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