veth: check for NAPI instead of xdp_prog before xmit of XDP frame
Subsystems (3)
PATCH 1/1 veth: check for NAPI instead of xdp_prog before xmit of XDP frame
The recent patch that tied enabling of veth NAPI to the GRO flag also has the nice side effect that a veth device can be the target of an XDP_REDIRECT without an XDP program needing to be loaded on the peer device. However, the patch adding this extra NAPI mode didn't actually change the check in veth_xdp_xmit() to also look at the new NAPI pointer, so let's fix that.
--- drivers/net/veth.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/veth.c +3 -4
@@ -486,11 +486,10 @@ static int veth_xdp_xmit(struct net_device *dev, int n, rcv_priv =netdev_priv (rcv); rq = &rcv_priv->rq[veth_select_rxq (rcv)]; -/* Non-NULL xdp_prog ensures that xdp_ring is initialized on receive -* side. This means an XDP program is loaded on the peer and the peer -* device is up. +/* The napi pointer is set if NAPI is enabled, which ensures that +* xdp_ring is initialized on receive side and the peer device is up. */ -if (!rcu_access_pointer (rq->xdp_prog)) +if (!rcu_access_pointer (rq->napi)) goto out; max_len = rcv->mtu + rcv->hard_header_len +VLAN_HLEN ;
Signature · 1 line
2.31.1
Quoted 7 lines · On Fri, 16 Apr 2021 17:47:45 +0200 Toke Høiland-Jørgensen <[email protected]>…
The recent patch that tied enabling of veth NAPI to the GRO flag also has the nice side effect that a veth device can be the target of an
XDP_REDIRECTwithout an XDP program needing to be loaded on the peer device. However, the patch adding this extra NAPI mode didn't actually change the check inveth_xdp_xmit()to also look at the new NAPI pointer, so let's fix that.
Quoted 5 lines
Fixes 6788fa154546 ("veth: allow enabling NAPI even without XDP")Signed-off-by Toke Høiland-Jørgensen <[email protected]>--- drivers/net/veth.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
Very happy to see this strange requirement of loading an xdp_prog on the veth peer (inside the netns) being lifted. Multiple people/users have hit this issue and complained. Thanks for the followup to fix this! :-)
Quoted 19 lines
drivers/net/veth.c +3
-4@@ -486,11 +486,10 @@ static int veth_xdp_xmit(struct net_device *dev, int n, rcv_priv =netdev_priv (rcv); rq = &rcv_priv->rq[veth_select_rxq (rcv)]; -/* Non-NULL xdp_prog ensures that xdp_ring is initialized on receive -* side. This means an XDP program is loaded on the peer and the peer -* device is up. +/* The napi pointer is set if NAPI is enabled, which ensures that +* xdp_ring is initialized on receive side and the peer device is up. */ -if (!rcu_access_pointer (rq->xdp_prog)) +if (!rcu_access_pointer (rq->napi)) goto out; max_len = rcv->mtu + rcv->hard_header_len +VLAN_HLEN ;
Signature · 4 lines
Best regards, Jesper Dangaard Brouer MSc.CS, Principal Kernel Engineer at Red Hat LinkedIn: http://www.linkedin.com/in/brouer
Quoted 22 lines · Toke Høiland-Jørgensen
The recent patch that tied enabling of veth NAPI to the GRO flag also has the nice side effect that a veth device can be the target of an
XDP_REDIRECTwithout an XDP program needing to be loaded on the peer device. However, the patch adding this extra NAPI mode didn't actually change the check inveth_xdp_xmit()to also look at the new NAPI pointer, so let's fix that.Fixes 6788fa154546 ("veth: allow enabling NAPI even without XDP")Signed-off-by Toke Høiland-Jørgensen <[email protected]>--- drivers/net/veth.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)drivers/net/veth.c +0
-1@@ -486,11 +486,10 @@ static int veth_xdp_xmit(struct net_device *dev, int n, rcv_priv =netdev_priv (rcv); rq = &rcv_priv->rq[veth_select_rxq (rcv)]; -/* Non-NULL xdp_prog ensures that xdp_ring is initialized on receive
drivers/net/veth.c static int veth_xdp_xmit(struct net_device *dev, int n, · line 495
Quoted 10 lines
drivers/net/veth.c +3
-3-* side. This means an XDP program is loaded on the peer and the peer -* device is up. +/* The napi pointer is set if NAPI is enabled, which ensures that +* xdp_ring is initialized on receive side and the peer device is up. */ -if (!rcu_access_pointer (rq->xdp_prog)) +if (!rcu_access_pointer (rq->napi)) goto out; max_len = rcv->mtu + rcv->hard_header_len +VLAN_HLEN ;
Thanks for the quick turn-around!
This patch was applied to netdev/net-next.git (refs/heads/master):
Hello:
This patch was applied to netdev/net-next.git (refs/heads/master):
Quoted 8 lines · On Fri, 16 Apr 2021 17:47:45 +0200 you wrote:
The recent patch that tied enabling of veth NAPI to the GRO flag also has the nice side effect that a veth device can be the target of an
XDP_REDIRECTwithout an XDP program needing to be loaded on the peer device. However, the patch adding this extra NAPI mode didn't actually change the check inveth_xdp_xmit()to also look at the new NAPI pointer, so let's fix that.[...]
Here is the summary with links:
- [net-next] veth: check for NAPI instead of xdp_prog before xmit of XDP frame
https://git.kernel.org/netdev/net-next/c/0e672f306a28
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html