From: "Michael S. Tsirkin" <mst@redhat•com>
To: Xuan Zhuo <xuanzhuo@linux•alibaba.com>
Cc: netdev@vger•kernel.org, "Jason Wang" <jasowang@redhat•com>,
"Eugenio Pérez" <eperezma@redhat•com>,
"Andrew Lunn" <andrew+netdev@lunn•ch>,
"David S. Miller" <davem@davemloft•net>,
"Eric Dumazet" <edumazet@google•com>,
"Jakub Kicinski" <kuba@kernel•org>,
"Paolo Abeni" <pabeni@redhat•com>,
"Heng Qi" <hengqi@linux•alibaba.com>,
"Willem de Bruijn" <willemb@google•com>,
"Jiri Pirko" <jiri@resnulli•us>,
"Alvaro Karsz" <alvaro.karsz@solid-run•com>,
virtualization@lists•linux.dev
Subject: Re: [PATCH net v4 1/4] virtio-net: fix incorrect flags recording in big mode
Date: Sun, 9 Nov 2025 16:34:37 -0500 [thread overview]
Message-ID: <20251109163431-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20251029030913.20423-2-xuanzhuo@linux.alibaba.com>
On Wed, Oct 29, 2025 at 11:09:10AM +0800, Xuan Zhuo wrote:
> The purpose of commit 703eec1b2422 ("virtio_net: fixing XDP for fully
> checksummed packets handling") is to record the flags in advance, as
> their value may be overwritten in the XDP case. However, the flags
> recorded under big mode are incorrect, because in big mode, the passed
> buf does not point to the rx buffer, but rather to the page of the
> submitted buffer. This commit fixes this issue.
>
> For the small mode, the commit c11a49d58ad2 ("virtio_net: Fix mismatched
> buf address when unmapping for small packets") fixed it.
>
> Fixes: 703eec1b2422 ("virtio_net: fixing XDP for fully checksummed packets handling")
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux•alibaba.com>
> Acked-by: Jason Wang <jasowang@redhat•com>
Acked-by: Michael S. Tsirkin <mst@redhat•com>
> ---
> drivers/net/virtio_net.c | 16 +++++++++++-----
> 1 file changed, 11 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
> index 8e8a179aaa49..59f116b609f6 100644
> --- a/drivers/net/virtio_net.c
> +++ b/drivers/net/virtio_net.c
> @@ -2625,22 +2625,28 @@ static void receive_buf(struct virtnet_info *vi, struct receive_queue *rq,
> return;
> }
>
> - /* 1. Save the flags early, as the XDP program might overwrite them.
> + /* About the flags below:
> + * 1. Save the flags early, as the XDP program might overwrite them.
> * These flags ensure packets marked as VIRTIO_NET_HDR_F_DATA_VALID
> * stay valid after XDP processing.
> * 2. XDP doesn't work with partially checksummed packets (refer to
> * virtnet_xdp_set()), so packets marked as
> * VIRTIO_NET_HDR_F_NEEDS_CSUM get dropped during XDP processing.
> */
> - flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
>
> - if (vi->mergeable_rx_bufs)
> + if (vi->mergeable_rx_bufs) {
> + flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
> skb = receive_mergeable(dev, vi, rq, buf, ctx, len, xdp_xmit,
> stats);
> - else if (vi->big_packets)
> + } else if (vi->big_packets) {
> + void *p = page_address((struct page *)buf);
> +
> + flags = ((struct virtio_net_common_hdr *)p)->hdr.flags;
> skb = receive_big(dev, vi, rq, buf, len, stats);
> - else
> + } else {
> + flags = ((struct virtio_net_common_hdr *)buf)->hdr.flags;
> skb = receive_small(dev, vi, rq, buf, ctx, len, xdp_xmit, stats);
> + }
>
> if (unlikely(!skb))
> return;
> --
> 2.32.0.3.g01195cf9f
next prev parent reply other threads:[~2025-11-09 21:34 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 3:09 [PATCH net v4 0/4] fixes two virtio-net related bugs Xuan Zhuo
2025-10-29 3:09 ` [PATCH net v4 1/4] virtio-net: fix incorrect flags recording in big mode Xuan Zhuo
2025-11-09 17:04 ` Alyssa Ross
2025-11-09 21:34 ` Michael S. Tsirkin [this message]
2025-10-29 3:09 ` [PATCH net v4 2/4] virtio-net: Ensure hdr_len is not set unless the header is forwarded to the device Xuan Zhuo
2025-10-30 2:42 ` Jason Wang
2025-11-09 21:37 ` Michael S. Tsirkin
2025-10-29 3:09 ` [PATCH net v4 3/4] virtio-net: correct hdr_len handling for VIRTIO_NET_F_GUEST_HDRLEN Xuan Zhuo
2025-10-30 2:53 ` Jason Wang
2025-11-09 21:41 ` Michael S. Tsirkin
2025-11-10 7:16 ` Jason Wang
2025-11-10 7:26 ` Michael S. Tsirkin
2025-11-10 7:39 ` Jason Wang
2025-11-10 16:10 ` Michael S. Tsirkin
2025-11-11 0:45 ` Jason Wang
2025-11-09 21:42 ` Michael S. Tsirkin
2025-10-29 3:09 ` [PATCH net v4 4/4] virtio-net: correct hdr_len handling for tunnel gso Xuan Zhuo
2025-10-29 9:51 ` Paolo Abeni
2025-10-30 8:02 ` [PATCH net v4 0/4] fixes two virtio-net related bugs Michael S. Tsirkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251109163431-mutt-send-email-mst@kernel.org \
--to=mst@redhat$(echo .)com \
--cc=alvaro.karsz@solid-run$(echo .)com \
--cc=andrew+netdev@lunn$(echo .)ch \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=eperezma@redhat$(echo .)com \
--cc=hengqi@linux$(echo .)alibaba.com \
--cc=jasowang@redhat$(echo .)com \
--cc=jiri@resnulli$(echo .)us \
--cc=kuba@kernel$(echo .)org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=virtualization@lists$(echo .)linux.dev \
--cc=willemb@google$(echo .)com \
--cc=xuanzhuo@linux$(echo .)alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox