Commit 08334824 authored by Alexander Duyck's avatar Alexander Duyck Committed by David S. Miller

GSO/UDP: Use skb->len instead of udph->len to determine length of original skb

It is possible for tunnels to end up generating IP or IPv6 datagrams that
are larger than 64K and expecting to be segmented.  As such we need to deal
with length values greater than 64K.  In order to accommodate this we need
to update the code to work with a 32b length value instead of a 16b one.
Signed-off-by: default avatarAlexander Duyck <aduyck@mirantis.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1e940829
...@@ -40,13 +40,19 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb, ...@@ -40,13 +40,19 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
__be16 protocol = skb->protocol; __be16 protocol = skb->protocol;
u16 mac_len = skb->mac_len; u16 mac_len = skb->mac_len;
int udp_offset, outer_hlen; int udp_offset, outer_hlen;
u32 partial; __wsum partial;
if (unlikely(!pskb_may_pull(skb, tnl_hlen))) if (unlikely(!pskb_may_pull(skb, tnl_hlen)))
goto out; goto out;
/* adjust partial header checksum to negate old length */ /* Adjust partial header checksum to negate old length.
partial = (__force u32)uh->check + (__force u16)~uh->len; * We cannot rely on the value contained in uh->len as it is
* possible that the actual value exceeds the boundaries of the
* 16 bit length field due to the header being added outside of an
* IP or IPv6 frame that was already limited to 64K - 1.
*/
partial = csum_sub(csum_unfold(uh->check),
(__force __wsum)htonl(skb->len));
/* setup inner skb. */ /* setup inner skb. */
skb->encapsulation = 0; skb->encapsulation = 0;
...@@ -119,8 +125,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb, ...@@ -119,8 +125,7 @@ static struct sk_buff *__skb_udp_tunnel_segment(struct sk_buff *skb,
if (!need_csum) if (!need_csum)
continue; continue;
uh->check = ~csum_fold((__force __wsum) uh->check = ~csum_fold(csum_add(partial, (__force __wsum)len));
((__force u32)len + partial));
if (skb->encapsulation || !offload_csum) { if (skb->encapsulation || !offload_csum) {
uh->check = gso_make_checksum(skb, ~uh->check); uh->check = gso_make_checksum(skb, ~uh->check);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment