All of lore.kernel.org
 help / color / mirror / Atom feed
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 2/4] virtio-net: Ensure hdr_len is not set unless the header is forwarded to the device.
Date: Sun, 9 Nov 2025 16:37:50 -0500	[thread overview]
Message-ID: <20251109163644-mutt-send-email-mst@kernel.org> (raw)
In-Reply-To: <20251029030913.20423-3-xuanzhuo@linux.alibaba.com>

On Wed, Oct 29, 2025 at 11:09:11AM +0800, Xuan Zhuo 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@linux.alibaba.com>

maybe ...  but what is this patch trying to achieve?
it does not seem harmful to set it ...


> ---
>  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


  parent reply	other threads:[~2025-11-09 21:37 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
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 [this message]
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=20251109163644-mutt-send-email-mst@kernel.org \
    --to=mst@redhat.com \
    --cc=alvaro.karsz@solid-run.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=eperezma@redhat.com \
    --cc=hengqi@linux.alibaba.com \
    --cc=jasowang@redhat.com \
    --cc=jiri@resnulli.us \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=virtualization@lists.linux.dev \
    --cc=willemb@google.com \
    --cc=xuanzhuo@linux.alibaba.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.