xdp-project / xdp-tutorial

XDP tutorial
2.33k stars 562 forks source link

XDP_REDIRECT results in all packets being dropped #348

Closed pchaseh closed 1 year ago

pchaseh commented 1 year ago

I am attempting to run the xdp_router program from xdp_prog_kern_03.c so that packets received on one interface are redirected to the other. As it currently stands, I'm using the test environment included in this repository, and when I send a packet to the interface that the XDP program is attached to, it neither seems to get redirected properly nor is ever visible when running tcpdump despite the fact that bpf_redirect is successfully returning XDP_REDIRECT. I've also verified that the FIB lookup is returning the correct interface that I'd like to redirect to. Running ethtool -S test (with test being the interface that XDP is attached to) shows thatrx_queue_0_drops is increasing with each packet that I send. I additionally ran bpftrace -e 'tracepoint:xdp:xdp_redirect*_err {@redir_errno[-args->err] = count();}', and I'm seeing @redir_errno[95] in the output which would suggest that perhaps the operation is failing with EOPNOTSUPP I've also tried loading my program in both native and SKB mode, with the only difference being that in the latter case I have no visibility as to what's going on via either ethtool or bpftrace. The packets are still not visible in tcpdump.

How can I remediate this (assuming it's a reasonable expectation that bpf_redirect should work to some capacity given my scenario)? My current setup is as follows:

tohojo commented 1 year ago

Chase @.***> writes:

I additionally ran bpftrace -e 'tracepoint:xdp:xdp_redirect*_err ***@***.***_errno[-args->err] = count();}', and I'm seeing @.***_errno[95]in the output which would suggest that perhaps the operation is failing withEOPNOTSUPP`

This is indeed the correct way to debug that. This would indicate that the driver of the interface you're redirecting into doesn't implement support for that particular feature. What driver?

pchaseh commented 1 year ago

Chase @.> writes: I additionally ran `bpftrace -e 'tracepoint:xdp:xdp_redirect_err **@._errno[-args->err] = count();}'`, and I'm seeing @._errno[95]in the output which would suggest that perhaps the operation is failing withEOPNOTSUPP` This is indeed the correct way to debug that. This would indicate that the driver of the interface you're redirecting into doesn't implement support for that particular feature. What driver?

It looks like the driver is hv_netvsc, I do see that support was only recently added according to https://bugs.launchpad.net/ubuntu/+source/linux-azure/+bug/1972832, so it looks like I'll need 5.15 at least. I'll try this and close out the issue if I manage to get it working, thank you for the help

tohojo commented 1 year ago

Cool; you're welcome!

pchaseh commented 1 year ago

Fixed by upgrading to a linux-azure kernel version released after the linked patch