Commit 8c3a897b authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

inet: restore gso for vxlan

Alexei reported a performance regression on vxlan, caused
by commit 3347c960 "ipv4: gso: make inet_gso_segment() stackable"

GSO vxlan packets were not properly segmented, adding IP fragments
while they were not expected.

Rename 'bool tunnel' to 'bool encap', and add a new boolean
to express the fact that UDP should be fragmented.
This fragmentation is triggered by skb->encapsulation being set.

Remove a "skb->encapsulation = 1" added in above commit,
as its not needed, as frags inherit skb->frag from original
GSO skb.
Reported-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Tested-by: default avatarAlexei Starovoitov <ast@plumgrid.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1f2cd845
...@@ -1251,8 +1251,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, ...@@ -1251,8 +1251,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
struct sk_buff *segs = ERR_PTR(-EINVAL); struct sk_buff *segs = ERR_PTR(-EINVAL);
const struct net_offload *ops; const struct net_offload *ops;
unsigned int offset = 0; unsigned int offset = 0;
bool udpfrag, encap;
struct iphdr *iph; struct iphdr *iph;
bool tunnel;
int proto; int proto;
int nhoff; int nhoff;
int ihl; int ihl;
...@@ -1290,8 +1290,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, ...@@ -1290,8 +1290,8 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
goto out; goto out;
__skb_pull(skb, ihl); __skb_pull(skb, ihl);
tunnel = SKB_GSO_CB(skb)->encap_level > 0; encap = SKB_GSO_CB(skb)->encap_level > 0;
if (tunnel) if (encap)
features = skb->dev->hw_enc_features & netif_skb_features(skb); features = skb->dev->hw_enc_features & netif_skb_features(skb);
SKB_GSO_CB(skb)->encap_level += ihl; SKB_GSO_CB(skb)->encap_level += ihl;
...@@ -1306,24 +1306,23 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb, ...@@ -1306,24 +1306,23 @@ static struct sk_buff *inet_gso_segment(struct sk_buff *skb,
if (IS_ERR_OR_NULL(segs)) if (IS_ERR_OR_NULL(segs))
goto out; goto out;
udpfrag = !!skb->encapsulation && proto == IPPROTO_UDP;
skb = segs; skb = segs;
do { do {
iph = (struct iphdr *)(skb_mac_header(skb) + nhoff); iph = (struct iphdr *)(skb_mac_header(skb) + nhoff);
if (!tunnel && proto == IPPROTO_UDP) { if (udpfrag) {
iph->id = htons(id); iph->id = htons(id);
iph->frag_off = htons(offset >> 3); iph->frag_off = htons(offset >> 3);
if (skb->next != NULL) if (skb->next != NULL)
iph->frag_off |= htons(IP_MF); iph->frag_off |= htons(IP_MF);
offset += skb->len - nhoff - ihl; offset += skb->len - nhoff - ihl;
} else { } else {
iph->id = htons(id++); iph->id = htons(id++);
} }
iph->tot_len = htons(skb->len - nhoff); iph->tot_len = htons(skb->len - nhoff);
ip_send_check(iph); ip_send_check(iph);
if (tunnel) { if (encap)
skb_reset_inner_headers(skb); skb_reset_inner_headers(skb);
skb->encapsulation = 1;
}
skb->network_header = (u8 *)iph - skb->head; skb->network_header = (u8 *)iph - skb->head;
} while ((skb = skb->next)); } while ((skb = skb->next));
......
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