Commit 229740c6 authored by Jarno Rajahalme's avatar Jarno Rajahalme Committed by David S. Miller

udp_offload: Set encapsulation before inner completes.

UDP tunnel segmentation code relies on the inner offsets being set for
an UDP tunnel GSO packet, but the inner *_complete() functions will
set the inner offsets only if 'encapsulation' is set before calling
them.  Currently, udp_gro_complete() sets 'encapsulation' only after
the inner *_complete() functions are done.  This causes the inner
offsets having invalid values after udp_gro_complete() returns, which
in turn will make it impossible to properly segment the packet in case
it needs to be forwarded, which would be visible to the user either as
invalid packets being sent or as packet loss.

This patch fixes this by setting skb's 'encapsulation' in
udp_gro_complete() before calling into the inner complete functions,
and by making each possible UDP tunnel gro_complete() callback set the
inner_mac_header to the beginning of the tunnel payload.
Signed-off-by: default avatarJarno Rajahalme <jarno@ovn.org>
Reviewed-by: default avatarAlexander Duyck <aduyck@mirantis.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 43b8448c
...@@ -514,6 +514,9 @@ static int geneve_gro_complete(struct sk_buff *skb, int nhoff, ...@@ -514,6 +514,9 @@ static int geneve_gro_complete(struct sk_buff *skb, int nhoff,
err = ptype->callbacks.gro_complete(skb, nhoff + gh_len); err = ptype->callbacks.gro_complete(skb, nhoff + gh_len);
rcu_read_unlock(); rcu_read_unlock();
skb_set_inner_mac_header(skb, nhoff + gh_len);
return err; return err;
} }
......
...@@ -616,6 +616,9 @@ static struct sk_buff **vxlan_gro_receive(struct sk_buff **head, ...@@ -616,6 +616,9 @@ static struct sk_buff **vxlan_gro_receive(struct sk_buff **head,
static int vxlan_gro_complete(struct sk_buff *skb, int nhoff, static int vxlan_gro_complete(struct sk_buff *skb, int nhoff,
struct udp_offload *uoff) struct udp_offload *uoff)
{ {
/* Sets 'skb->inner_mac_header' since we are always called with
* 'skb->encapsulation' set.
*/
return eth_gro_complete(skb, nhoff + sizeof(struct vxlanhdr)); return eth_gro_complete(skb, nhoff + sizeof(struct vxlanhdr));
} }
......
...@@ -2164,6 +2164,9 @@ struct packet_offload { ...@@ -2164,6 +2164,9 @@ struct packet_offload {
struct udp_offload; struct udp_offload;
/* 'skb->encapsulation' is set before gro_complete() is called. gro_complete()
* must set 'skb->inner_mac_header' to the beginning of tunnel payload.
*/
struct udp_offload_callbacks { struct udp_offload_callbacks {
struct sk_buff **(*gro_receive)(struct sk_buff **head, struct sk_buff **(*gro_receive)(struct sk_buff **head,
struct sk_buff *skb, struct sk_buff *skb,
......
...@@ -236,6 +236,8 @@ static int fou_gro_complete(struct sk_buff *skb, int nhoff, ...@@ -236,6 +236,8 @@ static int fou_gro_complete(struct sk_buff *skb, int nhoff,
err = ops->callbacks.gro_complete(skb, nhoff); err = ops->callbacks.gro_complete(skb, nhoff);
skb_set_inner_mac_header(skb, nhoff);
out_unlock: out_unlock:
rcu_read_unlock(); rcu_read_unlock();
...@@ -412,6 +414,8 @@ static int gue_gro_complete(struct sk_buff *skb, int nhoff, ...@@ -412,6 +414,8 @@ static int gue_gro_complete(struct sk_buff *skb, int nhoff,
err = ops->callbacks.gro_complete(skb, nhoff + guehlen); err = ops->callbacks.gro_complete(skb, nhoff + guehlen);
skb_set_inner_mac_header(skb, nhoff + guehlen);
out_unlock: out_unlock:
rcu_read_unlock(); rcu_read_unlock();
return err; return err;
......
...@@ -399,6 +399,11 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff) ...@@ -399,6 +399,11 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff)
uh->len = newlen; uh->len = newlen;
/* Set encapsulation before calling into inner gro_complete() functions
* to make them set up the inner offsets.
*/
skb->encapsulation = 1;
rcu_read_lock(); rcu_read_lock();
uo_priv = rcu_dereference(udp_offload_base); uo_priv = rcu_dereference(udp_offload_base);
...@@ -421,9 +426,6 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff) ...@@ -421,9 +426,6 @@ int udp_gro_complete(struct sk_buff *skb, int nhoff)
if (skb->remcsum_offload) if (skb->remcsum_offload)
skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM; skb_shinfo(skb)->gso_type |= SKB_GSO_TUNNEL_REMCSUM;
skb->encapsulation = 1;
skb_set_inner_mac_header(skb, nhoff + sizeof(struct udphdr));
return err; return err;
} }
......
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