Skip to content

Commit d96016a

Browse files
jsitnickikuba-moo
authored andcommitted
udp: Compute L4 checksum as usual when not segmenting the skb
If: 1) the user requested USO, but 2) there is not enough payload for GSO to kick in, and 3) the egress device doesn't offer checksum offload, then we want to compute the L4 checksum in software early on. In the case when we are not taking the GSO path, but it has been requested, the software checksum fallback in skb_segment doesn't get a chance to compute the full checksum, if the egress device can't do it. As a result we end up sending UDP datagrams with only a partial checksum filled in, which the peer will discard. Fixes: 10154db ("udp: Allow GSO transmit from devices with no checksum offload") Reported-by: Ivan Babrou <[email protected]> Signed-off-by: Jakub Sitnicki <[email protected]> Acked-by: Willem de Bruijn <[email protected]> Cc: [email protected] Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 56440d7 commit d96016a

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

net/ipv4/udp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,8 +951,10 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
951951
skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
952952
skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen,
953953
cork->gso_size);
954+
955+
/* Don't checksum the payload, skb will get segmented */
956+
goto csum_partial;
954957
}
955-
goto csum_partial;
956958
}
957959

958960
if (is_udplite) /* UDP-Lite */

net/ipv6/udp.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,8 +1266,10 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
12661266
skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
12671267
skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen,
12681268
cork->gso_size);
1269+
1270+
/* Don't checksum the payload, skb will get segmented */
1271+
goto csum_partial;
12691272
}
1270-
goto csum_partial;
12711273
}
12721274

12731275
if (is_udplite)

0 commit comments

Comments
 (0)