Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef __LINUX_BRIDGE_NETFILTER_H |
| 2 | #define __LINUX_BRIDGE_NETFILTER_H |
| 3 | |
David Howells | 607ca46 | 2012-10-13 10:46:48 +0100 | [diff] [blame] | 4 | #include <uapi/linux/netfilter_bridge.h> |
Florian Westphal | c737b7c | 2015-04-02 14:31:41 +0200 | [diff] [blame] | 5 | #include <linux/skbuff.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | |
| 7 | enum nf_br_hook_priorities { |
| 8 | NF_BR_PRI_FIRST = INT_MIN, |
| 9 | NF_BR_PRI_NAT_DST_BRIDGED = -300, |
| 10 | NF_BR_PRI_FILTER_BRIDGED = -200, |
| 11 | NF_BR_PRI_BRNF = 0, |
| 12 | NF_BR_PRI_NAT_DST_OTHER = 100, |
| 13 | NF_BR_PRI_FILTER_OTHER = 200, |
| 14 | NF_BR_PRI_NAT_SRC = 300, |
| 15 | NF_BR_PRI_LAST = INT_MAX, |
| 16 | }; |
| 17 | |
Pablo Neira Ayuso | 34666d4 | 2014-09-18 11:29:03 +0200 | [diff] [blame] | 18 | #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | |
Eric W. Biederman | 0c4b51f | 2015-09-15 20:04:18 -0500 | [diff] [blame^] | 20 | int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb); |
Bart De Schuymer | ea2d9b4 | 2010-04-15 12:14:51 +0200 | [diff] [blame] | 21 | |
Peter Huang (Peng) | a881e96 | 2012-04-19 20:12:51 +0000 | [diff] [blame] | 22 | static inline void br_drop_fake_rtable(struct sk_buff *skb) |
| 23 | { |
| 24 | struct dst_entry *dst = skb_dst(skb); |
| 25 | |
| 26 | if (dst && (dst->flags & DST_FAKE_RTABLE)) |
| 27 | skb_dst_drop(skb); |
| 28 | } |
| 29 | |
Florian Westphal | c737b7c | 2015-04-02 14:31:41 +0200 | [diff] [blame] | 30 | static inline int nf_bridge_get_physinif(const struct sk_buff *skb) |
| 31 | { |
Florian Westphal | 547c4b5 | 2015-04-20 12:35:47 +0200 | [diff] [blame] | 32 | struct nf_bridge_info *nf_bridge; |
| 33 | |
| 34 | if (skb->nf_bridge == NULL) |
| 35 | return 0; |
| 36 | |
| 37 | nf_bridge = skb->nf_bridge; |
| 38 | return nf_bridge->physindev ? nf_bridge->physindev->ifindex : 0; |
Florian Westphal | c737b7c | 2015-04-02 14:31:41 +0200 | [diff] [blame] | 39 | } |
| 40 | |
| 41 | static inline int nf_bridge_get_physoutif(const struct sk_buff *skb) |
| 42 | { |
Florian Westphal | 547c4b5 | 2015-04-20 12:35:47 +0200 | [diff] [blame] | 43 | struct nf_bridge_info *nf_bridge; |
| 44 | |
| 45 | if (skb->nf_bridge == NULL) |
| 46 | return 0; |
| 47 | |
| 48 | nf_bridge = skb->nf_bridge; |
| 49 | return nf_bridge->physoutdev ? nf_bridge->physoutdev->ifindex : 0; |
Florian Westphal | c737b7c | 2015-04-02 14:31:41 +0200 | [diff] [blame] | 50 | } |
| 51 | |
| 52 | static inline struct net_device * |
| 53 | nf_bridge_get_physindev(const struct sk_buff *skb) |
| 54 | { |
| 55 | return skb->nf_bridge ? skb->nf_bridge->physindev : NULL; |
| 56 | } |
| 57 | |
| 58 | static inline struct net_device * |
| 59 | nf_bridge_get_physoutdev(const struct sk_buff *skb) |
| 60 | { |
| 61 | return skb->nf_bridge ? skb->nf_bridge->physoutdev : NULL; |
| 62 | } |
Florian Westphal | 72b1e5e | 2015-07-23 16:21:30 +0200 | [diff] [blame] | 63 | |
| 64 | static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb) |
| 65 | { |
| 66 | return skb->nf_bridge && skb->nf_bridge->in_prerouting; |
| 67 | } |
Stephen Hemminger | 07317621 | 2006-08-29 17:48:17 -0700 | [diff] [blame] | 68 | #else |
Peter Huang (Peng) | a881e96 | 2012-04-19 20:12:51 +0000 | [diff] [blame] | 69 | #define br_drop_fake_rtable(skb) do { } while (0) |
Florian Westphal | 72b1e5e | 2015-07-23 16:21:30 +0200 | [diff] [blame] | 70 | static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb) |
| 71 | { |
| 72 | return false; |
| 73 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | #endif /* CONFIG_BRIDGE_NETFILTER */ |
| 75 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | #endif |