fou: eliminate IPv4,v6 specific GRO functions
authorTom Herbert <therbert@google.com>
Fri, 3 Oct 2014 22:48:08 +0000 (15:48 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 3 Oct 2014 23:53:32 +0000 (16:53 -0700)
This patch removes fou[46]_gro_receive and fou[46]_gro_complete
functions. The v4 or v6 variants were chosen for the UDP offloads
based on the address family of the socket this is not necessary
or correct. Alternatively, this patch adds is_ipv6 to napi_gro_skb.
This is set in udp6_gro_receive and unset in udp4_gro_receive. In
fou_gro_receive the value is used to select the correct inet_offloads
for the protocol of the outer IP header.

Signed-off-by: Tom Herbert <therbert@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/netdevice.h
net/ipv4/fou.c
net/ipv4/udp_offload.c
net/ipv6/udp_offload.c

index 910fb17ad14898ac9fdbc3d91e951f6b1182bb59..22d54b9b700d9a05ece03073cce0a980d082d63d 100644 (file)
@@ -1886,6 +1886,9 @@ struct napi_gro_cb {
        /* Number of checksums via CHECKSUM_UNNECESSARY */
        u8      csum_cnt:3;
 
+       /* Used in foo-over-udp, set in udp[46]_gro_receive */
+       u8      is_ipv6:1;
+
        /* used to support CHECKSUM_COMPLETE for tunneling protocols */
        __wsum  csum;
 
index dced89fbe480c53b798f202088d3da8716131533..7e2126a31f2e9b963afc51a4dbd553fb2fc8574c 100644 (file)
@@ -65,14 +65,15 @@ static int fou_udp_recv(struct sock *sk, struct sk_buff *skb)
 }
 
 static struct sk_buff **fou_gro_receive(struct sk_buff **head,
-                                       struct sk_buff *skb,
-                                       const struct net_offload **offloads)
+                                       struct sk_buff *skb)
 {
        const struct net_offload *ops;
        struct sk_buff **pp = NULL;
        u8 proto = NAPI_GRO_CB(skb)->proto;
+       const struct net_offload **offloads;
 
        rcu_read_lock();
+       offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
        if (!ops || !ops->callbacks.gro_receive)
                goto out_unlock;
@@ -85,14 +86,15 @@ out_unlock:
        return pp;
 }
 
-static int fou_gro_complete(struct sk_buff *skb, int nhoff,
-                           const struct net_offload **offloads)
+static int fou_gro_complete(struct sk_buff *skb, int nhoff)
 {
        const struct net_offload *ops;
        u8 proto = NAPI_GRO_CB(skb)->proto;
        int err = -ENOSYS;
+       const struct net_offload **offloads;
 
        rcu_read_lock();
+       offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
        ops = rcu_dereference(offloads[proto]);
        if (WARN_ON(!ops || !ops->callbacks.gro_complete))
                goto out_unlock;
@@ -105,28 +107,6 @@ out_unlock:
        return err;
 }
 
-static struct sk_buff **fou4_gro_receive(struct sk_buff **head,
-                                        struct sk_buff *skb)
-{
-       return fou_gro_receive(head, skb, inet_offloads);
-}
-
-static int fou4_gro_complete(struct sk_buff *skb, int nhoff)
-{
-       return fou_gro_complete(skb, nhoff, inet_offloads);
-}
-
-static struct sk_buff **fou6_gro_receive(struct sk_buff **head,
-                                        struct sk_buff *skb)
-{
-       return fou_gro_receive(head, skb, inet6_offloads);
-}
-
-static int fou6_gro_complete(struct sk_buff *skb, int nhoff)
-{
-       return fou_gro_complete(skb, nhoff, inet6_offloads);
-}
-
 static int fou_add_to_port_list(struct fou *fou)
 {
        struct fou *fout;
@@ -199,20 +179,8 @@ static int fou_create(struct net *net, struct fou_cfg *cfg,
 
        sk->sk_allocation = GFP_ATOMIC;
 
-       switch (cfg->udp_config.family) {
-       case AF_INET:
-               fou->udp_offloads.callbacks.gro_receive = fou4_gro_receive;
-               fou->udp_offloads.callbacks.gro_complete = fou4_gro_complete;
-               break;
-       case AF_INET6:
-               fou->udp_offloads.callbacks.gro_receive = fou6_gro_receive;
-               fou->udp_offloads.callbacks.gro_complete = fou6_gro_complete;
-               break;
-       default:
-               err = -EPFNOSUPPORT;
-               goto error;
-       }
-
+       fou->udp_offloads.callbacks.gro_receive = fou_gro_receive;
+       fou->udp_offloads.callbacks.gro_complete = fou_gro_complete;
        fou->udp_offloads.port = cfg->udp_config.local_udp_port;
        fou->udp_offloads.ipproto = cfg->protocol;
 
index 8c35f2c939ee55247e9c95d21bd4c9395628f8fa..507310ef4b5681bd8e59ba779e0560ecc3e5d04e 100644 (file)
@@ -334,6 +334,7 @@ static struct sk_buff **udp4_gro_receive(struct sk_buff **head,
                skb_gro_checksum_try_convert(skb, IPPROTO_UDP, uh->check,
                                             inet_gro_compute_pseudo);
 skip:
+       NAPI_GRO_CB(skb)->is_ipv6 = 0;
        return udp_gro_receive(head, skb, uh);
 
 flush:
index 8f96988c1db2ee9fb5fb0c012d4dfd3a0de1163c..6b8f543f6ac6ac76c2efaec21b4489fe347f9544 100644 (file)
@@ -140,6 +140,7 @@ static struct sk_buff **udp6_gro_receive(struct sk_buff **head,
                                             ip6_gro_compute_pseudo);
 
 skip:
+       NAPI_GRO_CB(skb)->is_ipv6 = 1;
        return udp_gro_receive(head, skb, uh);
 
 flush: