Pablo Neira | e687ad6 | 2015-05-13 18:19:38 +0200 | [diff] [blame] | 1 | #ifndef _NETFILTER_INGRESS_H_ |
| 2 | #define _NETFILTER_INGRESS_H_ |
| 3 | |
| 4 | #include <linux/netfilter.h> |
| 5 | #include <linux/netdevice.h> |
| 6 | |
| 7 | #ifdef CONFIG_NETFILTER_INGRESS |
Florian Westphal | 61b590b | 2015-10-23 12:43:18 +0200 | [diff] [blame] | 8 | static inline bool nf_hook_ingress_active(const struct sk_buff *skb) |
Pablo Neira | e687ad6 | 2015-05-13 18:19:38 +0200 | [diff] [blame] | 9 | { |
Florian Westphal | 61b590b | 2015-10-23 12:43:18 +0200 | [diff] [blame] | 10 | #ifdef HAVE_JUMP_LABEL |
| 11 | if (!static_key_false(&nf_hooks_needed[NFPROTO_NETDEV][NF_NETDEV_INGRESS])) |
| 12 | return false; |
| 13 | #endif |
| 14 | return !list_empty(&skb->dev->nf_hooks_ingress); |
Pablo Neira | e687ad6 | 2015-05-13 18:19:38 +0200 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | static inline int nf_hook_ingress(struct sk_buff *skb) |
| 18 | { |
| 19 | struct nf_hook_state state; |
| 20 | |
| 21 | nf_hook_state_init(&state, &skb->dev->nf_hooks_ingress, |
Pablo Neira Ayuso | b486598 | 2015-11-06 18:35:57 +0100 | [diff] [blame] | 22 | NF_NETDEV_INGRESS, INT_MIN, NFPROTO_NETDEV, |
| 23 | skb->dev, NULL, NULL, dev_net(skb->dev), NULL); |
Pablo Neira | e687ad6 | 2015-05-13 18:19:38 +0200 | [diff] [blame] | 24 | return nf_hook_slow(skb, &state); |
| 25 | } |
| 26 | |
| 27 | static inline void nf_hook_ingress_init(struct net_device *dev) |
| 28 | { |
| 29 | INIT_LIST_HEAD(&dev->nf_hooks_ingress); |
| 30 | } |
| 31 | #else /* CONFIG_NETFILTER_INGRESS */ |
| 32 | static inline int nf_hook_ingress_active(struct sk_buff *skb) |
| 33 | { |
| 34 | return 0; |
| 35 | } |
| 36 | |
| 37 | static inline int nf_hook_ingress(struct sk_buff *skb) |
| 38 | { |
| 39 | return 0; |
| 40 | } |
| 41 | |
| 42 | static inline void nf_hook_ingress_init(struct net_device *dev) {} |
| 43 | #endif /* CONFIG_NETFILTER_INGRESS */ |
| 44 | #endif /* _NETFILTER_INGRESS_H_ */ |