netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy
@ 2025-06-03 15:06 Bui Quang Minh
  2025-06-04  0:37 ` Jason Wang
                   ` (3 more replies)
  0 siblings, 4 replies; 15+ messages in thread
From: Bui Quang Minh @ 2025-06-03 15:06 UTC (permalink / raw)
  To: netdev
  Cc: Michael S. Tsirkin, Jason Wang, Xuan Zhuo, Eugenio Pérez,
	Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Alexei Starovoitov, Daniel Borkmann,
	Jesper Dangaard Brouer, John Fastabend, virtualization,
	linux-kernel, bpf, Bui Quang Minh, stable

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. This commit instead returns
XDP_DROP in that case.

Fixes: 99c861b44eb1 ("virtio_net: xsk: rx: support recv merge mode")
Cc: stable@vger.kernel.org
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
---
 drivers/net/virtio_net.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index e53ba600605a..4c35324d6e5b 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -1309,9 +1309,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_DROP;
+	}
 	rcu_read_unlock();
 
 	switch (ret) {
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2025-06-13 15:58 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-03 15:06 [PATCH net] virtio-net: drop the multi-buffer XDP packet in zerocopy Bui Quang Minh
2025-06-04  0:37 ` Jason Wang
2025-06-04 14:17   ` Bui Quang Minh
2025-06-05  0:46     ` Jason Wang
2025-06-04 16:55 ` Zvi Effron
2025-06-05 14:25   ` Bui Quang Minh
2025-06-05 11:03 ` Paolo Abeni
2025-06-05 14:33   ` Bui Quang Minh
2025-06-05 14:48     ` Jakub Kicinski
2025-06-06 15:48       ` Bui Quang Minh
2025-06-09 16:58         ` Jakub Kicinski
2025-06-10 15:18           ` Bui Quang Minh
2025-06-10 20:37             ` Jakub Kicinski
2025-06-13 15:58               ` Bui Quang Minh
2025-06-13  1:51 ` Xuan Zhuo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).