1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __LINUX_BRIDGE_NETFILTER_H
3 #define __LINUX_BRIDGE_NETFILTER_H
5 #include <uapi/linux/netfilter_bridge.h>
6 #include <linux/skbuff.h>
8 enum nf_br_hook_priorities
{
9 NF_BR_PRI_FIRST
= INT_MIN
,
10 NF_BR_PRI_NAT_DST_BRIDGED
= -300,
11 NF_BR_PRI_FILTER_BRIDGED
= -200,
13 NF_BR_PRI_NAT_DST_OTHER
= 100,
14 NF_BR_PRI_FILTER_OTHER
= 200,
15 NF_BR_PRI_NAT_SRC
= 300,
16 NF_BR_PRI_LAST
= INT_MAX
,
19 #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
21 int br_handle_frame_finish(struct net
*net
, struct sock
*sk
, struct sk_buff
*skb
);
23 static inline void br_drop_fake_rtable(struct sk_buff
*skb
)
25 struct dst_entry
*dst
= skb_dst(skb
);
27 if (dst
&& (dst
->flags
& DST_FAKE_RTABLE
))
31 static inline int nf_bridge_get_physinif(const struct sk_buff
*skb
)
33 struct nf_bridge_info
*nf_bridge
;
35 if (skb
->nf_bridge
== NULL
)
38 nf_bridge
= skb
->nf_bridge
;
39 return nf_bridge
->physindev
? nf_bridge
->physindev
->ifindex
: 0;
42 static inline int nf_bridge_get_physoutif(const struct sk_buff
*skb
)
44 struct nf_bridge_info
*nf_bridge
;
46 if (skb
->nf_bridge
== NULL
)
49 nf_bridge
= skb
->nf_bridge
;
50 return nf_bridge
->physoutdev
? nf_bridge
->physoutdev
->ifindex
: 0;
53 static inline struct net_device
*
54 nf_bridge_get_physindev(const struct sk_buff
*skb
)
56 return skb
->nf_bridge
? skb
->nf_bridge
->physindev
: NULL
;
59 static inline struct net_device
*
60 nf_bridge_get_physoutdev(const struct sk_buff
*skb
)
62 return skb
->nf_bridge
? skb
->nf_bridge
->physoutdev
: NULL
;
65 static inline bool nf_bridge_in_prerouting(const struct sk_buff
*skb
)
67 return skb
->nf_bridge
&& skb
->nf_bridge
->in_prerouting
;
70 #define br_drop_fake_rtable(skb) do { } while (0)
71 static inline bool nf_bridge_in_prerouting(const struct sk_buff
*skb
)
75 #endif /* CONFIG_BRIDGE_NETFILTER */