diff options
author | Florian Fainelli <f.fainelli@gmail.com> | 2017-04-08 11:55:22 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-08 16:49:36 -0400 |
commit | 16c5dcb13a371feae0e680e6518775b5335b37d8 (patch) | |
tree | 2dd0fe414dc67bcef0da6c4e2a19178650145fe3 | |
parent | 9d7f9c4f78e95dd9d17199a53d903262530be62e (diff) |
net: dsa: Move skb_unshare() to dsa_switch_rcv()
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>
-rw-r--r-- | net/dsa/dsa.c | 4 | ||||
-rw-r--r-- | net/dsa/tag_brcm.c | 5 | ||||
-rw-r--r-- | net/dsa/tag_dsa.c | 5 | ||||
-rw-r--r-- | net/dsa/tag_edsa.c | 5 | ||||
-rw-r--r-- | net/dsa/tag_mtk.c | 5 | ||||
-rw-r--r-- | net/dsa/tag_qca.c | 5 | ||||
-rw-r--r-- | net/dsa/tag_trailer.c | 5 |
7 files changed, 4 insertions, 30 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 6cad15da5892..d370c8bfa372 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c | |||
@@ -906,6 +906,10 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, | |||
906 | return 0; | 906 | return 0; |
907 | } | 907 | } |
908 | 908 | ||
909 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
910 | if (!skb) | ||
911 | return 0; | ||
912 | |||
909 | return dst->rcv(skb, dev, pt, orig_dev); | 913 | return dst->rcv(skb, dev, pt, orig_dev); |
910 | } | 914 | } |
911 | 915 | ||
diff --git a/net/dsa/tag_brcm.c b/net/dsa/tag_brcm.c index 68d4feef96d4..263941769c88 100644 --- a/net/dsa/tag_brcm.c +++ b/net/dsa/tag_brcm.c | |||
@@ -102,10 +102,6 @@ static int brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, | |||
102 | 102 | ||
103 | ds = dst->cpu_switch; | 103 | ds = dst->cpu_switch; |
104 | 104 | ||
105 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
106 | if (skb == NULL) | ||
107 | goto out; | ||
108 | |||
109 | if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN))) | 105 | if (unlikely(!pskb_may_pull(skb, BRCM_TAG_LEN))) |
110 | goto out_drop; | 106 | goto out_drop; |
111 | 107 | ||
@@ -151,7 +147,6 @@ static int brcm_tag_rcv(struct sk_buff *skb, struct net_device *dev, | |||
151 | 147 | ||
152 | out_drop: | 148 | out_drop: |
153 | kfree_skb(skb); | 149 | kfree_skb(skb); |
154 | out: | ||
155 | return 0; | 150 | return 0; |
156 | } | 151 | } |
157 | 152 | ||
diff --git a/net/dsa/tag_dsa.c b/net/dsa/tag_dsa.c index 377569c0e4f7..b7032699eaad 100644 --- a/net/dsa/tag_dsa.c +++ b/net/dsa/tag_dsa.c | |||
@@ -77,10 +77,6 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev, | |||
77 | int source_device; | 77 | int source_device; |
78 | int source_port; | 78 | int source_port; |
79 | 79 | ||
80 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
81 | if (skb == NULL) | ||
82 | goto out; | ||
83 | |||
84 | if (unlikely(!pskb_may_pull(skb, DSA_HLEN))) | 80 | if (unlikely(!pskb_may_pull(skb, DSA_HLEN))) |
85 | goto out_drop; | 81 | goto out_drop; |
86 | 82 | ||
@@ -175,7 +171,6 @@ static int dsa_rcv(struct sk_buff *skb, struct net_device *dev, | |||
175 | 171 | ||
176 | out_drop: | 172 | out_drop: |
177 | kfree_skb(skb); | 173 | kfree_skb(skb); |
178 | out: | ||
179 | return 0; | 174 | return 0; |
180 | } | 175 | } |
181 | 176 | ||
diff --git a/net/dsa/tag_edsa.c b/net/dsa/tag_edsa.c index 30520ff9c9a2..b87009672b40 100644 --- a/net/dsa/tag_edsa.c +++ b/net/dsa/tag_edsa.c | |||
@@ -90,10 +90,6 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev, | |||
90 | int source_device; | 90 | int source_device; |
91 | int source_port; | 91 | int source_port; |
92 | 92 | ||
93 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
94 | if (skb == NULL) | ||
95 | goto out; | ||
96 | |||
97 | if (unlikely(!pskb_may_pull(skb, EDSA_HLEN))) | 93 | if (unlikely(!pskb_may_pull(skb, EDSA_HLEN))) |
98 | goto out_drop; | 94 | goto out_drop; |
99 | 95 | ||
@@ -194,7 +190,6 @@ static int edsa_rcv(struct sk_buff *skb, struct net_device *dev, | |||
194 | 190 | ||
195 | out_drop: | 191 | out_drop: |
196 | kfree_skb(skb); | 192 | kfree_skb(skb); |
197 | out: | ||
198 | return 0; | 193 | return 0; |
199 | } | 194 | } |
200 | 195 | ||
diff --git a/net/dsa/tag_mtk.c b/net/dsa/tag_mtk.c index 836c311a3c38..d0a477084870 100644 --- a/net/dsa/tag_mtk.c +++ b/net/dsa/tag_mtk.c | |||
@@ -55,10 +55,6 @@ static int mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, | |||
55 | int port; | 55 | int port; |
56 | __be16 *phdr, hdr; | 56 | __be16 *phdr, hdr; |
57 | 57 | ||
58 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
59 | if (!skb) | ||
60 | goto out; | ||
61 | |||
62 | if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) | 58 | if (unlikely(!pskb_may_pull(skb, MTK_HDR_LEN))) |
63 | goto out_drop; | 59 | goto out_drop; |
64 | 60 | ||
@@ -105,7 +101,6 @@ static int mtk_tag_rcv(struct sk_buff *skb, struct net_device *dev, | |||
105 | 101 | ||
106 | out_drop: | 102 | out_drop: |
107 | kfree_skb(skb); | 103 | kfree_skb(skb); |
108 | out: | ||
109 | return 0; | 104 | return 0; |
110 | } | 105 | } |
111 | 106 | ||
diff --git a/net/dsa/tag_qca.c b/net/dsa/tag_qca.c index 6579d6db1bc6..d1324649808c 100644 --- a/net/dsa/tag_qca.c +++ b/net/dsa/tag_qca.c | |||
@@ -75,10 +75,6 @@ static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, | |||
75 | int port; | 75 | int port; |
76 | __be16 *phdr, hdr; | 76 | __be16 *phdr, hdr; |
77 | 77 | ||
78 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
79 | if (!skb) | ||
80 | goto out; | ||
81 | |||
82 | if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN))) | 78 | if (unlikely(!pskb_may_pull(skb, QCA_HDR_LEN))) |
83 | goto out_drop; | 79 | goto out_drop; |
84 | 80 | ||
@@ -126,7 +122,6 @@ static int qca_tag_rcv(struct sk_buff *skb, struct net_device *dev, | |||
126 | 122 | ||
127 | out_drop: | 123 | out_drop: |
128 | kfree_skb(skb); | 124 | kfree_skb(skb); |
129 | out: | ||
130 | return 0; | 125 | return 0; |
131 | } | 126 | } |
132 | 127 | ||
diff --git a/net/dsa/tag_trailer.c b/net/dsa/tag_trailer.c index f5c764ee2968..1fc0b221a70f 100644 --- a/net/dsa/tag_trailer.c +++ b/net/dsa/tag_trailer.c | |||
@@ -68,10 +68,6 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev, | |||
68 | 68 | ||
69 | ds = dst->cpu_switch; | 69 | ds = dst->cpu_switch; |
70 | 70 | ||
71 | skb = skb_unshare(skb, GFP_ATOMIC); | ||
72 | if (skb == NULL) | ||
73 | goto out; | ||
74 | |||
75 | if (skb_linearize(skb)) | 71 | if (skb_linearize(skb)) |
76 | goto out_drop; | 72 | goto out_drop; |
77 | 73 | ||
@@ -100,7 +96,6 @@ static int trailer_rcv(struct sk_buff *skb, struct net_device *dev, | |||
100 | 96 | ||
101 | out_drop: | 97 | out_drop: |
102 | kfree_skb(skb); | 98 | kfree_skb(skb); |
103 | out: | ||
104 | return 0; | 99 | return 0; |
105 | } | 100 | } |
106 | 101 | ||