[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACGkMEszWAc_552TmyqH1grZLDK7ZO_dJ7mr1JD+YK=BphFJZQ@mail.gmail.com>
Date: Thu, 30 Oct 2025 10:42:28 +0800
From: Jason Wang <jasowang@...hat.com>
To: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
Cc: netdev@...r.kernel.org, "Michael S. Tsirkin" <mst@...hat.com>,
Eugenio Pérez <eperezma@...hat.com>,
Andrew Lunn <andrew+netdev@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Heng Qi <hengqi@...ux.alibaba.com>, Willem de Bruijn <willemb@...gle.com>,
Jiri Pirko <jiri@...nulli.us>, Alvaro Karsz <alvaro.karsz@...id-run.com>,
virtualization@...ts.linux.dev
Subject: Re: [PATCH net v4 2/4] virtio-net: Ensure hdr_len is not set unless
the header is forwarded to the device.
On Wed, Oct 29, 2025 at 11:09 AM Xuan Zhuo <xuanzhuo@...ux.alibaba.com> wrote:
>
> Although `virtio_net_hdr_from_skb` is used in several places outside of
> `virtio-net.c`, the `hdr_len` field is only utilized by the device
> according to the specification. Therefore, we do not need to set
> `hdr_len` unless the header is actually passed to the device.
>
> Signed-off-by: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
I wonder if this will cause any issue consider hdr_len is just a hint.
E.g device needs to survive from hdr_len = 0.
> ---
> include/linux/virtio_net.h | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
> index 4d1780848d0e..710ae0d2d336 100644
> --- a/include/linux/virtio_net.h
> +++ b/include/linux/virtio_net.h
> @@ -218,9 +218,14 @@ static inline int virtio_net_hdr_from_skb(const struct sk_buff *skb,
> if (skb_is_gso(skb)) {
> struct skb_shared_info *sinfo = skb_shinfo(skb);
>
> - /* This is a hint as to how much should be linear. */
> - hdr->hdr_len = __cpu_to_virtio16(little_endian,
> - skb_headlen(skb));
> + /* In certain code paths (such as the af_packet.c receive path),
> + * this function may be called without a transport header.
> + * In this case, we do not need to set the hdr_len.
> + */
> + if (skb_transport_header_was_set(skb))
> + hdr->hdr_len = __cpu_to_virtio16(little_endian,
> + skb_headlen(skb));
> +
> hdr->gso_size = __cpu_to_virtio16(little_endian,
> sinfo->gso_size);
> if (sinfo->gso_type & SKB_GSO_TCPV4)
> --
> 2.32.0.3.g01195cf9f
>
Thanks
Powered by blists - more mailing lists