]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
net: dsa: Move skb_unshare() to dsa_switch_rcv()
authorFlorian Fainelli <f.fainelli@gmail.com>
Sat, 8 Apr 2017 15:55:22 +0000 (08:55 -0700)
committerDavid S. Miller <davem@davemloft.net>
Sat, 8 Apr 2017 20:49:36 +0000 (13:49 -0700)
All DSA tag receive functions need to unshare the skb before mangling it, move
this to the generic dsa_switch_rcv() function which will allow us to make the
tag receive function return their mangled skb without caring about freeing a
NULL skb.

Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/dsa/dsa.c
net/dsa/tag_brcm.c
net/dsa/tag_dsa.c
net/dsa/tag_edsa.c
net/dsa/tag_mtk.c
net/dsa/tag_qca.c
net/dsa/tag_trailer.c

index 6cad15da58922ad06aa663d54aebdd6fff92e0ae..d370c8bfa372f484676041f946fc4006fd3c7af8 100644 (file)
@@ -906,6 +906,10 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev,
                return 0;
        }
 
+       skb = skb_unshare(skb, GFP_ATOMIC);
+       if (!skb)
+               return 0;
+
        return dst->rcv(skb, dev, pt, orig_dev);
 }
 
index 68d4feef96d4f92748e2ac91166f671393ed3148..263941769c88d3c63072830d9845e2d0f7be684d 100644 (file)
@@ -102,10 +102,6 @@ static int brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
 
        ds = dst->cpu_switch;
 
-       skb = skb_unshare(skb, GFP_ATOMIC);
-       if (skb == NULL)
-               goto out;
-
        if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN)))
                goto out_drop;
 
@@ -151,7 +147,6 @@ static int brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev,
 
 out_drop:
        kfree_skb(skb);
-out:
        return 0;
 }
 
index 377569c0e4f7c307c02ddd793f1a1dbd1f1e6d78..b7032699eaadfa90d56bd88ee68ba921a73c017d 100644 (file)
@@ -77,10 +77,6 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev,
        int source_device;
        int source_port;
 
-       skb = skb_unshare(skb, GFP_ATOMIC);
-       if (skb == NULL)
-               goto out;
-
        if (unlikely(!pskb_may_pull(skb, DSA_HLEN)))
                goto out_drop;
 
@@ -175,7 +171,6 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev,
 
 out_drop:
        kfree_skb(skb);
-out:
        return 0;
 }
 
index 30520ff9c9a28f7331a1ab40ecfaebb44920609c..b87009672b40a21b10f523e1c478b6ae5786a20f 100644 (file)
@@ -90,10 +90,6 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev,
        int source_device;
        int source_port;
 
-       skb = skb_unshare(skb, GFP_ATOMIC);
-       if (skb == NULL)
-               goto out;
-
        if (unlikely(!pskb_may_pull(skb, EDSA_HLEN)))
                goto out_drop;
 
@@ -194,7 +190,6 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev,
 
 out_drop:
        kfree_skb(skb);
-out:
        return 0;
 }
 
index 836c311a3c386b36fcb33d3ff26cf7dc69cf604b..d0a477084870821b58a2f7007c6f404da8ce441b 100644 (file)
@@ -55,10 +55,6 @@ static int mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
        int port;
        __be16 *phdr, hdr;
 
-       skb = skb_unshare(skb, GFP_ATOMIC);
-       if (!skb)
-               goto out;
-
        if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN)))
                goto out_drop;
 
@@ -105,7 +101,6 @@ static int mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev,
 
 out_drop:
        kfree_skb(skb);
-out:
        return 0;
 }
 
index 6579d6db1bc6209a80849124d89880387dd6498b..d1324649808c0a2917f1606baa0e3d6740e9f0f6 100644 (file)
@@ -75,10 +75,6 @@ static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
        int port;
        __be16 *phdr, hdr;
 
-       skb = skb_unshare(skb, GFP_ATOMIC);
-       if (!skb)
-               goto out;
-
        if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN)))
                goto out_drop;
 
@@ -126,7 +122,6 @@ static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev,
 
 out_drop:
        kfree_skb(skb);
-out:
        return 0;
 }
 
index f5c764ee29680a9a2ced6087191b008a9a503573..1fc0b221a70fd8def65755e0eae03d90d36a94d8 100644 (file)
@@ -68,10 +68,6 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev,
 
        ds = dst->cpu_switch;
 
-       skb = skb_unshare(skb, GFP_ATOMIC);
-       if (skb == NULL)
-               goto out;
-
        if (skb_linearize(skb))
                goto out_drop;
 
@@ -100,7 +96,6 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev,
 
 out_drop:
        kfree_skb(skb);
-out:
        return 0;
 }