diff options
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/dev.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/net/core/dev.c b/net/core/dev.c index e65af6041415..7775e8b48deb 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
@@ -105,6 +105,7 @@ | |||
105 | #include <net/dst.h> | 105 | #include <net/dst.h> |
106 | #include <net/pkt_sched.h> | 106 | #include <net/pkt_sched.h> |
107 | #include <net/checksum.h> | 107 | #include <net/checksum.h> |
108 | #include <net/xfrm.h> | ||
108 | #include <linux/highmem.h> | 109 | #include <linux/highmem.h> |
109 | #include <linux/init.h> | 110 | #include <linux/init.h> |
110 | #include <linux/kmod.h> | 111 | #include <linux/kmod.h> |
@@ -1419,6 +1420,45 @@ static inline void net_timestamp(struct sk_buff *skb) | |||
1419 | skb->tstamp.tv64 = 0; | 1420 | skb->tstamp.tv64 = 0; |
1420 | } | 1421 | } |
1421 | 1422 | ||
1423 | /** | ||
1424 | * dev_forward_skb - loopback an skb to another netif | ||
1425 | * | ||
1426 | * @dev: destination network device | ||
1427 | * @skb: buffer to forward | ||
1428 | * | ||
1429 | * return values: | ||
1430 | * NET_RX_SUCCESS (no congestion) | ||
1431 | * NET_RX_DROP (packet was dropped) | ||
1432 | * | ||
1433 | * dev_forward_skb can be used for injecting an skb from the | ||
1434 | * start_xmit function of one device into the receive queue | ||
1435 | * of another device. | ||
1436 | * | ||
1437 | * The receiving device may be in another namespace, so | ||
1438 | * we have to clear all information in the skb that could | ||
1439 | * impact namespace isolation. | ||
1440 | */ | ||
1441 | int dev_forward_skb(struct net_device *dev, struct sk_buff *skb) | ||
1442 | { | ||
1443 | skb_orphan(skb); | ||
1444 | |||
1445 | if (!(dev->flags & IFF_UP)) | ||
1446 | return NET_RX_DROP; | ||
1447 | |||
1448 | if (skb->len > (dev->mtu + dev->hard_header_len)) | ||
1449 | return NET_RX_DROP; | ||
1450 | |||
1451 | skb_dst_drop(skb); | ||
1452 | skb->tstamp.tv64 = 0; | ||
1453 | skb->pkt_type = PACKET_HOST; | ||
1454 | skb->protocol = eth_type_trans(skb, dev); | ||
1455 | skb->mark = 0; | ||
1456 | secpath_reset(skb); | ||
1457 | nf_reset(skb); | ||
1458 | return netif_rx(skb); | ||
1459 | } | ||
1460 | EXPORT_SYMBOL_GPL(dev_forward_skb); | ||
1461 | |||
1422 | /* | 1462 | /* |
1423 | * Support routine. Sends outgoing frames to any network | 1463 | * Support routine. Sends outgoing frames to any network |
1424 | * taps currently in use. | 1464 | * taps currently in use. |