From: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
To: netdev@vger.kernel.org
Cc: "Michael S. Tsirkin" <mst@redhat.com>,
"Jason Wang" <jasowang@redhat.com>,
"Xuan Zhuo" <xuanzhuo@linux.alibaba.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>,
"Willem de Bruijn" <willemb@google.com>,
"Jiri Pirko" <jiri@resnulli.us>,
"Alvaro Karsz" <alvaro.karsz@solid-run.com>,
"Heng Qi" <hengqi@linux.alibaba.com>,
virtualization@lists.linux.dev
Subject: [PATCH net v2 3/3] virtio-net: correct hdr_len handling for tunnel gso
Date: Mon, 13 Oct 2025 10:06:29 +0800 [thread overview]
Message-ID: <20251013020629.73902-4-xuanzhuo@linux.alibaba.com> (raw)
In-Reply-To: <20251013020629.73902-1-xuanzhuo@linux.alibaba.com>
The commit a2fb4bc4e2a6a03 ("net: implement virtio helpers to handle UDP
GSO tunneling.") introduces support for the UDP GSO tunnel feature in
virtio-net.
The virtio spec says:
If the \field{gso_type} has the VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV4 bit or
VIRTIO_NET_HDR_GSO_UDP_TUNNEL_IPV6 bit set, \field{hdr_len} accounts for
all the headers up to and including the inner transport.
The commit did not update the hdr_len to include the inner transport.
Fixes: a2fb4bc4e2a6a03 ("net: implement virtio helpers to handle UDP GSO tunneling.")
Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
---
include/linux/virtio_net.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/include/linux/virtio_net.h b/include/linux/virtio_net.h
index e059e9c57937..765fd5f471a4 100644
--- a/include/linux/virtio_net.h
+++ b/include/linux/virtio_net.h
@@ -403,6 +403,7 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb,
struct virtio_net_hdr *hdr = (struct virtio_net_hdr *)vhdr;
unsigned int inner_nh, outer_th;
int tnl_gso_type;
+ u16 hdr_len;
int ret;
tnl_gso_type = skb_shinfo(skb)->gso_type & (SKB_GSO_UDP_TUNNEL |
@@ -434,6 +435,23 @@ virtio_net_hdr_tnl_from_skb(const struct sk_buff *skb,
outer_th = skb->transport_header - skb_headroom(skb);
vhdr->inner_nh_offset = cpu_to_le16(inner_nh);
vhdr->outer_th_offset = cpu_to_le16(outer_th);
+
+ switch (skb->inner_ipproto) {
+ case IPPROTO_TCP:
+ hdr_len = inner_tcp_hdrlen(skb);
+ break;
+
+ case IPPROTO_UDP:
+ hdr_len = sizeof(struct udphdr);
+ break;
+
+ default:
+ return -EINVAL;
+ }
+
+ hdr_len += skb_inner_transport_offset(skb);
+ hdr->hdr_len = __cpu_to_virtio16(little_endian, hdr_len);
+
return 0;
}
--
2.32.0.3.g01195cf9f
next prev parent reply other threads:[~2025-10-13 2:06 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-13 2:06 [PATCH net v2 0/3] fixes two virtio-net related bugs Xuan Zhuo
2025-10-13 2:06 ` [PATCH net v2 1/3] virtio-net: fix incorrect flags recording in big mode Xuan Zhuo
2025-10-13 2:06 ` [PATCH net v2 2/3] virtio-net: correct hdr_len handling for VIRTIO_NET_F_GUEST_HDRLEN Xuan Zhuo
2025-10-13 2:06 ` Xuan Zhuo [this message]
2025-10-13 8:11 ` [PATCH net v2 3/3] virtio-net: correct hdr_len handling for tunnel gso Paolo Abeni
2025-10-14 2:58 ` Xuan Zhuo
2025-10-13 5:56 ` [PATCH net v2 0/3] fixes two virtio-net related bugs Jason Wang
2025-10-14 2:56 ` Xuan Zhuo
2025-10-13 7:56 ` Michael S. Tsirkin
2025-10-14 2:55 ` Xuan Zhuo
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=20251013020629.73902-4-xuanzhuo@linux.alibaba.com \
--to=xuanzhuo@linux.alibaba.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=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=virtualization@lists.linux.dev \
--cc=willemb@google.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).