mirror of
https://github.com/torvalds/linux.git
synced 2026-05-27 00:22:00 +02:00
Merge branch 'udp-gso-fix-__udp_gso_segment-after-gso_partial-udp-length-change'
Gal Pressman says:
====================
udp: gso: Fix __udp_gso_segment() after GSO_PARTIAL UDP length change
This series fixes two issues introduced by commit b10b446ce7 ("udp:
gso: Use single MSS length in UDP header for GSO_PARTIAL"), which
switched __udp_gso_segment() to write the single MSS length into the UDP
header for GSO_PARTIAL skbs.
Patch 1 (from Alice) fixes the UDP checksum adjustment in
__udp_gso_segment().
The patch adjusts the checksum by the correct delta, and since msslen
and newlen become equivalent before the loop, drops one of the two
variables to simplify the code.
Patch 2 handles the case where the last segment of a GSO_PARTIAL skb is
itself a GSO skb. This happens when the original packet size is an exact
multiple of MSS, so the post-loop segment is not a remainder skb but a
full GSO chunk and must also carry the single MSS length in its UDP
header.
====================
Link: https://patch.msgid.link/20260518062250.3019914-1-gal@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
commit
9a8e01c500
|
|
@ -482,11 +482,11 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
|
|||
struct sock *sk = gso_skb->sk;
|
||||
unsigned int sum_truesize = 0;
|
||||
struct sk_buff *segs, *seg;
|
||||
__be16 newlen, msslen;
|
||||
struct udphdr *uh;
|
||||
unsigned int mss;
|
||||
bool copy_dtor;
|
||||
__sum16 check;
|
||||
__be16 newlen;
|
||||
int ret = 0;
|
||||
|
||||
mss = skb_shinfo(gso_skb)->gso_size;
|
||||
|
|
@ -555,15 +555,6 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
|
|||
return segs;
|
||||
}
|
||||
|
||||
msslen = htons(sizeof(*uh) + mss);
|
||||
|
||||
/* GSO partial and frag_list segmentation only requires splitting
|
||||
* the frame into an MSS multiple and possibly a remainder, both
|
||||
* cases return a GSO skb. So update the mss now.
|
||||
*/
|
||||
if (skb_is_gso(segs))
|
||||
mss *= skb_shinfo(segs)->gso_segs;
|
||||
|
||||
seg = segs;
|
||||
uh = udp_hdr(seg);
|
||||
|
||||
|
|
@ -586,7 +577,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
|
|||
if (!seg->next)
|
||||
break;
|
||||
|
||||
uh->len = msslen;
|
||||
uh->len = newlen;
|
||||
uh->check = check;
|
||||
|
||||
if (seg->ip_summed == CHECKSUM_PARTIAL)
|
||||
|
|
@ -599,9 +590,12 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
|
|||
uh = udp_hdr(seg);
|
||||
}
|
||||
|
||||
/* last packet can be partial gso_size, account for that in checksum */
|
||||
newlen = htons(skb_tail_pointer(seg) - skb_transport_header(seg) +
|
||||
seg->data_len);
|
||||
/* Unless skb fits perfectly as GSO_PARTIAL, the trailing
|
||||
* segment may not be full MSS, account for that in the checksum
|
||||
*/
|
||||
if (!skb_is_gso(seg))
|
||||
newlen = htons(skb_tail_pointer(seg) -
|
||||
skb_transport_header(seg) + seg->data_len);
|
||||
check = csum16_add(csum16_sub(uh->check, uh->len), newlen);
|
||||
|
||||
uh->len = newlen;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user