netfilter_bridge.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #ifndef __LINUX_BRIDGE_NETFILTER_H
  2. #define __LINUX_BRIDGE_NETFILTER_H
  3. #include <uapi/linux/netfilter_bridge.h>
  4. #include <linux/skbuff.h>
  5. enum nf_br_hook_priorities {
  6. NF_BR_PRI_FIRST = INT_MIN,
  7. NF_BR_PRI_NAT_DST_BRIDGED = -300,
  8. NF_BR_PRI_FILTER_BRIDGED = -200,
  9. NF_BR_PRI_BRNF = 0,
  10. NF_BR_PRI_NAT_DST_OTHER = 100,
  11. NF_BR_PRI_FILTER_OTHER = 200,
  12. NF_BR_PRI_NAT_SRC = 300,
  13. NF_BR_PRI_LAST = INT_MAX,
  14. };
  15. #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
  16. int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
  17. static inline void br_drop_fake_rtable(struct sk_buff *skb)
  18. {
  19. struct dst_entry *dst = skb_dst(skb);
  20. if (dst && (dst->flags & DST_FAKE_RTABLE))
  21. skb_dst_drop(skb);
  22. }
  23. static inline int nf_bridge_get_physinif(const struct sk_buff *skb)
  24. {
  25. struct nf_bridge_info *nf_bridge;
  26. if (skb->nf_bridge == NULL)
  27. return 0;
  28. nf_bridge = skb->nf_bridge;
  29. return nf_bridge->physindev ? nf_bridge->physindev->ifindex : 0;
  30. }
  31. static inline int nf_bridge_get_physoutif(const struct sk_buff *skb)
  32. {
  33. struct nf_bridge_info *nf_bridge;
  34. if (skb->nf_bridge == NULL)
  35. return 0;
  36. nf_bridge = skb->nf_bridge;
  37. return nf_bridge->physoutdev ? nf_bridge->physoutdev->ifindex : 0;
  38. }
  39. static inline struct net_device *
  40. nf_bridge_get_physindev(const struct sk_buff *skb)
  41. {
  42. return skb->nf_bridge ? skb->nf_bridge->physindev : NULL;
  43. }
  44. static inline struct net_device *
  45. nf_bridge_get_physoutdev(const struct sk_buff *skb)
  46. {
  47. return skb->nf_bridge ? skb->nf_bridge->physoutdev : NULL;
  48. }
  49. static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb)
  50. {
  51. return skb->nf_bridge && skb->nf_bridge->in_prerouting;
  52. }
  53. #else
  54. #define br_drop_fake_rtable(skb) do { } while (0)
  55. static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb)
  56. {
  57. return false;
  58. }
  59. #endif /* CONFIG_BRIDGE_NETFILTER */
  60. #endif