xdp-tutorial icon indicating copy to clipboard operation
xdp-tutorial copied to clipboard

Question about XDP_REDIRECT

Open aaroua5 opened this issue 4 years ago • 5 comments

Hello everybody,

I'm new to the XDP world and have a question about redirecting to other interfaces in XDP. The two functions bpf_redirect_map () and bpf_redirect () only takes one interface as an argument. In my case I want to redirect the frame from one ingress port to several egress ports at the same time. Is it possible ?

Thanks in Advance !

aaroua5 avatar Dec 28 '20 19:12 aaroua5

Achraf Aroua [email protected] writes:

Hello everybody,

I'm new to the XDP world and have a question about redirecting to other interfaces in XDP. The two functions bpf_redirect_map () and bpf_redirect () only takes one interface as an argument. In my case I want to redirect the frame from one ingress port to several egress ports at the same time. Is it possible ?

Not yet, but it's being worked on: https://lore.kernel.org/bpf/[email protected]/

tohojo avatar Dec 28 '20 21:12 tohojo

Do you know any other workaround I can use at the moment?

aaroua5 avatar Dec 31 '20 08:12 aaroua5

Achraf Aroua [email protected] writes:

Do you know any other workaround I can use at the moment?

You can XDP_PASS packets and handle the cloning in the regular stack...

tohojo avatar Dec 31 '20 11:12 tohojo

Firstly, you should use XDP_PASS to pass the packet to higher stack. After that, using tc mirred, and use sub module pedit to change "correct" destination mac address, unless you will overflow all port of your switch.

johanfirdi avatar Sep 12 '21 04:09 johanfirdi

Note also that the support for duplicating packets on XDP_REDIRECT has landed in the kernel as of kernel 5.14. See this commit for the sample that uses it: https://git.kernel.org/torvalds/c/e48cfe4bbfad

tohojo avatar Sep 12 '21 14:09 tohojo