Merge tag 'gpio-v3.13-3' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw...
[linux-2.6.git] / include / linux / netfilter_bridge.h
blob8ab1c278b66da77229647e08ef8e0d948d4e6122
1 #ifndef __LINUX_BRIDGE_NETFILTER_H
2 #define __LINUX_BRIDGE_NETFILTER_H
4 #include <uapi/linux/netfilter_bridge.h>
7 enum nf_br_hook_priorities {
8 NF_BR_PRI_FIRST = INT_MIN,
9 NF_BR_PRI_NAT_DST_BRIDGED = -300,
10 NF_BR_PRI_FILTER_BRIDGED = -200,
11 NF_BR_PRI_BRNF = 0,
12 NF_BR_PRI_NAT_DST_OTHER = 100,
13 NF_BR_PRI_FILTER_OTHER = 200,
14 NF_BR_PRI_NAT_SRC = 300,
15 NF_BR_PRI_LAST = INT_MAX,
18 #ifdef CONFIG_BRIDGE_NETFILTER
20 #define BRNF_PKT_TYPE 0x01
21 #define BRNF_BRIDGED_DNAT 0x02
22 #define BRNF_BRIDGED 0x04
23 #define BRNF_NF_BRIDGE_PREROUTING 0x08
24 #define BRNF_8021Q 0x10
25 #define BRNF_PPPoE 0x20
27 /* Only used in br_forward.c */
28 int nf_bridge_copy_header(struct sk_buff *skb);
29 static inline int nf_bridge_maybe_copy_header(struct sk_buff *skb)
31 if (skb->nf_bridge &&
32 skb->nf_bridge->mask & (BRNF_BRIDGED | BRNF_BRIDGED_DNAT))
33 return nf_bridge_copy_header(skb);
34 return 0;
37 static inline unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb)
39 switch (skb->protocol) {
40 case __cpu_to_be16(ETH_P_8021Q):
41 return VLAN_HLEN;
42 case __cpu_to_be16(ETH_P_PPP_SES):
43 return PPPOE_SES_HLEN;
44 default:
45 return 0;
49 static inline unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
51 if (unlikely(skb->nf_bridge->mask & BRNF_PPPoE))
52 return PPPOE_SES_HLEN;
53 return 0;
56 int br_handle_frame_finish(struct sk_buff *skb);
57 /* Only used in br_device.c */
58 static inline int br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)
60 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
62 skb_pull(skb, ETH_HLEN);
63 nf_bridge->mask ^= BRNF_BRIDGED_DNAT;
64 skb_copy_to_linear_data_offset(skb, -(ETH_HLEN-ETH_ALEN),
65 skb->nf_bridge->data, ETH_HLEN-ETH_ALEN);
66 skb->dev = nf_bridge->physindev;
67 return br_handle_frame_finish(skb);
70 /* This is called by the IP fragmenting code and it ensures there is
71 * enough room for the encapsulating header (if there is one). */
72 static inline unsigned int nf_bridge_pad(const struct sk_buff *skb)
74 if (skb->nf_bridge)
75 return nf_bridge_encap_header_len(skb);
76 return 0;
79 struct bridge_skb_cb {
80 union {
81 __be32 ipv4;
82 } daddr;
85 static inline void br_drop_fake_rtable(struct sk_buff *skb)
87 struct dst_entry *dst = skb_dst(skb);
89 if (dst && (dst->flags & DST_FAKE_RTABLE))
90 skb_dst_drop(skb);
93 #else
94 #define nf_bridge_maybe_copy_header(skb) (0)
95 #define nf_bridge_pad(skb) (0)
96 #define br_drop_fake_rtable(skb) do { } while (0)
97 #endif /* CONFIG_BRIDGE_NETFILTER */
99 #endif