1. AF_XDP Support¶
PF_RING since version 7.5 (note: 7.9 is actually recommended) includes support for AF_XDP adapters, when compiling from source code this is enabled by default (unless the –disable-xdp configure flag is specified).
- PF_RING 7.9.0-6671 or later
- Dependencies: libelf-dev
- Kernel: >= 5.4 (configured with CONFIG_XDP_SOCKETS=y)
- libbpf with latest AF_XDP support installed from <kernel source>/tools/lib/bpf
- Hugepages loaded
1.2. Kernel Version¶
Install a kernel >= 5.4, which includes support for unaligned zero-copy buffers. Ubuntu 20 LTS currently runs a kernel 5.4 which fully supports AF_XDP. However the HWE kernel 5.8 is recommended as it provides improved AF_XDP support.
apt install libelf-dev
On Ubuntu 18.04 you can use uktools available at https://github.com/usbkey9/uktools/ following the instructions below:
git clone https://github.com/usbkey9/uktools && cd uktools make
Download and unpack sources for kernel 5.x:
wget http://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.8.tar.xz tar xvf linux-5.8.tar.xz
Compile and install libbpf:
cd linux-5.8/tools/lib/bpf make sudo make install_lib sudo make install_headers sudo ldconfig
Install PF_RING as reported in the Installing from packages section on a supported OS with a supported kernel version (e.g. Ubuntu 20) or compile it from source code. In the latter case AF_XDP support should be automatically detected and enabled:
cd PF_RING/userland ./configure make
Note: the –enable-xdp flag was required on previous pf_ring versions.
Please make sure the below output is printed by the configure script (this means AF_XDP support is actually detected and enabled).
checking PF_RING AF_XDP support... yes
1.4. Load the driver¶
Load vanilla drivers (use recent drivers that include AF_XDP support, PF_RING ZC drivers should be unloaded as they only support PF_RING ZC mode).
1.5. Load Hugepages¶
Hugepages are required for the AF_XDP support to work (used for buffers allocation). When installing from packages following the Installing from packages guide it is only required to create /etc/pf_ring/hugepages.conf, otherwise hugepages can be loaded with:
echo 1024 > /sys/kernel/mm/hugepages/hugepages-2048kB/nr_hugepages mount -t hugetlbfs nodev /dev/hugepages
You are now ready to run any pf_ring sample application using xdp:<interface>@<queue> as interface name. Example:
cd examples sudo ./pfcount -i xdp:eth1@0
Please note that with AF_XDP pf_ring attaches to a NIC queue, please disable RSS or open all queues.