tools/xdp/README.md
This directory contains tools for using XDP and, importantly, provides examples.
The xdp_loader program can attach one of three programs to a network device.
Those programs, specified via the -program flag, can be:
pass - Allow all traffic, passing it on to the kernel network stack.drop - Drop all traffic before it hits the kernel network stack.tcpdump - Use an AF_XDP socket to print all network traffic. Unlike the
normal tcpdump tool, intercepted packets are not also passed to the kernel
network stack.XDPThe XDP pass and drop programs simply allow or drop all traffic on a given NIC. These examples give an idea of how to use the Cilium eBPF library and how to build eBPF programs within gVisor.
AF_XDPThe code supporting tcpdump is a minimal example of using an AF_XDP socket
to receive packets. There are very few other examples of AF_XDP floating
around the internet. They all use the in-tree libbpf library
unfortunately.1
The XDP project has a useful example that uses libbpf. One must also look at libbpf itself to understand what's really going on.
XDP functionality has since moved to libxdp, but nobody seems to be using it yet. ↩