virtio-net: drop the multi-buffer XDP packet in zerocopy
Subsystems (6)
PATCH v2 1/1 virtio-net: drop the multi-buffer XDP packet in zerocopy
In virtio-net, we have not yet supported multi-buffer XDP packet in zerocopy mode when there is a binding XDP program. However, in that case, when receiving multi-buffer XDP packet, we skip the XDP program and return XDP_PASS. As a result, the packet is passed to normal network stack which is an incorrect behavior (e.g. a XDP program for packet count is installed, multi-buffer XDP packet arrives and does go through XDP program. As a result, the packet count does not increase but the packet is still received from network stack).This commit instead returns XDP_ABORTED in that case.
---
Changes in v2:
- Return XDP_ABORTED instead of XDP_DROP, make clearer explanation in commit message
--- drivers/net/virtio_net.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/net/virtio_net.c +8 -3
@@ -1379,9 +1379,14 @@ static struct sk_buff *virtnet_receive_xsk_merge(struct net_device *dev, struct ret =XDP_PASS ;rcu_read_lock (); prog =rcu_dereference (rq->xdp_prog); -/* TODO: support multi buffer. */ -if (prog && num_buf ==1 ) - ret =virtnet_xdp_handler (prog, xdp, dev, xdp_xmit, stats); +if (prog) { +/* TODO: support multi buffer. */ +if (num_buf ==1 ) + ret =virtnet_xdp_handler (prog, xdp, dev, xdp_xmit, + stats); +else + ret =XDP_ABORTED ; + }rcu_read_unlock ();switch (ret) {
Signature · 1 line
2.43.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 11 lines · On Wed, 22 Oct 2025 22:56:30 +0700 you wrote:
In virtio-net, we have not yet supported multi-buffer XDP packet in zerocopy mode when there is a binding XDP program. However, in that case, when receiving multi-buffer XDP packet, we skip the XDP program and return
XDP_PASS. As a result, the packet is passed to normal network stack which is an incorrect behavior (e.g. a XDP program for packet count is installed, multi-buffer XDP packet arrives and does go through XDP program. As a result, the packet count does not increase but the packet is still received from network stack).This commit instead returnsXDP_ABORTEDin that case.[...]
Here is the summary with links:
- [net,v2] virtio-net: drop the multi-buffer XDP packet in zerocopy
https://git.kernel.org/netdev/net/c/1ab665817448
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html