06b05f8af96555f9cd4220165c685f6a2b97319a
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.2 / 644-bridge_optimize_netfilter_hooks.patch
1 --- a/net/bridge/br_netfilter.c
2 +++ b/net/bridge/br_netfilter.c
3 @@ -62,6 +62,11 @@ static int brnf_filter_pppoe_tagged __re
4 #define brnf_filter_pppoe_tagged 0
5 #endif
6
7 +bool br_netfilter_run_hooks(void)
8 +{
9 + return brnf_call_iptables | brnf_call_ip6tables | brnf_call_arptables;
10 +}
11 +
12 static inline __be16 vlan_proto(const struct sk_buff *skb)
13 {
14 if (vlan_tx_tag_present(skb))
15 --- a/net/bridge/br_private.h
16 +++ b/net/bridge/br_private.h
17 @@ -491,12 +491,25 @@ static inline bool br_multicast_is_route
18 extern int br_netfilter_init(void);
19 extern void br_netfilter_fini(void);
20 extern void br_netfilter_rtable_init(struct net_bridge *);
21 +extern bool br_netfilter_run_hooks(void);
22 #else
23 #define br_netfilter_init() (0)
24 #define br_netfilter_fini() do { } while(0)
25 #define br_netfilter_rtable_init(x)
26 +#define br_netfilter_run_hooks() false
27 #endif
28
29 +static inline int
30 +BR_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
31 + struct net_device *in, struct net_device *out,
32 + int (*okfn)(struct sk_buff *))
33 +{
34 + if (!br_netfilter_run_hooks())
35 + return okfn(skb);
36 +
37 + return NF_HOOK(pf, hook, skb, in, out, okfn);
38 +}
39 +
40 /* br_stp.c */
41 extern void br_log_state(const struct net_bridge_port *p);
42 extern struct net_bridge_port *br_get_port(struct net_bridge *br,
43 --- a/net/bridge/br_input.c
44 +++ b/net/bridge/br_input.c
45 @@ -40,7 +40,7 @@ static int br_pass_frame_up(struct sk_bu
46 indev = skb->dev;
47 skb->dev = brdev;
48
49 - return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
50 + return BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
51 netif_receive_skb);
52 }
53
54 @@ -199,7 +199,7 @@ rx_handler_result_t br_handle_frame(stru
55 }
56
57 /* Deliver packet to local host only */
58 - if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
59 + if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
60 NULL, br_handle_local_finish)) {
61 return RX_HANDLER_CONSUMED; /* consumed by filter */
62 } else {
63 @@ -224,7 +224,7 @@ forward:
64 if (!compare_ether_addr(p->br->dev->dev_addr, dest))
65 skb->pkt_type = PACKET_HOST;
66
67 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
68 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
69 br_handle_frame_finish);
70 break;
71 default:
72 --- a/net/bridge/br_forward.c
73 +++ b/net/bridge/br_forward.c
74 @@ -55,7 +55,7 @@ int br_dev_queue_push_xmit(struct sk_buf
75
76 int br_forward_finish(struct sk_buff *skb)
77 {
78 - return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
79 + return BR_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
80 br_dev_queue_push_xmit);
81
82 }
83 @@ -74,7 +74,7 @@ static void __br_deliver(const struct ne
84 return;
85 }
86
87 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
88 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
89 br_forward_finish);
90 }
91
92 @@ -91,7 +91,7 @@ static void __br_forward(const struct ne
93 skb->dev = to->dev;
94 skb_forward_csum(skb);
95
96 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
97 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
98 br_forward_finish);
99 }
100
101 --- a/net/bridge/br_multicast.c
102 +++ b/net/bridge/br_multicast.c
103 @@ -824,7 +824,7 @@ static void __br_multicast_send_query(st
104 if (port) {
105 __skb_push(skb, sizeof(struct ethhdr));
106 skb->dev = port->dev;
107 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
108 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
109 dev_queue_xmit);
110 } else
111 netif_rx(skb);
112 --- a/net/bridge/br_stp_bpdu.c
113 +++ b/net/bridge/br_stp_bpdu.c
114 @@ -52,7 +52,7 @@ static void br_send_bpdu(struct net_brid
115
116 skb_reset_mac_header(skb);
117
118 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
119 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
120 dev_queue_xmit);
121 }
122