]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - net/bridge/br_netfilter_hooks.c
netfilter: Use nf_hook_state.net
[mirror_ubuntu-bionic-kernel.git] / net / bridge / br_netfilter_hooks.c
CommitLineData
1da177e4
LT
1/*
2 * Handle firewalling
3 * Linux ethernet bridge
4 *
5 * Authors:
8237908e
BDS
6 * Lennert Buytenhek <buytenh@gnu.org>
7 * Bart De Schuymer <bdschuym@pandora.be>
1da177e4
LT
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version
12 * 2 of the License, or (at your option) any later version.
13 *
14 * Lennert dedicates this file to Kerstin Wurdinger.
15 */
16
17#include <linux/module.h>
18#include <linux/kernel.h>
5a0e3ad6 19#include <linux/slab.h>
1da177e4
LT
20#include <linux/ip.h>
21#include <linux/netdevice.h>
22#include <linux/skbuff.h>
14c85021 23#include <linux/if_arp.h>
1da177e4
LT
24#include <linux/if_ether.h>
25#include <linux/if_vlan.h>
516299d2
MM
26#include <linux/if_pppox.h>
27#include <linux/ppp_defs.h>
1da177e4
LT
28#include <linux/netfilter_bridge.h>
29#include <linux/netfilter_ipv4.h>
30#include <linux/netfilter_ipv6.h>
31#include <linux/netfilter_arp.h>
32#include <linux/in_route.h>
f216f082 33#include <linux/inetdevice.h>
14c85021 34
1da177e4
LT
35#include <net/ip.h>
36#include <net/ipv6.h>
efb6de9b 37#include <net/addrconf.h>
14c85021 38#include <net/route.h>
56768644 39#include <net/netfilter/br_netfilter.h>
14c85021 40
1da177e4 41#include <asm/uaccess.h>
1da177e4
LT
42#include "br_private.h"
43#ifdef CONFIG_SYSCTL
44#include <linux/sysctl.h>
45#endif
46
1da177e4
LT
47#ifdef CONFIG_SYSCTL
48static struct ctl_table_header *brnf_sysctl_header;
9c1ea148
BH
49static int brnf_call_iptables __read_mostly = 1;
50static int brnf_call_ip6tables __read_mostly = 1;
51static int brnf_call_arptables __read_mostly = 1;
f4b3eee7
BT
52static int brnf_filter_vlan_tagged __read_mostly;
53static int brnf_filter_pppoe_tagged __read_mostly;
54static int brnf_pass_vlan_indev __read_mostly;
1da177e4 55#else
4df53d8b
PM
56#define brnf_call_iptables 1
57#define brnf_call_ip6tables 1
58#define brnf_call_arptables 1
47e0e1ca
HX
59#define brnf_filter_vlan_tagged 0
60#define brnf_filter_pppoe_tagged 0
4981682c 61#define brnf_pass_vlan_indev 0
1da177e4
LT
62#endif
63
739e4505 64#define IS_IP(skb) \
df8a39de 65 (!skb_vlan_tag_present(skb) && skb->protocol == htons(ETH_P_IP))
739e4505
FW
66
67#define IS_IPV6(skb) \
df8a39de 68 (!skb_vlan_tag_present(skb) && skb->protocol == htons(ETH_P_IPV6))
739e4505
FW
69
70#define IS_ARP(skb) \
df8a39de 71 (!skb_vlan_tag_present(skb) && skb->protocol == htons(ETH_P_ARP))
739e4505 72
b6f99a21 73static inline __be16 vlan_proto(const struct sk_buff *skb)
8b42ec39 74{
df8a39de 75 if (skb_vlan_tag_present(skb))
13937911
JG
76 return skb->protocol;
77 else if (skb->protocol == htons(ETH_P_8021Q))
78 return vlan_eth_hdr(skb)->h_vlan_encapsulated_proto;
79 else
80 return 0;
8b42ec39
SH
81}
82
83#define IS_VLAN_IP(skb) \
13937911 84 (vlan_proto(skb) == htons(ETH_P_IP) && \
8b42ec39
SH
85 brnf_filter_vlan_tagged)
86
87#define IS_VLAN_IPV6(skb) \
13937911 88 (vlan_proto(skb) == htons(ETH_P_IPV6) && \
8b42ec39
SH
89 brnf_filter_vlan_tagged)
90
91#define IS_VLAN_ARP(skb) \
13937911 92 (vlan_proto(skb) == htons(ETH_P_ARP) && \
8b42ec39 93 brnf_filter_vlan_tagged)
1da177e4 94
516299d2
MM
95static inline __be16 pppoe_proto(const struct sk_buff *skb)
96{
97 return *((__be16 *)(skb_mac_header(skb) + ETH_HLEN +
98 sizeof(struct pppoe_hdr)));
99}
100
101#define IS_PPPOE_IP(skb) \
102 (skb->protocol == htons(ETH_P_PPP_SES) && \
103 pppoe_proto(skb) == htons(PPP_IP) && \
104 brnf_filter_pppoe_tagged)
105
106#define IS_PPPOE_IPV6(skb) \
107 (skb->protocol == htons(ETH_P_PPP_SES) && \
108 pppoe_proto(skb) == htons(PPP_IPV6) && \
109 brnf_filter_pppoe_tagged)
110
e70deecb
FW
111/* largest possible L2 header, see br_nf_dev_queue_xmit() */
112#define NF_BRIDGE_MAX_MAC_HEADER_LENGTH (PPPOE_SES_HLEN + ETH_HLEN)
113
a1bc1b35 114#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) || IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
e70deecb
FW
115struct brnf_frag_data {
116 char mac[NF_BRIDGE_MAX_MAC_HEADER_LENGTH];
117 u8 encap_size;
118 u8 size;
d7b59742
FW
119 u16 vlan_tci;
120 __be16 vlan_proto;
e70deecb
FW
121};
122
123static DEFINE_PER_CPU(struct brnf_frag_data, brnf_frag_data_storage);
124#endif
125
a9fcc6a4
FW
126static void nf_bridge_info_free(struct sk_buff *skb)
127{
128 if (skb->nf_bridge) {
129 nf_bridge_put(skb->nf_bridge);
130 skb->nf_bridge = NULL;
131 }
132}
133
5dce971a
SH
134static inline struct net_device *bridge_parent(const struct net_device *dev)
135{
b5ed54e9 136 struct net_bridge_port *port;
5dce971a 137
b5ed54e9 138 port = br_port_get_rcu(dev);
139 return port ? port->br->dev : NULL;
5dce971a 140}
1da177e4 141
2dc2f207
PM
142static inline struct nf_bridge_info *nf_bridge_unshare(struct sk_buff *skb)
143{
144 struct nf_bridge_info *nf_bridge = skb->nf_bridge;
145
146 if (atomic_read(&nf_bridge->use) > 1) {
147 struct nf_bridge_info *tmp = nf_bridge_alloc(skb);
148
149 if (tmp) {
150 memcpy(tmp, nf_bridge, sizeof(struct nf_bridge_info));
151 atomic_set(&tmp->use, 1);
2dc2f207 152 }
4c3a76ab 153 nf_bridge_put(nf_bridge);
2dc2f207
PM
154 nf_bridge = tmp;
155 }
156 return nf_bridge;
157}
158
230ac490 159unsigned int nf_bridge_encap_header_len(const struct sk_buff *skb)
8d045163
FW
160{
161 switch (skb->protocol) {
162 case __cpu_to_be16(ETH_P_8021Q):
163 return VLAN_HLEN;
164 case __cpu_to_be16(ETH_P_PPP_SES):
165 return PPPOE_SES_HLEN;
166 default:
167 return 0;
168 }
169}
170
fc38582d 171static inline void nf_bridge_pull_encap_header(struct sk_buff *skb)
fdeabdef 172{
fc38582d
PM
173 unsigned int len = nf_bridge_encap_header_len(skb);
174
175 skb_pull(skb, len);
176 skb->network_header += len;
177}
fdeabdef 178
fc38582d
PM
179static inline void nf_bridge_pull_encap_header_rcsum(struct sk_buff *skb)
180{
181 unsigned int len = nf_bridge_encap_header_len(skb);
182
183 skb_pull_rcsum(skb, len);
184 skb->network_header += len;
185}
186
462fb2af
BD
187/* When handing a packet over to the IP layer
188 * check whether we have a skb that is in the
189 * expected format
190 */
191
77d574e7 192static int br_validate_ipv4(struct sk_buff *skb)
462fb2af 193{
b71d1d42 194 const struct iphdr *iph;
462fb2af
BD
195 struct net_device *dev = skb->dev;
196 u32 len;
197
6caab7b0
SB
198 if (!pskb_may_pull(skb, sizeof(struct iphdr)))
199 goto inhdr_error;
200
462fb2af 201 iph = ip_hdr(skb);
462fb2af
BD
202
203 /* Basic sanity checks */
204 if (iph->ihl < 5 || iph->version != 4)
205 goto inhdr_error;
206
207 if (!pskb_may_pull(skb, iph->ihl*4))
208 goto inhdr_error;
209
210 iph = ip_hdr(skb);
211 if (unlikely(ip_fast_csum((u8 *)iph, iph->ihl)))
212 goto inhdr_error;
213
214 len = ntohs(iph->tot_len);
215 if (skb->len < len) {
216 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INTRUNCATEDPKTS);
217 goto drop;
218 } else if (len < (iph->ihl*4))
219 goto inhdr_error;
220
221 if (pskb_trim_rcsum(skb, len)) {
222 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);
223 goto drop;
224 }
225
f8e9881c 226 memset(IPCB(skb), 0, sizeof(struct inet_skb_parm));
7677e868
HX
227 /* We should really parse IP options here but until
228 * somebody who actually uses IP options complains to
229 * us we'll just silently ignore the options because
230 * we're lazy!
231 */
462fb2af
BD
232 return 0;
233
234inhdr_error:
235 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INHDRERRORS);
236drop:
237 return -1;
238}
239
230ac490 240void nf_bridge_update_protocol(struct sk_buff *skb)
4a9d2f20 241{
3eaf4025
FW
242 switch (skb->nf_bridge->orig_proto) {
243 case BRNF_PROTO_8021Q:
4a9d2f20 244 skb->protocol = htons(ETH_P_8021Q);
3eaf4025
FW
245 break;
246 case BRNF_PROTO_PPPOE:
4a9d2f20 247 skb->protocol = htons(ETH_P_PPP_SES);
3eaf4025
FW
248 break;
249 case BRNF_PROTO_UNCHANGED:
250 break;
251 }
4a9d2f20
FW
252}
253
e179e632
BDS
254/* Obtain the correct destination MAC address, while preserving the original
255 * source MAC address. If we already know this address, we just copy it. If we
256 * don't, we use the neighbour framework to find out. In both cases, we make
257 * sure that br_handle_frame_finish() is called afterwards.
258 */
230ac490 259int br_nf_pre_routing_finish_bridge(struct sock *sk, struct sk_buff *skb)
e179e632 260{
f6b72b62 261 struct neighbour *neigh;
e179e632
BDS
262 struct dst_entry *dst;
263
264 skb->dev = bridge_parent(skb->dev);
265 if (!skb->dev)
266 goto free_skb;
267 dst = skb_dst(skb);
f9d75166
DM
268 neigh = dst_neigh_lookup_skb(dst, skb);
269 if (neigh) {
38330783 270 struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
f9d75166
DM
271 int ret;
272
273 if (neigh->hh.hh_len) {
274 neigh_hh_bridge(&neigh->hh, skb);
275 skb->dev = nf_bridge->physindev;
7026b1dd 276 ret = br_handle_frame_finish(sk, skb);
f9d75166
DM
277 } else {
278 /* the neighbour function below overwrites the complete
279 * MAC header, so we save the Ethernet source address and
280 * protocol number.
281 */
282 skb_copy_from_linear_data_offset(skb,
283 -(ETH_HLEN-ETH_ALEN),
e70deecb 284 nf_bridge->neigh_header,
f9d75166
DM
285 ETH_HLEN-ETH_ALEN);
286 /* tell br_dev_xmit to continue with forwarding */
72b1e5e4 287 nf_bridge->bridged_dnat = 1;
93fdd47e 288 /* FIXME Need to refragment */
f9d75166
DM
289 ret = neigh->output(neigh, skb);
290 }
291 neigh_release(neigh);
292 return ret;
e179e632
BDS
293 }
294free_skb:
295 kfree_skb(skb);
296 return 0;
297}
298
230ac490
PNA
299static inline bool
300br_nf_ipv4_daddr_was_changed(const struct sk_buff *skb,
301 const struct nf_bridge_info *nf_bridge)
8cae308d 302{
230ac490 303 return ip_hdr(skb)->daddr != nf_bridge->ipv4_daddr;
8cae308d
BT
304}
305
1da177e4 306/* This requires some explaining. If DNAT has taken place,
ea2d9b41 307 * we will need to fix up the destination Ethernet address.
faecbb45 308 * This is also true when SNAT takes place (for the reply direction).
1da177e4
LT
309 *
310 * There are two cases to consider:
311 * 1. The packet was DNAT'ed to a device in the same bridge
312 * port group as it was received on. We can still bridge
313 * the packet.
314 * 2. The packet was DNAT'ed to a different device, either
315 * a non-bridged device or another bridge port group.
316 * The packet will need to be routed.
317 *
318 * The correct way of distinguishing between these two cases is to
319 * call ip_route_input() and to look at skb->dst->dev, which is
320 * changed to the destination device if ip_route_input() succeeds.
321 *
ea2d9b41 322 * Let's first consider the case that ip_route_input() succeeds:
1da177e4 323 *
ea2d9b41
BDS
324 * If the output device equals the logical bridge device the packet
325 * came in on, we can consider this bridging. The corresponding MAC
326 * address will be obtained in br_nf_pre_routing_finish_bridge.
1da177e4
LT
327 * Otherwise, the packet is considered to be routed and we just
328 * change the destination MAC address so that the packet will
f216f082
BDS
329 * later be passed up to the IP stack to be routed. For a redirected
330 * packet, ip_route_input() will give back the localhost as output device,
331 * which differs from the bridge device.
1da177e4 332 *
ea2d9b41 333 * Let's now consider the case that ip_route_input() fails:
1da177e4 334 *
f216f082
BDS
335 * This can be because the destination address is martian, in which case
336 * the packet will be dropped.
ea2d9b41
BDS
337 * If IP forwarding is disabled, ip_route_input() will fail, while
338 * ip_route_output_key() can return success. The source
339 * address for ip_route_output_key() is set to zero, so ip_route_output_key()
1da177e4 340 * thinks we're handling a locally generated packet and won't care
ea2d9b41
BDS
341 * if IP forwarding is enabled. If the output device equals the logical bridge
342 * device, we proceed as if ip_route_input() succeeded. If it differs from the
343 * logical bridge port or if ip_route_output_key() fails we drop the packet.
344 */
7026b1dd 345static int br_nf_pre_routing_finish(struct sock *sk, struct sk_buff *skb)
1da177e4
LT
346{
347 struct net_device *dev = skb->dev;
eddc9ec5 348 struct iphdr *iph = ip_hdr(skb);
f2d74cf8 349 struct net *net = dev_net(dev);
38330783 350 struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
511c3f92 351 struct rtable *rt;
f216f082 352 int err;
93fdd47e 353
411ffb4f 354 nf_bridge->frag_max_size = IPCB(skb)->frag_max_size;
1da177e4 355
a1e67951 356 if (nf_bridge->pkt_otherhost) {
1da177e4 357 skb->pkt_type = PACKET_OTHERHOST;
a1e67951 358 nf_bridge->pkt_otherhost = false;
1da177e4 359 }
72b1e5e4 360 nf_bridge->in_prerouting = 0;
230ac490 361 if (br_nf_ipv4_daddr_was_changed(skb, nf_bridge)) {
f216f082 362 if ((err = ip_route_input(skb, iph->daddr, iph->saddr, iph->tos, dev))) {
f3abc9b9 363 struct in_device *in_dev = __in_dev_get_rcu(dev);
f216f082
BDS
364
365 /* If err equals -EHOSTUNREACH the error is due to a
366 * martian destination or due to the fact that
367 * forwarding is disabled. For most martian packets,
368 * ip_route_output_key() will fail. It won't fail for 2 types of
369 * martian destinations: loopback destinations and destination
370 * 0.0.0.0. In both cases the packet will be dropped because the
371 * destination is the loopback device and not the bridge. */
372 if (err != -EHOSTUNREACH || !in_dev || IN_DEV_FORWARD(in_dev))
373 goto free_skb;
1da177e4 374
f2d74cf8 375 rt = ip_route_output(net, iph->daddr, 0,
78fbfd8a 376 RT_TOS(iph->tos), 0);
b23dd4fe 377 if (!IS_ERR(rt)) {
1c011bed 378 /* - Bridged-and-DNAT'ed traffic doesn't
f216f082 379 * require ip_forwarding. */
b23dd4fe
DM
380 if (rt->dst.dev == dev) {
381 skb_dst_set(skb, &rt->dst);
1da177e4
LT
382 goto bridged_dnat;
383 }
b23dd4fe 384 ip_rt_put(rt);
1da177e4 385 }
f216f082 386free_skb:
1da177e4
LT
387 kfree_skb(skb);
388 return 0;
389 } else {
adf30907 390 if (skb_dst(skb)->dev == dev) {
1da177e4 391bridged_dnat:
1da177e4 392 skb->dev = nf_bridge->physindev;
e179e632 393 nf_bridge_update_protocol(skb);
fc38582d 394 nf_bridge_push_encap_header(skb);
713aefa3
JE
395 NF_HOOK_THRESH(NFPROTO_BRIDGE,
396 NF_BR_PRE_ROUTING,
29a26a56 397 net, sk, skb, skb->dev, NULL,
1da177e4
LT
398 br_nf_pre_routing_finish_bridge,
399 1);
400 return 0;
401 }
04091142 402 ether_addr_copy(eth_hdr(skb)->h_dest, dev->dev_addr);
1da177e4
LT
403 skb->pkt_type = PACKET_HOST;
404 }
405 } else {
511c3f92
ED
406 rt = bridge_parent_rtable(nf_bridge->physindev);
407 if (!rt) {
4adf0af6
SW
408 kfree_skb(skb);
409 return 0;
410 }
f9181f4f 411 skb_dst_set_noref(skb, &rt->dst);
1da177e4
LT
412 }
413
414 skb->dev = nf_bridge->physindev;
e179e632 415 nf_bridge_update_protocol(skb);
fc38582d 416 nf_bridge_push_encap_header(skb);
29a26a56 417 NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_PRE_ROUTING, net, sk, skb,
7026b1dd 418 skb->dev, NULL,
1da177e4
LT
419 br_handle_frame_finish, 1);
420
421 return 0;
422}
423
4981682c
PNA
424static struct net_device *brnf_get_logical_dev(struct sk_buff *skb, const struct net_device *dev)
425{
426 struct net_device *vlan, *br;
427
428 br = bridge_parent(dev);
df8a39de 429 if (brnf_pass_vlan_indev == 0 || !skb_vlan_tag_present(skb))
4981682c
PNA
430 return br;
431
f06c7f9f 432 vlan = __vlan_find_dev_deep_rcu(br, skb->vlan_proto,
df8a39de 433 skb_vlan_tag_get(skb) & VLAN_VID_MASK);
4981682c
PNA
434
435 return vlan ? vlan : br;
436}
437
1da177e4 438/* Some common code for IPv4/IPv6 */
230ac490 439struct net_device *setup_pre_routing(struct sk_buff *skb)
1da177e4 440{
38330783 441 struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
1da177e4
LT
442
443 if (skb->pkt_type == PACKET_OTHERHOST) {
444 skb->pkt_type = PACKET_HOST;
a1e67951 445 nf_bridge->pkt_otherhost = true;
1da177e4
LT
446 }
447
72b1e5e4 448 nf_bridge->in_prerouting = 1;
1da177e4 449 nf_bridge->physindev = skb->dev;
4981682c 450 skb->dev = brnf_get_logical_dev(skb, skb->dev);
3eaf4025 451
e179e632 452 if (skb->protocol == htons(ETH_P_8021Q))
3eaf4025 453 nf_bridge->orig_proto = BRNF_PROTO_8021Q;
e179e632 454 else if (skb->protocol == htons(ETH_P_PPP_SES))
3eaf4025 455 nf_bridge->orig_proto = BRNF_PROTO_PPPOE;
5dce971a 456
6b8dbcf2
FW
457 /* Must drop socket now because of tproxy. */
458 skb_orphan(skb);
5dce971a 459 return skb->dev;
1da177e4
LT
460}
461
1da177e4
LT
462/* Direct IPv6 traffic to br_nf_pre_routing_ipv6.
463 * Replicate the checks that IPv4 does on packet reception.
464 * Set skb->dev to the bridge device (i.e. parent of the
465 * receiving device) to make netfilter happy, the REDIRECT
466 * target in particular. Save the original destination IP
467 * address to be able to detect DNAT afterwards. */
795aa6ef
PM
468static unsigned int br_nf_pre_routing(const struct nf_hook_ops *ops,
469 struct sk_buff *skb,
238e54c9 470 const struct nf_hook_state *state)
1da177e4 471{
faecbb45 472 struct nf_bridge_info *nf_bridge;
4df53d8b
PM
473 struct net_bridge_port *p;
474 struct net_bridge *br;
e7c243c9
EP
475 __u32 len = nf_bridge_encap_header_len(skb);
476
e7c243c9 477 if (unlikely(!pskb_may_pull(skb, len)))
deef4b52 478 return NF_DROP;
1da177e4 479
238e54c9 480 p = br_port_get_rcu(state->in);
4df53d8b 481 if (p == NULL)
deef4b52 482 return NF_DROP;
4df53d8b
PM
483 br = p->br;
484
739e4505 485 if (IS_IPV6(skb) || IS_VLAN_IPV6(skb) || IS_PPPOE_IPV6(skb)) {
4df53d8b 486 if (!brnf_call_ip6tables && !br->nf_call_ip6tables)
1da177e4 487 return NF_ACCEPT;
4df53d8b 488
fc38582d 489 nf_bridge_pull_encap_header_rcsum(skb);
238e54c9 490 return br_nf_pre_routing_ipv6(ops, skb, state);
1da177e4 491 }
4df53d8b
PM
492
493 if (!brnf_call_iptables && !br->nf_call_iptables)
1da177e4 494 return NF_ACCEPT;
1da177e4 495
739e4505 496 if (!IS_IP(skb) && !IS_VLAN_IP(skb) && !IS_PPPOE_IP(skb))
1da177e4
LT
497 return NF_ACCEPT;
498
fc38582d 499 nf_bridge_pull_encap_header_rcsum(skb);
1da177e4 500
77d574e7 501 if (br_validate_ipv4(skb))
deef4b52 502 return NF_DROP;
17762060 503
789bc3e5 504 nf_bridge_put(skb->nf_bridge);
fdeabdef 505 if (!nf_bridge_alloc(skb))
1da177e4 506 return NF_DROP;
5dce971a
SH
507 if (!setup_pre_routing(skb))
508 return NF_DROP;
c055d5b0 509
faecbb45
FW
510 nf_bridge = nf_bridge_info_get(skb);
511 nf_bridge->ipv4_daddr = ip_hdr(skb)->daddr;
512
e179e632 513 skb->protocol = htons(ETH_P_IP);
1da177e4 514
29a26a56 515 NF_HOOK(NFPROTO_IPV4, NF_INET_PRE_ROUTING, state->net, state->sk, skb,
7026b1dd 516 skb->dev, NULL,
1da177e4
LT
517 br_nf_pre_routing_finish);
518
519 return NF_STOLEN;
1da177e4
LT
520}
521
522
523/* PF_BRIDGE/LOCAL_IN ************************************************/
524/* The packet is locally destined, which requires a real
525 * dst_entry, so detach the fake one. On the way up, the
526 * packet would pass through PRE_ROUTING again (which already
527 * took place when the packet entered the bridge), but we
528 * register an IPv4 PRE_ROUTING 'sabotage' hook that will
529 * prevent this from happening. */
795aa6ef
PM
530static unsigned int br_nf_local_in(const struct nf_hook_ops *ops,
531 struct sk_buff *skb,
238e54c9 532 const struct nf_hook_state *state)
1da177e4 533{
a881e963 534 br_drop_fake_rtable(skb);
1da177e4
LT
535 return NF_ACCEPT;
536}
537
1da177e4 538/* PF_BRIDGE/FORWARD *************************************************/
7026b1dd 539static int br_nf_forward_finish(struct sock *sk, struct sk_buff *skb)
1da177e4 540{
38330783 541 struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
29a26a56 542 struct net *net = dev_net(skb->dev);
1da177e4 543 struct net_device *in;
1da177e4 544
739e4505 545 if (!IS_ARP(skb) && !IS_VLAN_ARP(skb)) {
0b67c43c 546
efb6de9b 547 if (skb->protocol == htons(ETH_P_IP))
411ffb4f 548 nf_bridge->frag_max_size = IPCB(skb)->frag_max_size;
efb6de9b
BT
549
550 if (skb->protocol == htons(ETH_P_IPV6))
551 nf_bridge->frag_max_size = IP6CB(skb)->frag_max_size;
0b67c43c 552
1da177e4 553 in = nf_bridge->physindev;
a1e67951 554 if (nf_bridge->pkt_otherhost) {
1da177e4 555 skb->pkt_type = PACKET_OTHERHOST;
a1e67951 556 nf_bridge->pkt_otherhost = false;
1da177e4 557 }
e94c6743 558 nf_bridge_update_protocol(skb);
1da177e4
LT
559 } else {
560 in = *((struct net_device **)(skb->cb));
561 }
fc38582d 562 nf_bridge_push_encap_header(skb);
e179e632 563
29a26a56 564 NF_HOOK_THRESH(NFPROTO_BRIDGE, NF_BR_FORWARD, net, sk, skb,
7026b1dd 565 in, skb->dev, br_forward_finish, 1);
1da177e4
LT
566 return 0;
567}
568
739e4505 569
1da177e4
LT
570/* This is the 'purely bridged' case. For IP, we pass the packet to
571 * netfilter with indev and outdev set to the bridge device,
572 * but we are still able to filter on the 'real' indev/outdev
573 * because of the physdev module. For ARP, indev and outdev are the
574 * bridge ports. */
795aa6ef
PM
575static unsigned int br_nf_forward_ip(const struct nf_hook_ops *ops,
576 struct sk_buff *skb,
238e54c9 577 const struct nf_hook_state *state)
1da177e4 578{
1da177e4 579 struct nf_bridge_info *nf_bridge;
5dce971a 580 struct net_device *parent;
76108cea 581 u_int8_t pf;
1da177e4
LT
582
583 if (!skb->nf_bridge)
584 return NF_ACCEPT;
585
2dc2f207
PM
586 /* Need exclusive nf_bridge_info since we might have multiple
587 * different physoutdevs. */
588 if (!nf_bridge_unshare(skb))
589 return NF_DROP;
590
38330783
FW
591 nf_bridge = nf_bridge_info_get(skb);
592 if (!nf_bridge)
593 return NF_DROP;
594
238e54c9 595 parent = bridge_parent(state->out);
5dce971a
SH
596 if (!parent)
597 return NF_DROP;
598
739e4505 599 if (IS_IP(skb) || IS_VLAN_IP(skb) || IS_PPPOE_IP(skb))
aa740f46 600 pf = NFPROTO_IPV4;
739e4505 601 else if (IS_IPV6(skb) || IS_VLAN_IPV6(skb) || IS_PPPOE_IPV6(skb))
aa740f46 602 pf = NFPROTO_IPV6;
a2bd40ad
HX
603 else
604 return NF_ACCEPT;
1da177e4 605
3db05fea 606 nf_bridge_pull_encap_header(skb);
1da177e4 607
1da177e4
LT
608 if (skb->pkt_type == PACKET_OTHERHOST) {
609 skb->pkt_type = PACKET_HOST;
a1e67951 610 nf_bridge->pkt_otherhost = true;
1da177e4
LT
611 }
612
0b67c43c 613 if (pf == NFPROTO_IPV4) {
77d574e7 614 if (br_validate_ipv4(skb))
0b67c43c 615 return NF_DROP;
411ffb4f 616 IPCB(skb)->frag_max_size = nf_bridge->frag_max_size;
0b67c43c 617 }
6b1e960f 618
efb6de9b
BT
619 if (pf == NFPROTO_IPV6) {
620 if (br_validate_ipv6(skb))
621 return NF_DROP;
622 IP6CB(skb)->frag_max_size = nf_bridge->frag_max_size;
623 }
624
1da177e4 625 nf_bridge->physoutdev = skb->dev;
aa740f46 626 if (pf == NFPROTO_IPV4)
e179e632
BDS
627 skb->protocol = htons(ETH_P_IP);
628 else
629 skb->protocol = htons(ETH_P_IPV6);
1da177e4 630
29a26a56 631 NF_HOOK(pf, NF_INET_FORWARD, state->net, NULL, skb,
7026b1dd 632 brnf_get_logical_dev(skb, state->in),
238e54c9 633 parent, br_nf_forward_finish);
1da177e4
LT
634
635 return NF_STOLEN;
636}
637
795aa6ef
PM
638static unsigned int br_nf_forward_arp(const struct nf_hook_ops *ops,
639 struct sk_buff *skb,
238e54c9 640 const struct nf_hook_state *state)
1da177e4 641{
4df53d8b
PM
642 struct net_bridge_port *p;
643 struct net_bridge *br;
1da177e4
LT
644 struct net_device **d = (struct net_device **)(skb->cb);
645
238e54c9 646 p = br_port_get_rcu(state->out);
4df53d8b
PM
647 if (p == NULL)
648 return NF_ACCEPT;
649 br = p->br;
650
651 if (!brnf_call_arptables && !br->nf_call_arptables)
1da177e4 652 return NF_ACCEPT;
1da177e4 653
739e4505 654 if (!IS_ARP(skb)) {
8b42ec39 655 if (!IS_VLAN_ARP(skb))
1da177e4 656 return NF_ACCEPT;
3db05fea 657 nf_bridge_pull_encap_header(skb);
1da177e4
LT
658 }
659
d0a92be0 660 if (arp_hdr(skb)->ar_pln != 4) {
fc38582d 661 if (IS_VLAN_ARP(skb))
3db05fea 662 nf_bridge_push_encap_header(skb);
1da177e4
LT
663 return NF_ACCEPT;
664 }
238e54c9 665 *d = state->in;
29a26a56 666 NF_HOOK(NFPROTO_ARP, NF_ARP_FORWARD, state->net, state->sk, skb,
7026b1dd 667 state->in, state->out, br_nf_forward_finish);
1da177e4
LT
668
669 return NF_STOLEN;
670}
671
efb6de9b 672#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4) || IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
6532948b 673static int br_nf_push_frag_xmit(struct net *net, struct sock *sk, struct sk_buff *skb)
8bd63cf1 674{
e70deecb 675 struct brnf_frag_data *data;
8bd63cf1 676 int err;
8bd63cf1 677
e70deecb
FW
678 data = this_cpu_ptr(&brnf_frag_data_storage);
679 err = skb_cow_head(skb, data->size);
8bd63cf1 680
e70deecb 681 if (err) {
8bd63cf1
FW
682 kfree_skb(skb);
683 return 0;
684 }
685
d7b59742
FW
686 if (data->vlan_tci) {
687 skb->vlan_tci = data->vlan_tci;
688 skb->vlan_proto = data->vlan_proto;
689 }
690
e70deecb
FW
691 skb_copy_to_linear_data_offset(skb, -data->size, data->mac, data->size);
692 __skb_push(skb, data->encap_size);
693
a9fcc6a4 694 nf_bridge_info_free(skb);
7026b1dd 695 return br_dev_queue_push_xmit(sk, skb);
8bd63cf1 696}
6532948b
EB
697static int br_nf_push_frag_xmit_sk(struct sock *sk, struct sk_buff *skb)
698{
699 struct net *net = dev_net(skb_dst(skb)->dev);
700 return br_nf_push_frag_xmit(net, sk, skb);
701}
efb6de9b 702#endif
8bd63cf1 703
a1bc1b35 704#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
8d4df0b9
EB
705static int
706br_nf_ip_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
707 int (*output)(struct sock *, struct sk_buff *))
49d16b23
AZ
708{
709 unsigned int mtu = ip_skb_dst_mtu(skb);
710 struct iphdr *iph = ip_hdr(skb);
49d16b23
AZ
711
712 if (unlikely(((iph->frag_off & htons(IP_DF)) && !skb->ignore_df) ||
713 (IPCB(skb)->frag_max_size &&
714 IPCB(skb)->frag_max_size > mtu))) {
8d4df0b9 715 IP_INC_STATS(net, IPSTATS_MIB_FRAGFAILS);
49d16b23
AZ
716 kfree_skb(skb);
717 return -EMSGSIZE;
718 }
719
720 return ip_do_fragment(sk, skb, output);
721}
a1bc1b35 722#endif
49d16b23 723
33b1f313
FW
724static unsigned int nf_bridge_mtu_reduction(const struct sk_buff *skb)
725{
726 if (skb->nf_bridge->orig_proto == BRNF_PROTO_PPPOE)
727 return PPPOE_SES_HLEN;
728 return 0;
729}
730
7026b1dd 731static int br_nf_dev_queue_xmit(struct sock *sk, struct sk_buff *skb)
2e2f7aef 732{
411ffb4f 733 struct nf_bridge_info *nf_bridge;
7a8d831d 734 unsigned int mtu_reserved;
8d4df0b9 735 struct net *net = dev_net(skb_dst(skb)->dev);
462fb2af 736
efb6de9b
BT
737 mtu_reserved = nf_bridge_mtu_reduction(skb);
738
739 if (skb_is_gso(skb) || skb->len + mtu_reserved <= skb->dev->mtu) {
a9fcc6a4 740 nf_bridge_info_free(skb);
7026b1dd 741 return br_dev_queue_push_xmit(sk, skb);
a9fcc6a4 742 }
7a8d831d 743
411ffb4f 744 nf_bridge = nf_bridge_info_get(skb);
efb6de9b
BT
745
746#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV4)
93fdd47e
HX
747 /* This is wrong! We should preserve the original fragment
748 * boundaries by preserving frag_list rather than refragmenting.
749 */
efb6de9b 750 if (skb->protocol == htons(ETH_P_IP)) {
e70deecb
FW
751 struct brnf_frag_data *data;
752
77d574e7 753 if (br_validate_ipv4(skb))
dd302b59 754 goto drop;
411ffb4f
BT
755
756 IPCB(skb)->frag_max_size = nf_bridge->frag_max_size;
e70deecb
FW
757
758 nf_bridge_update_protocol(skb);
759
760 data = this_cpu_ptr(&brnf_frag_data_storage);
d7b59742
FW
761
762 data->vlan_tci = skb->vlan_tci;
763 data->vlan_proto = skb->vlan_proto;
e70deecb
FW
764 data->encap_size = nf_bridge_encap_header_len(skb);
765 data->size = ETH_HLEN + data->encap_size;
766
767 skb_copy_from_linear_data_offset(skb, -data->size, data->mac,
768 data->size);
769
6532948b 770 return br_nf_ip_fragment(net, sk, skb, br_nf_push_frag_xmit_sk);
e70deecb 771 }
efb6de9b
BT
772#endif
773#if IS_ENABLED(CONFIG_NF_DEFRAG_IPV6)
774 if (skb->protocol == htons(ETH_P_IPV6)) {
775 const struct nf_ipv6_ops *v6ops = nf_get_ipv6_ops();
776 struct brnf_frag_data *data;
462fb2af 777
efb6de9b 778 if (br_validate_ipv6(skb))
dd302b59 779 goto drop;
efb6de9b
BT
780
781 IP6CB(skb)->frag_max_size = nf_bridge->frag_max_size;
782
783 nf_bridge_update_protocol(skb);
784
785 data = this_cpu_ptr(&brnf_frag_data_storage);
786 data->encap_size = nf_bridge_encap_header_len(skb);
787 data->size = ETH_HLEN + data->encap_size;
788
789 skb_copy_from_linear_data_offset(skb, -data->size, data->mac,
790 data->size);
791
792 if (v6ops)
6532948b 793 return v6ops->fragment(sk, skb, br_nf_push_frag_xmit_sk);
dd302b59
FW
794
795 kfree_skb(skb);
796 return -EMSGSIZE;
efb6de9b
BT
797 }
798#endif
a9fcc6a4
FW
799 nf_bridge_info_free(skb);
800 return br_dev_queue_push_xmit(sk, skb);
dd302b59
FW
801 drop:
802 kfree_skb(skb);
803 return 0;
c197facc 804}
1da177e4
LT
805
806/* PF_BRIDGE/POST_ROUTING ********************************************/
795aa6ef
PM
807static unsigned int br_nf_post_routing(const struct nf_hook_ops *ops,
808 struct sk_buff *skb,
238e54c9 809 const struct nf_hook_state *state)
1da177e4 810{
38330783 811 struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
1da177e4 812 struct net_device *realoutdev = bridge_parent(skb->dev);
76108cea 813 u_int8_t pf;
1da177e4 814
e4bb9bcb
FW
815 /* if nf_bridge is set, but ->physoutdev is NULL, this packet came in
816 * on a bridge, but was delivered locally and is now being routed:
817 *
818 * POST_ROUTING was already invoked from the ip stack.
819 */
820 if (!nf_bridge || !nf_bridge->physoutdev)
81d9ddae
PM
821 return NF_ACCEPT;
822
5dce971a
SH
823 if (!realoutdev)
824 return NF_DROP;
825
739e4505 826 if (IS_IP(skb) || IS_VLAN_IP(skb) || IS_PPPOE_IP(skb))
aa740f46 827 pf = NFPROTO_IPV4;
739e4505 828 else if (IS_IPV6(skb) || IS_VLAN_IPV6(skb) || IS_PPPOE_IPV6(skb))
aa740f46 829 pf = NFPROTO_IPV6;
a2bd40ad
HX
830 else
831 return NF_ACCEPT;
1da177e4 832
1da177e4
LT
833 /* We assume any code from br_dev_queue_push_xmit onwards doesn't care
834 * about the value of skb->pkt_type. */
835 if (skb->pkt_type == PACKET_OTHERHOST) {
836 skb->pkt_type = PACKET_HOST;
a1e67951 837 nf_bridge->pkt_otherhost = true;
1da177e4
LT
838 }
839
fc38582d 840 nf_bridge_pull_encap_header(skb);
aa740f46 841 if (pf == NFPROTO_IPV4)
e179e632
BDS
842 skb->protocol = htons(ETH_P_IP);
843 else
844 skb->protocol = htons(ETH_P_IPV6);
1da177e4 845
29a26a56 846 NF_HOOK(pf, NF_INET_POST_ROUTING, state->net, state->sk, skb,
7026b1dd 847 NULL, realoutdev,
2e2f7aef 848 br_nf_dev_queue_xmit);
1da177e4
LT
849
850 return NF_STOLEN;
1da177e4
LT
851}
852
1da177e4
LT
853/* IP/SABOTAGE *****************************************************/
854/* Don't hand locally destined packets to PF_INET(6)/PRE_ROUTING
855 * for the second time. */
795aa6ef
PM
856static unsigned int ip_sabotage_in(const struct nf_hook_ops *ops,
857 struct sk_buff *skb,
238e54c9 858 const struct nf_hook_state *state)
1da177e4 859{
72b1e5e4 860 if (skb->nf_bridge && !skb->nf_bridge->in_prerouting)
1da177e4 861 return NF_STOP;
1da177e4
LT
862
863 return NF_ACCEPT;
864}
865
e5de75bf
PNA
866/* This is called when br_netfilter has called into iptables/netfilter,
867 * and DNAT has taken place on a bridge-forwarded packet.
868 *
869 * neigh->output has created a new MAC header, with local br0 MAC
870 * as saddr.
871 *
872 * This restores the original MAC saddr of the bridged packet
873 * before invoking bridge forward logic to transmit the packet.
874 */
875static void br_nf_pre_routing_finish_bridge_slow(struct sk_buff *skb)
876{
38330783 877 struct nf_bridge_info *nf_bridge = nf_bridge_info_get(skb);
e5de75bf
PNA
878
879 skb_pull(skb, ETH_HLEN);
72b1e5e4 880 nf_bridge->bridged_dnat = 0;
e5de75bf 881
e70deecb
FW
882 BUILD_BUG_ON(sizeof(nf_bridge->neigh_header) != (ETH_HLEN - ETH_ALEN));
883
884 skb_copy_to_linear_data_offset(skb, -(ETH_HLEN - ETH_ALEN),
885 nf_bridge->neigh_header,
886 ETH_HLEN - ETH_ALEN);
e5de75bf 887 skb->dev = nf_bridge->physindev;
7fb48c5b
FW
888
889 nf_bridge->physoutdev = NULL;
7026b1dd 890 br_handle_frame_finish(NULL, skb);
e5de75bf
PNA
891}
892
1a4ba64d 893static int br_nf_dev_xmit(struct sk_buff *skb)
e5de75bf 894{
72b1e5e4 895 if (skb->nf_bridge && skb->nf_bridge->bridged_dnat) {
e5de75bf
PNA
896 br_nf_pre_routing_finish_bridge_slow(skb);
897 return 1;
898 }
899 return 0;
900}
1a4ba64d
PNA
901
902static const struct nf_br_ops br_ops = {
903 .br_dev_xmit_hook = br_nf_dev_xmit,
904};
e5de75bf 905
4b7fd5d9
PNA
906void br_netfilter_enable(void)
907{
908}
909EXPORT_SYMBOL_GPL(br_netfilter_enable);
910
ea2d9b41
BDS
911/* For br_nf_post_routing, we need (prio = NF_BR_PRI_LAST), because
912 * br_dev_queue_push_xmit is called afterwards */
1999414a 913static struct nf_hook_ops br_nf_ops[] __read_mostly = {
1490fd89
CG
914 {
915 .hook = br_nf_pre_routing,
916 .owner = THIS_MODULE,
aa740f46 917 .pf = NFPROTO_BRIDGE,
1490fd89
CG
918 .hooknum = NF_BR_PRE_ROUTING,
919 .priority = NF_BR_PRI_BRNF,
920 },
921 {
922 .hook = br_nf_local_in,
923 .owner = THIS_MODULE,
aa740f46 924 .pf = NFPROTO_BRIDGE,
1490fd89
CG
925 .hooknum = NF_BR_LOCAL_IN,
926 .priority = NF_BR_PRI_BRNF,
927 },
928 {
929 .hook = br_nf_forward_ip,
930 .owner = THIS_MODULE,
aa740f46 931 .pf = NFPROTO_BRIDGE,
1490fd89
CG
932 .hooknum = NF_BR_FORWARD,
933 .priority = NF_BR_PRI_BRNF - 1,
934 },
935 {
936 .hook = br_nf_forward_arp,
937 .owner = THIS_MODULE,
aa740f46 938 .pf = NFPROTO_BRIDGE,
1490fd89
CG
939 .hooknum = NF_BR_FORWARD,
940 .priority = NF_BR_PRI_BRNF,
941 },
1490fd89
CG
942 {
943 .hook = br_nf_post_routing,
944 .owner = THIS_MODULE,
aa740f46 945 .pf = NFPROTO_BRIDGE,
1490fd89
CG
946 .hooknum = NF_BR_POST_ROUTING,
947 .priority = NF_BR_PRI_LAST,
948 },
949 {
950 .hook = ip_sabotage_in,
951 .owner = THIS_MODULE,
aa740f46 952 .pf = NFPROTO_IPV4,
1490fd89
CG
953 .hooknum = NF_INET_PRE_ROUTING,
954 .priority = NF_IP_PRI_FIRST,
955 },
956 {
957 .hook = ip_sabotage_in,
958 .owner = THIS_MODULE,
aa740f46 959 .pf = NFPROTO_IPV6,
1490fd89
CG
960 .hooknum = NF_INET_PRE_ROUTING,
961 .priority = NF_IP6_PRI_FIRST,
962 },
1da177e4
LT
963};
964
965#ifdef CONFIG_SYSCTL
966static
fe2c6338 967int brnf_sysctl_call_tables(struct ctl_table *ctl, int write,
56b148eb 968 void __user *buffer, size_t *lenp, loff_t *ppos)
1da177e4
LT
969{
970 int ret;
971
8d65af78 972 ret = proc_dointvec(ctl, write, buffer, lenp, ppos);
1da177e4
LT
973
974 if (write && *(int *)(ctl->data))
975 *(int *)(ctl->data) = 1;
976 return ret;
977}
978
fe2c6338 979static struct ctl_table brnf_table[] = {
1da177e4 980 {
1da177e4
LT
981 .procname = "bridge-nf-call-arptables",
982 .data = &brnf_call_arptables,
983 .maxlen = sizeof(int),
984 .mode = 0644,
6d9f239a 985 .proc_handler = brnf_sysctl_call_tables,
1da177e4
LT
986 },
987 {
1da177e4
LT
988 .procname = "bridge-nf-call-iptables",
989 .data = &brnf_call_iptables,
990 .maxlen = sizeof(int),
991 .mode = 0644,
6d9f239a 992 .proc_handler = brnf_sysctl_call_tables,
1da177e4
LT
993 },
994 {
1da177e4
LT
995 .procname = "bridge-nf-call-ip6tables",
996 .data = &brnf_call_ip6tables,
997 .maxlen = sizeof(int),
998 .mode = 0644,
6d9f239a 999 .proc_handler = brnf_sysctl_call_tables,
1da177e4
LT
1000 },
1001 {
1da177e4
LT
1002 .procname = "bridge-nf-filter-vlan-tagged",
1003 .data = &brnf_filter_vlan_tagged,
1004 .maxlen = sizeof(int),
1005 .mode = 0644,
6d9f239a 1006 .proc_handler = brnf_sysctl_call_tables,
516299d2
MM
1007 },
1008 {
516299d2
MM
1009 .procname = "bridge-nf-filter-pppoe-tagged",
1010 .data = &brnf_filter_pppoe_tagged,
1011 .maxlen = sizeof(int),
1012 .mode = 0644,
6d9f239a 1013 .proc_handler = brnf_sysctl_call_tables,
1da177e4 1014 },
4981682c
PNA
1015 {
1016 .procname = "bridge-nf-pass-vlan-input-dev",
1017 .data = &brnf_pass_vlan_indev,
1018 .maxlen = sizeof(int),
1019 .mode = 0644,
1020 .proc_handler = brnf_sysctl_call_tables,
1021 },
f8572d8f 1022 { }
1da177e4 1023};
1da177e4
LT
1024#endif
1025
34666d46 1026static int __init br_netfilter_init(void)
1da177e4 1027{
5eb87f45 1028 int ret;
1da177e4 1029
34666d46 1030 ret = nf_register_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
5eb87f45 1031 if (ret < 0)
1da177e4 1032 return ret;
fc66f95c 1033
1da177e4 1034#ifdef CONFIG_SYSCTL
ec8f23ce 1035 brnf_sysctl_header = register_net_sysctl(&init_net, "net/bridge", brnf_table);
1da177e4 1036 if (brnf_sysctl_header == NULL) {
789bc3e5
SH
1037 printk(KERN_WARNING
1038 "br_netfilter: can't register to sysctl.\n");
96727239
GU
1039 nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
1040 return -ENOMEM;
1da177e4
LT
1041 }
1042#endif
1a4ba64d 1043 RCU_INIT_POINTER(nf_br_ops, &br_ops);
1da177e4 1044 printk(KERN_NOTICE "Bridge firewalling registered\n");
1da177e4
LT
1045 return 0;
1046}
1047
34666d46 1048static void __exit br_netfilter_fini(void)
1da177e4 1049{
1a4ba64d 1050 RCU_INIT_POINTER(nf_br_ops, NULL);
5eb87f45 1051 nf_unregister_hooks(br_nf_ops, ARRAY_SIZE(br_nf_ops));
1da177e4 1052#ifdef CONFIG_SYSCTL
5dd3df10 1053 unregister_net_sysctl_table(brnf_sysctl_header);
1da177e4
LT
1054#endif
1055}
34666d46
PNA
1056
1057module_init(br_netfilter_init);
1058module_exit(br_netfilter_fini);
1059
1060MODULE_LICENSE("GPL");
1061MODULE_AUTHOR("Lennert Buytenhek <buytenh@gnu.org>");
1062MODULE_AUTHOR("Bart De Schuymer <bdschuym@pandora.be>");
1063MODULE_DESCRIPTION("Linux ethernet netfilter firewall bridge");