Commit d96016a7 authored by Jakub Sitnicki's avatar Jakub Sitnicki Committed by Jakub Kicinski
Browse files

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: 10154dbd ("udp: Allow GSO transmit from devices with no checksum offload")
Reported-by: default avatarIvan Babrou <ivan@cloudflare.com>
Signed-off-by: default avatarJakub Sitnicki <jakub@cloudflare.com>
Acked-by: default avatarWillem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20241011-uso-swcsum-fixup-v2-1-6e1ddc199af9@cloudflare.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 56440d7e
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -951,9 +951,11 @@ static int udp_send_skb(struct sk_buff *skb, struct flowi4 *fl4,
			skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
			skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen,
								 cork->gso_size);
		}

			/* Don't checksum the payload, skb will get segmented */
			goto csum_partial;
		}
	}

	if (is_udplite)  				 /*     UDP-Lite      */
		csum = udplite_csum(skb);
+3 −1
Original line number Diff line number Diff line
@@ -1266,9 +1266,11 @@ static int udp_v6_send_skb(struct sk_buff *skb, struct flowi6 *fl6,
			skb_shinfo(skb)->gso_type = SKB_GSO_UDP_L4;
			skb_shinfo(skb)->gso_segs = DIV_ROUND_UP(datalen,
								 cork->gso_size);
		}

			/* Don't checksum the payload, skb will get segmented */
			goto csum_partial;
		}
	}

	if (is_udplite)
		csum = udplite_csum(skb);