]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
virtio-net: drop the multi-buffer XDP packet in zerocopy
authorBui Quang Minh <minhquangbui99@gmail.com>
Wed, 22 Oct 2025 15:56:30 +0000 (22:56 +0700)
committerJakub Kicinski <kuba@kernel.org>
Fri, 24 Oct 2025 00:30:40 +0000 (17:30 -0700)
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.

Fixes: 99c861b44eb1 ("virtio_net: xsk: rx: support recv merge mode")
Cc: stable@vger.kernel.org
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Signed-off-by: Bui Quang Minh <minhquangbui99@gmail.com>
Link: https://patch.msgid.link/20251022155630.49272-1-minhquangbui99@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/virtio_net.c

index a757cbcab87f6420641583401649027f6aec4583..8e8a179aaa491529ffeda99661bc6be4accbc7ed 100644 (file)
@@ -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) {