Commit | Line | Data |
---|---|---|
b2441318 | 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4 LT |
2 | #ifndef __LINUX_BRIDGE_NETFILTER_H |
3 | #define __LINUX_BRIDGE_NETFILTER_H | |
4 | ||
607ca46e | 5 | #include <uapi/linux/netfilter_bridge.h> |
c737b7c4 | 6 | #include <linux/skbuff.h> |
1da177e4 | 7 | |
46705b07 JS |
8 | struct nf_bridge_frag_data { |
9 | char mac[ETH_HLEN]; | |
10 | bool vlan_present; | |
11 | u16 vlan_tci; | |
12 | __be16 vlan_proto; | |
13 | }; | |
14 | ||
34666d46 | 15 | #if IS_ENABLED(CONFIG_BRIDGE_NETFILTER) |
1da177e4 | 16 | |
0c4b51f0 | 17 | int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb); |
ea2d9b41 | 18 | |
a881e963 PHP |
19 | static inline void br_drop_fake_rtable(struct sk_buff *skb) |
20 | { | |
21 | struct dst_entry *dst = skb_dst(skb); | |
22 | ||
23 | if (dst && (dst->flags & DST_FAKE_RTABLE)) | |
24 | skb_dst_drop(skb); | |
25 | } | |
26 | ||
c4b0e771 FW |
27 | static inline struct nf_bridge_info * |
28 | nf_bridge_info_get(const struct sk_buff *skb) | |
29 | { | |
de8bda1d | 30 | return skb_ext_find(skb, SKB_EXT_BRIDGE_NF); |
c4b0e771 FW |
31 | } |
32 | ||
33 | static inline bool nf_bridge_info_exists(const struct sk_buff *skb) | |
34 | { | |
de8bda1d | 35 | return skb_ext_exist(skb, SKB_EXT_BRIDGE_NF); |
c4b0e771 FW |
36 | } |
37 | ||
c737b7c4 FW |
38 | static inline int nf_bridge_get_physinif(const struct sk_buff *skb) |
39 | { | |
c4b0e771 | 40 | const struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); |
547c4b54 | 41 | |
c4b0e771 | 42 | if (!nf_bridge) |
547c4b54 FW |
43 | return 0; |
44 | ||
547c4b54 | 45 | return nf_bridge->physindev ? nf_bridge->physindev->ifindex : 0; |
c737b7c4 FW |
46 | } |
47 | ||
48 | static inline int nf_bridge_get_physoutif(const struct sk_buff *skb) | |
49 | { | |
c4b0e771 | 50 | const struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); |
547c4b54 | 51 | |
c4b0e771 | 52 | if (!nf_bridge) |
547c4b54 FW |
53 | return 0; |
54 | ||
547c4b54 | 55 | return nf_bridge->physoutdev ? nf_bridge->physoutdev->ifindex : 0; |
c737b7c4 FW |
56 | } |
57 | ||
58 | static inline struct net_device * | |
59 | nf_bridge_get_physindev(const struct sk_buff *skb) | |
60 | { | |
c4b0e771 FW |
61 | const struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); |
62 | ||
63 | return nf_bridge ? nf_bridge->physindev : NULL; | |
c737b7c4 FW |
64 | } |
65 | ||
66 | static inline struct net_device * | |
67 | nf_bridge_get_physoutdev(const struct sk_buff *skb) | |
68 | { | |
c4b0e771 FW |
69 | const struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); |
70 | ||
71 | return nf_bridge ? nf_bridge->physoutdev : NULL; | |
c737b7c4 | 72 | } |
72b1e5e4 FW |
73 | |
74 | static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb) | |
75 | { | |
c4b0e771 FW |
76 | const struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb); |
77 | ||
78 | return nf_bridge && nf_bridge->in_prerouting; | |
72b1e5e4 | 79 | } |
07317621 | 80 | #else |
a881e963 | 81 | #define br_drop_fake_rtable(skb) do { } while (0) |
72b1e5e4 FW |
82 | static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb) |
83 | { | |
84 | return false; | |
85 | } | |
1da177e4 LT |
86 | #endif /* CONFIG_BRIDGE_NETFILTER */ |
87 | ||
1da177e4 | 88 | #endif |