diff options
author | David S. Miller <davem@davemloft.net> | 2017-04-08 13:49:36 -0700 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-04-08 13:49:36 -0700 |
commit | 417d978fa532b61b89f0c3ccbd9cdb51090ea032 (patch) | |
tree | 93e0c28cdfcac7bb616f9b767c4a782a2e620bce /net/dsa/dsa.c | |
parent | 7f564528a480084e2318cd48caba7aef4a54a77f (diff) | |
parent | a86d8becc3f04a5e350b5a17530e6a01495c00a5 (diff) |
Merge branch 'dsa-receive-path-simplifications'
Florian Fainelli says:
====================
net: dsa: Receive path simplifications
This patch series does factor the common code found in all tag implementations
into dsa_switch_rcv(). The original motivation was to add GRO support, but this
may be a lot of work with unclear benefits at this point.
Changes in v2:
- take care of tag_mtk.c in the process
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/dsa/dsa.c')
-rw-r--r-- | net/dsa/dsa.c | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/net/dsa/dsa.c b/net/dsa/dsa.c index 6cad15da5892..1fb9cf7aaaf4 100644 --- a/net/dsa/dsa.c +++ b/net/dsa/dsa.c @@ -23,6 +23,7 @@ #include <linux/sysfs.h> #include <linux/phy_fixed.h> #include <linux/gpio/consumer.h> +#include <linux/etherdevice.h> #include <net/dsa.h> #include "dsa_priv.h" @@ -900,13 +901,34 @@ static int dsa_switch_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt, struct net_device *orig_dev) { struct dsa_switch_tree *dst = dev->dsa_ptr; + struct sk_buff *nskb = NULL; if (unlikely(dst == NULL)) { kfree_skb(skb); return 0; } - return dst->rcv(skb, dev, pt, orig_dev); + skb = skb_unshare(skb, GFP_ATOMIC); + if (!skb) + return 0; + + nskb = dst->rcv(skb, dev, pt, orig_dev); + if (!nskb) { + kfree_skb(skb); + return 0; + } + + skb = nskb; + skb_push(skb, ETH_HLEN); + skb->pkt_type = PACKET_HOST; + skb->protocol = eth_type_trans(skb, skb->dev); + + skb->dev->stats.rx_packets++; + skb->dev->stats.rx_bytes += skb->len; + + netif_receive_skb(skb); + + return 0; } static struct packet_type dsa_pack_type __read_mostly = { |