diff options
author | Nicolas Dichtel <nicolas.dichtel@6wind.com> | 2013-06-26 10:11:27 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2013-06-28 01:29:05 -0400 |
commit | 621e84d6f373dcb273ebfd772638b8e7dc3c2c48 (patch) | |
tree | 55135ee5450006f25cca4f14c8206524f976149b /net/core | |
parent | 38ae92dc215e939897f17861d658f882d0eaab0f (diff) |
dev: introduce skb_scrub_packet()
The goal of this new function is to perform all needed cleanup before sending
an skb into another netns.
Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 11 | ||||
-rw-r--r-- | net/core/skbuff.c | 23 |
2 files changed, 24 insertions, 10 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index 722f633926e0..370354a9c5f6 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -1652,22 +1652,13 @@ int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) | |||
1652 | } | 1652 | } |
1653 | } | 1653 | } |
1654 | 1654 | ||
1655 | skb_orphan(skb); | ||
1656 | |||
1657 | if (unlikely(!is_skb_forwardable(dev, skb))) { | 1655 | if (unlikely(!is_skb_forwardable(dev, skb))) { |
1658 | atomic_long_inc(&dev->rx_dropped); | 1656 | atomic_long_inc(&dev->rx_dropped); |
1659 | kfree_skb(skb); | 1657 | kfree_skb(skb); |
1660 | return NET_RX_DROP; | 1658 | return NET_RX_DROP; |
1661 | } | 1659 | } |
1662 | skb->skb_iif = 0; | 1660 | skb_scrub_packet(skb); |
1663 | skb_dst_drop(skb); | ||
1664 | skb->tstamp.tv64 = 0; | ||
1665 | skb->pkt_type = PACKET_HOST; | ||
1666 | skb->protocol = eth_type_trans(skb, dev); | 1661 | skb->protocol = eth_type_trans(skb, dev); |
1667 | skb->mark = 0; | ||
1668 | secpath_reset(skb); | ||
1669 | nf_reset(skb); | ||
1670 | nf_reset_trace(skb); | ||
1671 | return netif_rx(skb); | 1662 | return netif_rx(skb); |
1672 | } | 1663 | } |
1673 | EXPORT_SYMBOL_GPL(dev_forward_skb); | 1664 | EXPORT_SYMBOL_GPL(dev_forward_skb); |
diff --git a/net/core/skbuff.c b/net/core/skbuff.c index 9f73eca29fbe..b1fcb8727e56 100644 --- a/net/core/skbuff.c +++ b/net/core/skbuff.c | |||
@@ -3492,3 +3492,26 @@ bool skb_try_coalesce(struct sk_buff *to, struct sk_buff *from, | |||
3492 | return true; | 3492 | return true; |
3493 | } | 3493 | } |
3494 | EXPORT_SYMBOL(skb_try_coalesce); | 3494 | EXPORT_SYMBOL(skb_try_coalesce); |
3495 | |||
3496 | /** | ||
3497 | * skb_scrub_packet - scrub an skb before sending it to another netns | ||
3498 | * | ||
3499 | * @skb: buffer to clean | ||
3500 | * | ||
3501 | * skb_scrub_packet can be used to clean an skb before injecting it in | ||
3502 | * another namespace. We have to clear all information in the skb that | ||
3503 | * could impact namespace isolation. | ||
3504 | */ | ||
3505 | void skb_scrub_packet(struct sk_buff *skb) | ||
3506 | { | ||
3507 | skb_orphan(skb); | ||
3508 | skb->tstamp.tv64 = 0; | ||
3509 | skb->pkt_type = PACKET_HOST; | ||
3510 | skb->skb_iif = 0; | ||
3511 | skb_dst_drop(skb); | ||
3512 | skb->mark = 0; | ||
3513 | secpath_reset(skb); | ||
3514 | nf_reset(skb); | ||
3515 | nf_reset_trace(skb); | ||
3516 | } | ||
3517 | EXPORT_SYMBOL_GPL(skb_scrub_packet); | ||