Skip to contentSkip to conversation

XDP and AF_XDP

DISCUSSION Michael A. Flückiger 2 participants 2 messages Aug 18, 2020

lore
Share & tools
lore
#0 lore raw

Hi all

I've recently discovered XDP / AF_XDP, and I now familiarize myself with the very interesting technology. Two questions came up, and I'm sure that the XDP community will be able to answer them a lot faster than if I search for documents in the www jungle.. :)

- An user land application is able to read and process incoming data directly from the AF_XDP socket. I'm wondering what happens when an application writes data into the AF_XDP socket? Are these frames directly sent out on the respective network interface?

- Whats the current status on XDP support on TX? Is it possible to intercept the TX queue (outgoing packets) or is still "just" the processing of incoming packets possible? Where could I find documents covering such updates?

Thanks for your effort!

Best,

Michi

#1 lore raw
Quoted 11 lines · Michael A. Flückiger

Hi all

I've recently discovered XDP / AF_XDP, and I now familiarize myself with the very interesting technology. Two questions came up, and I'm sure that the XDP community will be able to answer them a lot faster than if I search for documents in the www jungle.. :)

- An user land application is able to read and process incoming data directly from the AF_XDP socket. I'm wondering what happens when an application writes data into the AF_XDP socket? Are these frames directly sent out on the respective network interface?

You can send packets from AF_XDP as well, but it's not a regular socket. Please see the documentation here:
https://www.kernel.org/doc/html/latest/networking/af_xdp.html

Quoted 4 lines

- Whats the current status on XDP support on TX? Is it possible to intercept the TX queue (outgoing packets) or is still "just" the processing of incoming packets possible? Where could I find documents covering such updates?

There's no 'XDP TX' hook, but there are a few other options: When redirecting packets via the bpf_redirect_map() helper, you can attach a second XDP program to the map entries, which gives you a "post-redirect" hook that is tied to the destination. This is analogous to an XDP hook on TX, but only for packets that were redirected from XDP.

For packets coming from the regular networking stack, you can use the TC eBPF hook to modify traffic instead; it is possible to write eBPF programs that can be reused across the XDP and TC hooks (basically, by putting the logic in a function that you call from a small wrapper function in each hook type).

-Toke