]>
Commit | Line | Data |
---|---|---|
502061f8 PNA |
1 | /* |
2 | * Copyright (c) 2015 Pablo Neira Ayuso <[email protected]> | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of the GNU General Public License version 2 as published by | |
6 | * the Free Software Foundation. | |
7 | */ | |
8 | ||
9 | #include <linux/kernel.h> | |
10 | #include <linux/init.h> | |
11 | #include <linux/module.h> | |
12 | #include <linux/netlink.h> | |
13 | #include <linux/netfilter.h> | |
14 | #include <linux/netfilter/nf_tables.h> | |
15 | #include <net/netfilter/nf_tables.h> | |
16 | ||
3bf32761 FW |
17 | static void nf_do_netdev_egress(struct sk_buff *skb, struct net_device *dev) |
18 | { | |
19 | if (skb_mac_header_was_set(skb)) | |
20 | skb_push(skb, skb->mac_len); | |
21 | ||
22 | skb->dev = dev; | |
23 | dev_queue_xmit(skb); | |
24 | } | |
25 | ||
26 | void nf_fwd_netdev_egress(const struct nft_pktinfo *pkt, int oif) | |
27 | { | |
28 | struct net_device *dev; | |
29 | ||
30 | dev = dev_get_by_index_rcu(nft_net(pkt), oif); | |
31 | if (!dev) { | |
32 | kfree_skb(pkt->skb); | |
33 | return; | |
34 | } | |
35 | ||
36 | nf_do_netdev_egress(pkt->skb, dev); | |
37 | } | |
38 | EXPORT_SYMBOL_GPL(nf_fwd_netdev_egress); | |
39 | ||
502061f8 PNA |
40 | void nf_dup_netdev_egress(const struct nft_pktinfo *pkt, int oif) |
41 | { | |
42 | struct net_device *dev; | |
43 | struct sk_buff *skb; | |
44 | ||
0e5a1c7e | 45 | dev = dev_get_by_index_rcu(nft_net(pkt), oif); |
502061f8 PNA |
46 | if (dev == NULL) |
47 | return; | |
48 | ||
49 | skb = skb_clone(pkt->skb, GFP_ATOMIC); | |
3bf32761 FW |
50 | if (skb) |
51 | nf_do_netdev_egress(skb, dev); | |
502061f8 PNA |
52 | } |
53 | EXPORT_SYMBOL_GPL(nf_dup_netdev_egress); | |
54 | ||
55 | MODULE_LICENSE("GPL"); | |
56 | MODULE_AUTHOR("Pablo Neira Ayuso <[email protected]>"); |