Skip to contentSkip to conversation

udp: Complement partial checksum for GSO packet

PATCH Applied Sean Tranchetti 3 participants 4 messages May 1, 2018 – May 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udp: Complement partial checksum for GSO packet

Using the udp_v4_check() function to calculate the pseudo header for the newly segmented UDP packets results in assigning the complement of the value to the UDP header checksum field.

Always undo the complement the partial checksum value in order to match the case where GSO is not used on the UDP transmit path.

Fixes ee80d1ebe5ba ("udp: add udp gso")
---
 net/ipv4/udp_offload.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/udp_offload.c +1 -0
index f78fb36..0062570 100644
@@ -223,6 +223,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
 			csum_replace2(&uh->check, htons(mss),
 				      htons(seg->len - hdrlen - sizeof(*uh)));
 
+		uh->check = ~uh->check;
 		seg->destructor = sock_wfree;
 		seg->sk = sk;
 		sum_truesize += seg->truesize;
Signature · 1 line
1.9.1
#1 lore raw
Quoted 19 lines · Sean Tranchetti

Using the udp_v4_check() function to calculate the pseudo header for the newly segmented UDP packets results in assigning the complement of the value to the UDP header checksum field.

Always undo the complement the partial checksum value in order to match the case where GSO is not used on the UDP transmit path.

Fixes ee80d1ebe5ba ("udp: add udp gso")
---
 net/ipv4/udp_offload.c | 1 +
 1 file changed, 1 insertion(+)
net/ipv4/udp_offload.c +0 -0
index f78fb36..0062570 100644

net/ipv4/udp_offload.c struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb, · line 229

Quoted 7 lines
net/ipv4/udp_offload.c +1 -0
@@ -223,6 +223,7 @@ struct sk_buff *__udp_gso_segment(struct sk_buff *gso_skb,
                        csum_replace2(&uh->check, htons(mss),
                                      htons(seg->len - hdrlen - sizeof(*uh)));
 
+               uh->check = ~uh->check;
                seg->destructor = sock_wfree;
                seg->sk = sk;
                sum_truesize += seg->truesize;

Thanks, this looks plausible. I may have been mistaken by evaluation showing packets arriving at the peer with the correct checksum before.

On retesting, packets arrive with correct checksum in both cases, and even when setting purposely bad uh->check values.

Perhaps the two platforms I tested on (bnx2x, mlx4) ignore the pseudo header and recompute from scratch if CHECKSUM_PARTIAL is set for udp. Still having a look..

#2 lore raw
Quoted 11 lines · Willem de Bruijn
Quoted 10 lines · Sean Tranchetti

Using the udp_v4_check() function to calculate the pseudo header for the newly segmented UDP packets results in assigning the complement of the value to the UDP header checksum field.

Always undo the complement the partial checksum value in order to match the case where GSO is not used on the UDP transmit path.

Fixes ee80d1ebe5ba ("udp: add udp gso")

Thanks Sean.

maintainer Applied
#3 lore raw

From: Willem de Bruijn <[email protected]>
Date: Wed, 2 May 2018 11:25:43 +0200

Quoted 10 lines
Quoted 8 lines · Willem de Bruijn
Quoted 7 lines · Sean Tranchetti

Using the udp_v4_check() function to calculate the pseudo header for the newly segmented UDP packets results in assigning the complement of the value to the UDP header checksum field.

Always undo the complement the partial checksum value in order to match the case where GSO is not used on the UDP transmit path.

Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Fixes ee80d1ebe5ba ("udp: add udp gso")

Thanks Sean.

Applied, thanks everyone.