Re: [PATCH net v5 2/4] net: gso: count the inner UDP header of encapsulated UDP GSO packets

From: netdev-bot+sashiko

Date: Sun Nov 15 2026 - 19:47:36 EST


Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 0 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The new encapsulated SKB_GSO_UDP_L4 case in
skb_gso_transport_seglen() (net/core/gso.c) adds sizeof(struct udphdr)…

--

net: gso: count the inner UDP header of encapsulated UDP GSO packets

This commit changes skb_gso_transport_seglen() so that it adds
sizeof(struct udphdr) for encapsulated SKB_GSO_UDP_L4 packets, the same
way the unencapsulated branch does. Without it, each segment of a
tunnelled UDP GSO packet is counted 8 bytes short. As a result,
ip_forward() and ip_finish_output_gso() let DF segments that are slightly
too large leave without being fragmented.

> diff --git a/net/core/gso.c b/net/core/gso.c
> index b5bd269e56e4e..eb95c9d2819b1 100644
> --- a/net/core/gso.c
> +++ b/net/core/gso.c
> @@ -156,6 +156,8 @@ static unsigned int skb_gso_transport_seglen(const struct sk_buff *skb)
>
> if (likely(shinfo->gso_type & (SKB_GSO_TCPV4 | SKB_GSO_TCPV6)))
> thlen += inner_tcp_hdrlen(skb);
> + else if (shinfo->gso_type & SKB_GSO_UDP_L4)
> + thlen += sizeof(struct udphdr);

[Severity: High]
Does this cover encapsulated UDP GSO skbs that fraglist GRO builds?

The encapsulated branch computes its base as:

thlen = skb_inner_transport_header(skb) -
skb_transport_header(skb);

That only works if inner_transport_header has been set. On the UDP GRO
side, the only code that sets it is udp_gro_complete_segment():

net/ipv4/udp_offload.c:udp_gro_complete_segment() {
...
if (skb->encapsulation)
skb->inner_transport_header = skb->transport_header;
...
}

Take a receive device with NETIF_F_GRO_FRAGLIST and a UDP tunnel socket
such as VXLAN. The inner flow usually finds no socket in
udp_gro_receive(), so it is marked for fraglist:

if (skb->dev->features & NETIF_F_GRO_FRAGLIST)
NAPI_GRO_CB(skb)->is_flist = sk ? !udp_test_bit(GRO_ENABLED, sk) : 1;

On completion, the outer udp_gro_complete() clears encap_mark, sets
skb->encapsulation = 1 and calls the tunnel's gro_complete. The inner
udp4_gro_complete() then takes the fraglist branch and returns early:

if (NAPI_GRO_CB(skb)->is_flist && !NAPI_GRO_CB(skb)->encap_mark) {
udp_set_len(uh, skb->len - nhoff);

skb_shinfo(skb)->gso_type |= (SKB_GSO_FRAGLIST|SKB_GSO_UDP_L4);
skb_shinfo(skb)->gso_segs = NAPI_GRO_CB(skb)->count;
...
return 0;
}

udp6_gro_complete() has the same branch. Neither of them reaches
udp_gro_complete_segment(). inet_gro_complete() and eth_gro_complete()
only set the inner network and mac offsets.

The resulting skb has encapsulation set, and its gso_type is
SKB_GSO_UDP_TUNNEL[_CSUM] | SKB_GSO_FRAGLIST | SKB_GSO_UDP_L4. Its
inner_transport_header is still 0, and transport_header points at the
outer UDP header.

Doesn't the subtraction above then wrap to (unsigned)(-T), where T is the
offset of the outer UDP header from skb->head?

With a normal gso_size, the network seglen would come out more than 100
bytes below the real value. ip_exceeds_mtu() in ip_forward() and
ip_finish_output_gso() would then still pass oversized DF segments.

If gso_size is smaller than T - 28, the value wraps to nearly 4G instead.
Valid packets would then get ICMP frag-needed or be dropped.

The commit message says segments "built by UDP GRO behind a tunnel
socket" are miscounted. The fraglist variant of that same setup still
gets the wrong length, so the added 8 bytes make no difference there. No
later patch in the series seems to touch net/core/gso.c or the udp
offload files.

Would it make sense to also set inner_transport_header in the fraglist
branches of udp4_gro_complete() and udp6_gro_complete() when
skb->encapsulation is set? At that point skb->transport_header should
point at the inner UDP header.

--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/cover.1794151759.git.julius%40bairaktaris.de