Skip to content

Commit 1ab6658

Browse files
minhbq-99kuba-moo
authored andcommitted
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. Fixes: 99c861b ("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>
1 parent 420c84c commit 1ab6658

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/net/virtio_net.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1379,9 +1379,14 @@ static struct sk_buff *virtnet_receive_xsk_merge(struct net_device *dev, struct
13791379
ret = XDP_PASS;
13801380
rcu_read_lock();
13811381
prog = rcu_dereference(rq->xdp_prog);
1382-
/* TODO: support multi buffer. */
1383-
if (prog && num_buf == 1)
1384-
ret = virtnet_xdp_handler(prog, xdp, dev, xdp_xmit, stats);
1382+
if (prog) {
1383+
/* TODO: support multi buffer. */
1384+
if (num_buf == 1)
1385+
ret = virtnet_xdp_handler(prog, xdp, dev, xdp_xmit,
1386+
stats);
1387+
else
1388+
ret = XDP_ABORTED;
1389+
}
13851390
rcu_read_unlock();
13861391

13871392
switch (ret) {

0 commit comments

Comments
 (0)