-
Notifications
You must be signed in to change notification settings - Fork 579
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Trying to write XDP for redirecting packets in veth inside kubernetes #399
Comments
Looks like XDP is not enabled on the peer veth device. This can be done
in one of two ways:
- Load a dummy XDP program on the peer
- Enable GRO on both peers of the veth device
I'm not sure if the second method works on a kernel that old, though, so
going for the first option is probably safer...
|
@tohojo Thanks for the reply. |
Here's how I setup my ENV and loaded dummy XDP onto veth of client / nginx1(backend) / nginx2(backend) I oringaly tried this on Ubuntu 20.04(with Kernel 5.4.0-144-generic), but I tried on Ubuntu 22.04(with Kernel 5.15.0-94-generic) yesterday, I could not figure out what was missing. My setup can be found at hire |
The GRO thing was added in kernel 5.13, so on that 5.15 kernel it should
be enough to just enable GRO on both ends of the veth device (i.e., both
outside and inside the container). No idea how to get docker to do this
for you, but it should be possible to just do it manually with ethtool
after starting up the containers...
|
I tried entering container and manually installed ethtool after starting up the containers, Maybe this don't work on docker env because the veth pair? I am wondering if I can mount eBPF to tc to redirect packet to other interfaces instead? |
VP ***@***.***> writes:
I tried entering container and manually installed ethtool after starting up the containers,
did `ethtool -K eth0 gro on` inside the container and `ethtool -K ${vethname} gro on` on host.
But it did not work either.
Yeah, that should work (on the 5.15 kernel). Did the error codes change?
Maybe this don't work on docker env because the veth pair?
ref: [Re: Veth pair swallow packets for XDP_TX operation](https://www.spinics.net/lists/netdev/msg625217.html)
But I tried mounting dummy onto other containers, that did not work either.
I am wondering if I can mount eBPF to tc to redirect packet to other interfaces instead?
Maybe sacrifice some performance but works?
Sure, you can use TC instead. If you're only doing things on veth
devices that won't hurt performance either; XDP on veth only really
makes sense performance-wise if you're redirecting frames into the veth
devices from a physical NIC using XDP. If you're just sending traffic
around between containers, just use TC :)
|
Hi, I am newbie to XDP.
I got inspired by this tutorial and wanted to test redirecting packets between veths on kubernetes
I used hard-coded IP and MAC address in the XDP, and used return
bpf_redirect
、XDP_TX
、XDP_REDIRECT
but none of them worked.
I traced XDP using perf, and here is the result
My ENV setup is in fowlling
test Pod YAML
Can anyone point out what I was wrong or missing?
The text was updated successfully, but these errors were encountered: