kernel/3.1[02]: move MTD root device setup code to mtdcore
[openwrt/svn-archive/archive.git] / target / linux / generic / patches-3.10 / 644-bridge_optimize_netfilter_hooks.patch
1 --- a/net/bridge/br_forward.c
2 +++ b/net/bridge/br_forward.c
3 @@ -57,7 +57,7 @@ int br_dev_queue_push_xmit(struct sk_buf
4
5 int br_forward_finish(struct sk_buff *skb)
6 {
7 - return NF_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
8 + return BR_HOOK(NFPROTO_BRIDGE, NF_BR_POST_ROUTING, skb, NULL, skb->dev,
9 br_dev_queue_push_xmit);
10
11 }
12 @@ -80,7 +80,7 @@ static void __br_deliver(const struct ne
13 return;
14 }
15
16 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
17 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
18 br_forward_finish);
19 }
20
21 @@ -101,7 +101,7 @@ static void __br_forward(const struct ne
22 skb->dev = to->dev;
23 skb_forward_csum(skb);
24
25 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
26 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_FORWARD, skb, indev, skb->dev,
27 br_forward_finish);
28 }
29
30 --- a/net/bridge/br_input.c
31 +++ b/net/bridge/br_input.c
32 @@ -52,7 +52,7 @@ static int br_pass_frame_up(struct sk_bu
33 indev = skb->dev;
34 skb->dev = brdev;
35
36 - return NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
37 + return BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, indev, NULL,
38 netif_receive_skb);
39 }
40
41 @@ -209,7 +209,7 @@ rx_handler_result_t br_handle_frame(stru
42 }
43
44 /* Deliver packet to local host only */
45 - if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
46 + if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_IN, skb, skb->dev,
47 NULL, br_handle_local_finish)) {
48 return RX_HANDLER_CONSUMED; /* consumed by filter */
49 } else {
50 @@ -224,7 +224,7 @@ forward:
51 if (ether_addr_equal(p->br->dev->dev_addr, dest))
52 skb->pkt_type = PACKET_HOST;
53
54 - if (NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
55 + if (BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
56 br_handle_local_finish))
57 break;
58
59 @@ -246,7 +246,7 @@ forward:
60 if (ether_addr_equal(p->br->dev->dev_addr, dest))
61 skb->pkt_type = PACKET_HOST;
62
63 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
64 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, skb, skb->dev, NULL,
65 br_handle_frame_finish);
66 break;
67 default:
68 --- a/net/bridge/br_multicast.c
69 +++ b/net/bridge/br_multicast.c
70 @@ -783,7 +783,7 @@ static void __br_multicast_send_query(st
71 if (port) {
72 __skb_push(skb, sizeof(struct ethhdr));
73 skb->dev = port->dev;
74 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
75 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
76 dev_queue_xmit);
77 } else
78 netif_rx(skb);
79 --- a/net/bridge/br_netfilter.c
80 +++ b/net/bridge/br_netfilter.c
81 @@ -73,6 +73,15 @@ static int brnf_pass_vlan_indev __read_m
82 #define IS_ARP(skb) \
83 (!vlan_tx_tag_present(skb) && skb->protocol == htons(ETH_P_ARP))
84
85 +int brnf_call_ebtables __read_mostly = 0;
86 +EXPORT_SYMBOL_GPL(brnf_call_ebtables);
87 +
88 +bool br_netfilter_run_hooks(void)
89 +{
90 + return brnf_call_iptables | brnf_call_ip6tables | brnf_call_arptables |
91 + brnf_call_ebtables;
92 +}
93 +
94 static inline __be16 vlan_proto(const struct sk_buff *skb)
95 {
96 if (vlan_tx_tag_present(skb))
97 --- a/net/bridge/br_private.h
98 +++ b/net/bridge/br_private.h
99 @@ -696,15 +696,29 @@ static inline u16 br_get_pvid(const stru
100
101 /* br_netfilter.c */
102 #ifdef CONFIG_BRIDGE_NETFILTER
103 +extern int brnf_call_ebtables;
104 extern int br_netfilter_init(void);
105 extern void br_netfilter_fini(void);
106 extern void br_netfilter_rtable_init(struct net_bridge *);
107 +extern bool br_netfilter_run_hooks(void);
108 #else
109 #define br_netfilter_init() (0)
110 #define br_netfilter_fini() do { } while(0)
111 #define br_netfilter_rtable_init(x)
112 +#define br_netfilter_run_hooks() false
113 #endif
114
115 +static inline int
116 +BR_HOOK(uint8_t pf, unsigned int hook, struct sk_buff *skb,
117 + struct net_device *in, struct net_device *out,
118 + int (*okfn)(struct sk_buff *))
119 +{
120 + if (!br_netfilter_run_hooks())
121 + return okfn(skb);
122 +
123 + return NF_HOOK(pf, hook, skb, in, out, okfn);
124 +}
125 +
126 /* br_stp.c */
127 extern void br_log_state(const struct net_bridge_port *p);
128 extern struct net_bridge_port *br_get_port(struct net_bridge *br,
129 --- a/net/bridge/br_stp_bpdu.c
130 +++ b/net/bridge/br_stp_bpdu.c
131 @@ -54,7 +54,7 @@ static void br_send_bpdu(struct net_brid
132
133 skb_reset_mac_header(skb);
134
135 - NF_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
136 + BR_HOOK(NFPROTO_BRIDGE, NF_BR_LOCAL_OUT, skb, NULL, skb->dev,
137 dev_queue_xmit);
138 }
139
140 --- a/net/bridge/netfilter/ebtables.c
141 +++ b/net/bridge/netfilter/ebtables.c
142 @@ -2407,11 +2407,13 @@ static int __init ebtables_init(void)
143 }
144
145 printk(KERN_INFO "Ebtables v2.0 registered\n");
146 + brnf_call_ebtables = 1;
147 return 0;
148 }
149
150 static void __exit ebtables_fini(void)
151 {
152 + brnf_call_ebtables = 0;
153 nf_unregister_sockopt(&ebt_sockopts);
154 xt_unregister_target(&ebt_standard_target);
155 printk(KERN_INFO "Ebtables v2.0 unregistered\n");