[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251011094107.16439-4-xuanzhuo@linux.alibaba.com>
Date: Sat, 11 Oct 2025 17:41:07 +0800
From: Xuan Zhuo <xuanzhuo@...ux.alibaba.com>
To: netdev@...r.kernel.org
Cc: "Michael S. Tsirkin" <mst@...hat.com>,
Jason Wang <jasowang@...hat.com>,
Xuan Zhuo <xuanzhuo@...ux.alibaba.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>,
Willem de Bruijn <willemb@...gle.com>,
Jiri Pirko <jiri@...nulli.us>,
Alvaro Karsz <alvaro.karsz@...id-run.com>,
Heng Qi <hengqi@...ux.alibaba.com>,
virtualization@...ts.linux.dev
Subject: [PATCH net v1 3/3] virtio-net: correct hdr_len handling for tunnel gso
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@...ux.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 10ca53b3a399..742cce34a24e 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
Powered by blists - more mailing lists