GRE: Disable segmentation offloads w/ CSUM and we are encapsulated via FOU
authorAlexander Duyck <aduyck@mirantis.com>
Tue, 5 Apr 2016 16:13:39 +0000 (09:13 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 7 Apr 2016 20:56:33 +0000 (16:56 -0400)
This patch fixes an issue I found in which we were dropping frames if we
had enabled checksums on GRE headers that were encapsulated by either FOU
or GUE.  Without this patch I was barely able to get 1 Gb/s of throughput.
With this patch applied I am now at least getting around 6 Gb/s.

The issue is due to the fact that with FOU or GUE applied we do not provide
a transport offset pointing to the GRE header, nor do we offload it in
software as the GRE header is completely skipped by GSO and treated like a
VXLAN or GENEVE type header.  As such we need to prevent the stack from
generating it and also prevent GRE from generating it via any interface we
create.

Fixes: c3483384ee511 ("gro: Allow tunnel stacking in the case of FOU/GUE")
Signed-off-by: Alexander Duyck <aduyck@mirantis.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/core/dev.c
net/ipv4/fou.c
net/ipv4/gre_offload.c
net/ipv4/ip_gre.c

index cb0d5d09c2e4f86243a7f3ac2acc0d61fe3da1a9..8395308a24456028f22621c5e00f757c4c817576 100644 (file)
@@ -2120,7 +2120,10 @@ struct napi_gro_cb {
        /* Used in foo-over-udp, set in udp[46]_gro_receive */
        u8      is_ipv6:1;
 
-       /* 7 bit hole */
+       /* Used in GRE, set in fou/gue_gro_receive */
+       u8      is_fou:1;
+
+       /* 6 bit hole */
 
        /* used to support CHECKSUM_COMPLETE for tunneling protocols */
        __wsum  csum;
index b9bcbe77d913b15dcbe7cdc9ee6cb7f74ee55aee..77a71cd68535fc02ae939168934fa4fb4f419644 100644 (file)
@@ -4439,6 +4439,7 @@ static enum gro_result dev_gro_receive(struct napi_struct *napi, struct sk_buff
                NAPI_GRO_CB(skb)->flush = 0;
                NAPI_GRO_CB(skb)->free = 0;
                NAPI_GRO_CB(skb)->encap_mark = 0;
+               NAPI_GRO_CB(skb)->is_fou = 0;
                NAPI_GRO_CB(skb)->gro_remcsum_start = 0;
 
                /* Setup for GRO checksum validation */
index 5a94aea280d35cebd94d35f4be756a3cea2163a4..a39068b4a4d99383096c3c970c4c15f1ee464617 100644 (file)
@@ -203,6 +203,9 @@ static struct sk_buff **fou_gro_receive(struct sk_buff **head,
         */
        NAPI_GRO_CB(skb)->encap_mark = 0;
 
+       /* Flag this frame as already having an outer encap header */
+       NAPI_GRO_CB(skb)->is_fou = 1;
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
@@ -368,6 +371,9 @@ static struct sk_buff **gue_gro_receive(struct sk_buff **head,
         */
        NAPI_GRO_CB(skb)->encap_mark = 0;
 
+       /* Flag this frame as already having an outer encap header */
+       NAPI_GRO_CB(skb)->is_fou = 1;
+
        rcu_read_lock();
        offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[guehdr->proto_ctype]);
index c47539d04b88a78457e1f6badc5770cc931b469c..6a5bd43178666eed954c4ee6f22837059fad470d 100644 (file)
@@ -150,6 +150,14 @@ static struct sk_buff **gre_gro_receive(struct sk_buff **head,
        if ((greh->flags & ~(GRE_KEY|GRE_CSUM)) != 0)
                goto out;
 
+       /* We can only support GRE_CSUM if we can track the location of
+        * the GRE header.  In the case of FOU/GUE we cannot because the
+        * outer UDP header displaces the GRE header leaving us in a state
+        * of limbo.
+        */
+       if ((greh->flags & GRE_CSUM) && NAPI_GRO_CB(skb)->is_fou)
+               goto out;
+
        type = greh->protocol;
 
        rcu_read_lock();
index 31936d387cfd58b75218d340f683880e486c7351..af5d1f38217f4e4dcb977b6410d0d9a6a6c1e87c 100644 (file)
@@ -862,9 +862,16 @@ static void __gre_tunnel_init(struct net_device *dev)
        dev->hw_features        |= GRE_FEATURES;
 
        if (!(tunnel->parms.o_flags & TUNNEL_SEQ)) {
-               /* TCP offload with GRE SEQ is not supported. */
-               dev->features    |= NETIF_F_GSO_SOFTWARE;
-               dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+               /* TCP offload with GRE SEQ is not supported, nor
+                * can we support 2 levels of outer headers requiring
+                * an update.
+                */
+               if (!(tunnel->parms.o_flags & TUNNEL_CSUM) ||
+                   (tunnel->encap.type == TUNNEL_ENCAP_NONE)) {
+                       dev->features    |= NETIF_F_GSO_SOFTWARE;
+                       dev->hw_features |= NETIF_F_GSO_SOFTWARE;
+               }
+
                /* Can use a lockless transmit, unless we generate
                 * output sequences
                 */
This page took 0.031315 seconds and 5 git commands to generate.