Running AF_XDP inside Docker using veth driver

From: Yu-han Lin
Date: Wed Sep 18 2019 - 03:44:51 EST


Hello,

I wrote a test case handling network traffic in user-space inside a
Docker network
by using an XDP socket with libbpf. You can find the code in

https://github.com/glasnostic/af_xdp_test

My kernel version is 5.1 with XDP_SOCK enabled.

In this example, I have an unstable result while getting packets from
the XDP socket.
We can see a significant delay (~10s) until the packets are received
by the process.
It seems that XDP processes packets in batches and only when enough
packets exist,
all of the packets are sent to the userspace process.

This is a problem for traffic consisting of one packet (e.g. ARP, PING).

What is the correct way to deal with this problem?
E.g. can we force XDP to flush packets?

Thanks for the help.
- Yu-Han