]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/netfilter_bridge.h
net: rtnetlink: validate IFLA_MTU attribute in rtnl_create_link()
[mirror_ubuntu-bionic-kernel.git] / include / linux / netfilter_bridge.h
CommitLineData
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
LT
7
8enum 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,
12 NF_BR_PRI_BRNF = 0,
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,
17};
18
34666d46 19#if IS_ENABLED(CONFIG_BRIDGE_NETFILTER)
1da177e4 20
0c4b51f0 21int br_handle_frame_finish(struct net *net, struct sock *sk, struct sk_buff *skb);
ea2d9b41 22
a881e963
PHP
23static inline void br_drop_fake_rtable(struct sk_buff *skb)
24{
25 struct dst_entry *dst = skb_dst(skb);
26
27 if (dst && (dst->flags & DST_FAKE_RTABLE))
28 skb_dst_drop(skb);
29}
30
c737b7c4
FW
31static inline int nf_bridge_get_physinif(const struct sk_buff *skb)
32{
547c4b54
FW
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->physindev ? nf_bridge->physindev->ifindex : 0;
c737b7c4
FW
40}
41
42static inline int nf_bridge_get_physoutif(const struct sk_buff *skb)
43{
547c4b54
FW
44 struct nf_bridge_info *nf_bridge;
45
46 if (skb->nf_bridge == NULL)
47 return 0;
48
49 nf_bridge = skb->nf_bridge;
50 return nf_bridge->physoutdev ? nf_bridge->physoutdev->ifindex : 0;
c737b7c4
FW
51}
52
53static inline struct net_device *
54nf_bridge_get_physindev(const struct sk_buff *skb)
55{
56 return skb->nf_bridge ? skb->nf_bridge->physindev : NULL;
57}
58
59static inline struct net_device *
60nf_bridge_get_physoutdev(const struct sk_buff *skb)
61{
62 return skb->nf_bridge ? skb->nf_bridge->physoutdev : NULL;
63}
72b1e5e4
FW
64
65static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb)
66{
67 return skb->nf_bridge && skb->nf_bridge->in_prerouting;
68}
07317621 69#else
a881e963 70#define br_drop_fake_rtable(skb) do { } while (0)
72b1e5e4
FW
71static inline bool nf_bridge_in_prerouting(const struct sk_buff *skb)
72{
73 return false;
74}
1da177e4
LT
75#endif /* CONFIG_BRIDGE_NETFILTER */
76
1da177e4 77#endif