FastNetMon Advanced AF_XDP support

What is AF_XDP?

AF_XDP is a new kernel bypass technology integrated into the Linux Kernel. It offers very high performance and low CPU overhead. It does not require any additional licenses or third-party libraries. You can use it to process 1G, 10G or even 40G of traffic.

We recommend using the AF_PACKET capture engine for production deployments. AF_XDP support has some limitations and is not ready for production use:

  • Supports only a single interface
  • Uses only a single queue per network card
  • Requires manual configuration with ethtool

AF_PACKET is a way simpler to operate and offers better scalability.

Dependencies

You need to have at least Linux kernel 4.19 or more recent.

Modes

There are two modes of AF_XDP

  • Copy mode (works for all NIC supported in Linux). It offers great compatibility, but does not offer top performance
  • Native (driver) mode. Offers decent performance and requires support from the driver. Supported only for Intel XL710 now

In FastNetMon, you can require native mode support using force_native_mode_xdp option

Configuration

This mode requires XDP microprogram to work properly. You can download it here: xdp_kernel.o and put it to /root/xdp_kernel.o. Optionally, you can compile it on your own.

You can enable this mode in FastNetMon using the following commands:

sudo fcli set main mirror_xdp enable
sudo fcli set main microcode_xdp_path /root/xdp_kernel.o
sudo fcli set main force_native_mode_xdp disable
sudo fcli set main poll_mode_xdp enable
sudo fcli set main xdp_set_promisc enable
sudo fcli set main interfaces_xdp ethX

To get maximum throughput (but it will also increase CPU usage) you may disable poll_mode_xdp. It will switch FastNetMon into "active polling" mode and will eat the whole CPU.

When you enable AF_XDP, FastNetMon detaches the interface from the standard Linux Network stack. To return it, please reboot the machine.

FastNetMon binds only to the first RX queue. By default, your NIC allocates many queues, and you can reduce the number of them to 1 this way:

sudo ethtool --set-channels eth4 combined 1