netfilter_ingress.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #ifndef _NETFILTER_INGRESS_H_
  2. #define _NETFILTER_INGRESS_H_
  3. #include <linux/netfilter.h>
  4. #include <linux/netdevice.h>
  5. #ifdef CONFIG_NETFILTER_INGRESS
  6. static inline bool nf_hook_ingress_active(const struct sk_buff *skb)
  7. {
  8. #ifdef HAVE_JUMP_LABEL
  9. if (!static_key_false(&nf_hooks_needed[NFPROTO_NETDEV][NF_NETDEV_INGRESS]))
  10. return false;
  11. #endif
  12. return !list_empty(&skb->dev->nf_hooks_ingress);
  13. }
  14. static inline int nf_hook_ingress(struct sk_buff *skb)
  15. {
  16. struct nf_hook_state state;
  17. nf_hook_state_init(&state, &skb->dev->nf_hooks_ingress,
  18. NF_NETDEV_INGRESS, INT_MIN, NFPROTO_NETDEV,
  19. skb->dev, NULL, NULL, dev_net(skb->dev), NULL);
  20. return nf_hook_slow(skb, &state);
  21. }
  22. static inline void nf_hook_ingress_init(struct net_device *dev)
  23. {
  24. INIT_LIST_HEAD(&dev->nf_hooks_ingress);
  25. }
  26. #else /* CONFIG_NETFILTER_INGRESS */
  27. static inline int nf_hook_ingress_active(struct sk_buff *skb)
  28. {
  29. return 0;
  30. }
  31. static inline int nf_hook_ingress(struct sk_buff *skb)
  32. {
  33. return 0;
  34. }
  35. static inline void nf_hook_ingress_init(struct net_device *dev) {}
  36. #endif /* CONFIG_NETFILTER_INGRESS */
  37. #endif /* _NETFILTER_INGRESS_H_ */