i have a question about how exactly bpf redirect working BPF_MAP_TYPE_CPUMAP array, i saw it's a new feture on xdp-project repo and read are adding ability to run another (2nd) XDP-prog on the remote CPU the XDP packets is getting redirected to, i read the userspace code and i'm quite confused because i see a redirection interface is required, so in this case this new feature enabling the xdp on interface A to execute another xdp on interface B which recieves the "redirected" packets from interface A, right? if i'm not right so thanks in advance to make the picture clear.
It is a bit confusing, the original CPUMAP feature was only intended to redirect packets to a different CPU when handing packets to the kernel for SKB allocation: https://lwn.net/Articles/735193/.
In this patch, the ability was added to allow you to execute a second XDP program on the target CPU, for hardware without RSS support.
So you don't need a second program to use CPUMAP at all, and if you do, you don't need an interface.
The "sample" in the kernel has been modified may times and has many flags, which is great to demonstrate all the different use cases, but it also makes it really difficult to understand. At this point it is more like a test command for kernel developers than an concise example. These interface options are likely added to demonstrate that you can still redirect to interfaces from this second XDP program.
The original version of the sample is a lot easier:
This is the first version of the sample which has interface redirecting, in this version it is easier to see that both the program and redirect interfaces are optional: