From: Florian Fainelli <f.fainelli@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, andrew@lunn.ch,
vivien.didelot@savoirfairelinux.com,
Florian Fainelli <f.fainelli@gmail.com>
Subject: [PATCH net-next 2/3] net: dsa: Move skb_unshare() to dsa_switch_rcv()
Date: Fri, 7 Apr 2017 13:41:53 -0700 [thread overview]
Message-ID: <20170407204154.9651-3-f.fainelli@gmail.com> (raw)
In-Reply-To: <20170407204154.9651-1-f.fainelli@gmail.com>
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>
---
net/dsa/dsa.c | 4 ++++
net/dsa/tag_brcm.c | 5 -----
net/dsa/tag_dsa.c | 5 -----
net/dsa/tag_edsa.c | 5 -----
net/dsa/tag_qca.c | 5 -----
net/dsa/tag_trailer.c | 5 -----
6 files changed, 4 insertions(+), 25 deletions(-)
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c
index 95d1a756202c..c20da7bfc771 100644
--- a/net/dsa/dsa.c
+++ b/net/dsa/dsa.c
@@ -903,6 +903,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);
}
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,
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;
}
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,
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;
}
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,
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;
}
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,
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;
}
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,
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;
}
--
2.9.3
next prev parent reply other threads:[~2017-04-07 20:42 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-07 20:41 [PATCH net-next 0/3] net: dsa: Receive path simplifications Florian Fainelli
2017-04-07 20:41 ` [PATCH net-next 1/3] net: dsa: Do not check for NULL dst in tag parsers Florian Fainelli
2017-04-07 20:53 ` Vivien Didelot
2017-04-07 20:54 ` Andrew Lunn
2017-04-07 20:41 ` Florian Fainelli [this message]
2017-04-07 20:53 ` [PATCH net-next 2/3] net: dsa: Move skb_unshare() to dsa_switch_rcv() Vivien Didelot
2017-04-07 20:56 ` Andrew Lunn
2017-04-07 20:41 ` [PATCH net-next 3/3] net: dsa: Factor bottom tag receive functions Florian Fainelli
2017-04-07 20:54 ` Vivien Didelot
2017-04-08 2:33 ` kbuild test robot
2017-04-08 2:56 ` kbuild test robot
2017-04-07 20:53 ` [PATCH net-next 0/3] net: dsa: Receive path simplifications Andrew Lunn
2017-04-07 20:55 ` Florian Fainelli
2017-04-07 20:59 ` Andrew Lunn
2017-04-07 21:17 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170407204154.9651-3-f.fainelli@gmail.com \
--to=f.fainelli@gmail.com \
--cc=andrew@lunn.ch \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=vivien.didelot@savoirfairelinux.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).