XDP programs with eBPF

Two projects with example code:

Kernel samples/bpf

The kernel include some examples of XDP-eBPF programs, see kernel samples/bpf.

There are also some XDP eBPF code examples in the prototype-kernel project under prototype-kernel/kernel/samples/bpf. Simply run make inside this directory to compile the samples.

Special XDP eBPF cases

With XDP the eBPF program gets “direct” access to the raw/unstructured packet-data. Thus, eBPF uses some “direct access” instruction for accessing this data, but for safety this need to pass the in-kernel validator.

Walking the packet data, requires writing the boundary checks in a specialized manor.


if (data + nh_off > data_end)
              return rc;