udp: gso: Use single MSS length in UDP header for GSO_PARTIAL

In GSO_PARTIAL segmentation, set the UDP length field to the single
segment size (gso_size + UDP header) instead of the large MSS size.
This provides hardware with a template length value for final
segmentation, similar to how tunnel GSO_PARTIAL handles outer headers
in UDP tunnels.

This will remove the need to manually adjust the UDP header length in
the drivers, as can be seen in subsequent patches.

This was suggested by Alex in 2018:
https://lore.kernel.org/netdev/CAKgT0UcdnUWgr3KQ=RnLKigokkiUuYefmL-ePpDvJOBNpKScFA@mail.gmail.com/

Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com>
Signed-off-by: Gal Pressman <gal@nvidia.com>
Reviewed-by: Willem de Bruijn <willemb@google.com>
Link: https://patch.msgid.link/20260125121649.778086-2-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Gal Pressman 2026-01-25 14:16:47 +02:00 committed by Jakub Kicinski
parent d64f761dbf
commit b10b446ce7

View File

@ -483,11 +483,11 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
struct sock *sk = gso_skb->sk; struct sock *sk = gso_skb->sk;
unsigned int sum_truesize = 0; unsigned int sum_truesize = 0;
struct sk_buff *segs, *seg; struct sk_buff *segs, *seg;
__be16 newlen, msslen;
struct udphdr *uh; struct udphdr *uh;
unsigned int mss; unsigned int mss;
bool copy_dtor; bool copy_dtor;
__sum16 check; __sum16 check;
__be16 newlen;
int ret = 0; int ret = 0;
mss = skb_shinfo(gso_skb)->gso_size; mss = skb_shinfo(gso_skb)->gso_size;
@ -555,6 +555,8 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
return segs; return segs;
} }
msslen = htons(sizeof(*uh) + mss);
/* GSO partial and frag_list segmentation only requires splitting /* GSO partial and frag_list segmentation only requires splitting
* the frame into an MSS multiple and possibly a remainder, both * the frame into an MSS multiple and possibly a remainder, both
* cases return a GSO skb. So update the mss now. * cases return a GSO skb. So update the mss now.
@ -584,7 +586,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
if (!seg->next) if (!seg->next)
break; break;
uh->len = newlen; uh->len = msslen;
uh->check = check; uh->check = check;
if (seg->ip_summed == CHECKSUM_PARTIAL) if (seg->ip_summed == CHECKSUM_PARTIAL)