aboutsummaryrefslogtreecommitdiffstats
path: root/net/bridge
diff options
context:
space:
mode:
Diffstat (limited to 'net/bridge')
-rw-r--r--net/bridge/br_netfilter.c16
-rw-r--r--net/bridge/br_netlink.c4
-rw-r--r--net/bridge/br_notify.c2
-rw-r--r--net/bridge/br_stp_bpdu.c2
-rw-r--r--net/bridge/br_sysfs_br.c6
-rw-r--r--net/bridge/netfilter/Kconfig14
-rw-r--r--net/bridge/netfilter/Makefile1
-rw-r--r--net/bridge/netfilter/ebt_nflog.c74
-rw-r--r--net/bridge/netfilter/ebtable_broute.c2
-rw-r--r--net/bridge/netfilter/ebtable_filter.c2
-rw-r--r--net/bridge/netfilter/ebtable_nat.c2
11 files changed, 108 insertions, 17 deletions
diff --git a/net/bridge/br_netfilter.c b/net/bridge/br_netfilter.c
index af7e8be8d8d2..bb90cd7bace3 100644
--- a/net/bridge/br_netfilter.c
+++ b/net/bridge/br_netfilter.c
@@ -111,7 +111,9 @@ static inline __be16 pppoe_proto(const struct sk_buff *skb)
111 * require us to fill additional fields. */ 111 * require us to fill additional fields. */
112static struct net_device __fake_net_device = { 112static struct net_device __fake_net_device = {
113 .hard_header_len = ETH_HLEN, 113 .hard_header_len = ETH_HLEN,
114#ifdef CONFIG_NET_NS
114 .nd_net = &init_net, 115 .nd_net = &init_net,
116#endif
115}; 117};
116 118
117static struct rtable __fake_rtable = { 119static struct rtable __fake_rtable = {
@@ -224,8 +226,8 @@ static int br_nf_pre_routing_finish_ipv6(struct sk_buff *skb)
224 } 226 }
225 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING; 227 nf_bridge->mask ^= BRNF_NF_BRIDGE_PREROUTING;
226 228
227 skb->dst = (struct dst_entry *)&__fake_rtable; 229 skb->rtable = &__fake_rtable;
228 dst_hold(skb->dst); 230 dst_hold(&__fake_rtable.u.dst);
229 231
230 skb->dev = nf_bridge->physindev; 232 skb->dev = nf_bridge->physindev;
231 nf_bridge_push_encap_header(skb); 233 nf_bridge_push_encap_header(skb);
@@ -389,8 +391,8 @@ bridged_dnat:
389 skb->pkt_type = PACKET_HOST; 391 skb->pkt_type = PACKET_HOST;
390 } 392 }
391 } else { 393 } else {
392 skb->dst = (struct dst_entry *)&__fake_rtable; 394 skb->rtable = &__fake_rtable;
393 dst_hold(skb->dst); 395 dst_hold(&__fake_rtable.u.dst);
394 } 396 }
395 397
396 skb->dev = nf_bridge->physindev; 398 skb->dev = nf_bridge->physindev;
@@ -609,9 +611,9 @@ static unsigned int br_nf_local_in(unsigned int hook, struct sk_buff *skb,
609 const struct net_device *out, 611 const struct net_device *out,
610 int (*okfn)(struct sk_buff *)) 612 int (*okfn)(struct sk_buff *))
611{ 613{
612 if (skb->dst == (struct dst_entry *)&__fake_rtable) { 614 if (skb->rtable == &__fake_rtable) {
613 dst_release(skb->dst); 615 dst_release(&__fake_rtable.u.dst);
614 skb->dst = NULL; 616 skb->rtable = NULL;
615 } 617 }
616 618
617 return NF_ACCEPT; 619 return NF_ACCEPT;
diff --git a/net/bridge/br_netlink.c b/net/bridge/br_netlink.c
index f5d69336d97b..f155e6ce8a21 100644
--- a/net/bridge/br_netlink.c
+++ b/net/bridge/br_netlink.c
@@ -108,7 +108,7 @@ errout:
108 */ 108 */
109static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb) 109static int br_dump_ifinfo(struct sk_buff *skb, struct netlink_callback *cb)
110{ 110{
111 struct net *net = skb->sk->sk_net; 111 struct net *net = sock_net(skb->sk);
112 struct net_device *dev; 112 struct net_device *dev;
113 int idx; 113 int idx;
114 114
@@ -140,7 +140,7 @@ skip:
140 */ 140 */
141static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg) 141static int br_rtm_setlink(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg)
142{ 142{
143 struct net *net = skb->sk->sk_net; 143 struct net *net = sock_net(skb->sk);
144 struct ifinfomsg *ifm; 144 struct ifinfomsg *ifm;
145 struct nlattr *protinfo; 145 struct nlattr *protinfo;
146 struct net_device *dev; 146 struct net_device *dev;
diff --git a/net/bridge/br_notify.c b/net/bridge/br_notify.c
index 07ac3ae68d8f..00644a544e3c 100644
--- a/net/bridge/br_notify.c
+++ b/net/bridge/br_notify.c
@@ -37,7 +37,7 @@ static int br_device_event(struct notifier_block *unused, unsigned long event, v
37 struct net_bridge_port *p = dev->br_port; 37 struct net_bridge_port *p = dev->br_port;
38 struct net_bridge *br; 38 struct net_bridge *br;
39 39
40 if (dev->nd_net != &init_net) 40 if (dev_net(dev) != &init_net)
41 return NOTIFY_DONE; 41 return NOTIFY_DONE;
42 42
43 /* not a port of a bridge */ 43 /* not a port of a bridge */
diff --git a/net/bridge/br_stp_bpdu.c b/net/bridge/br_stp_bpdu.c
index 0edbd2a1c3f3..8deab645ef75 100644
--- a/net/bridge/br_stp_bpdu.c
+++ b/net/bridge/br_stp_bpdu.c
@@ -142,7 +142,7 @@ int br_stp_rcv(struct sk_buff *skb, struct net_device *dev,
142 struct net_bridge *br; 142 struct net_bridge *br;
143 const unsigned char *buf; 143 const unsigned char *buf;
144 144
145 if (dev->nd_net != &init_net) 145 if (dev_net(dev) != &init_net)
146 goto err; 146 goto err;
147 147
148 if (!p) 148 if (!p)
diff --git a/net/bridge/br_sysfs_br.c b/net/bridge/br_sysfs_br.c
index 9cf0538d1717..27d6a511c8c1 100644
--- a/net/bridge/br_sysfs_br.c
+++ b/net/bridge/br_sysfs_br.c
@@ -415,21 +415,21 @@ int br_sysfs_addbr(struct net_device *dev)
415 err = sysfs_create_group(brobj, &bridge_group); 415 err = sysfs_create_group(brobj, &bridge_group);
416 if (err) { 416 if (err) {
417 pr_info("%s: can't create group %s/%s\n", 417 pr_info("%s: can't create group %s/%s\n",
418 __FUNCTION__, dev->name, bridge_group.name); 418 __func__, dev->name, bridge_group.name);
419 goto out1; 419 goto out1;
420 } 420 }
421 421
422 err = sysfs_create_bin_file(brobj, &bridge_forward); 422 err = sysfs_create_bin_file(brobj, &bridge_forward);
423 if (err) { 423 if (err) {
424 pr_info("%s: can't create attribute file %s/%s\n", 424 pr_info("%s: can't create attribute file %s/%s\n",
425 __FUNCTION__, dev->name, bridge_forward.attr.name); 425 __func__, dev->name, bridge_forward.attr.name);
426 goto out2; 426 goto out2;
427 } 427 }
428 428
429 br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj); 429 br->ifobj = kobject_create_and_add(SYSFS_BRIDGE_PORT_SUBDIR, brobj);
430 if (!br->ifobj) { 430 if (!br->ifobj) {
431 pr_info("%s: can't add kobject (directory) %s/%s\n", 431 pr_info("%s: can't add kobject (directory) %s/%s\n",
432 __FUNCTION__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR); 432 __func__, dev->name, SYSFS_BRIDGE_PORT_SUBDIR);
433 goto out3; 433 goto out3;
434 } 434 }
435 return 0; 435 return 0;
diff --git a/net/bridge/netfilter/Kconfig b/net/bridge/netfilter/Kconfig
index 4a3e2bf892c7..7beeefa0f9c0 100644
--- a/net/bridge/netfilter/Kconfig
+++ b/net/bridge/netfilter/Kconfig
@@ -212,4 +212,18 @@ config BRIDGE_EBT_ULOG
212 212
213 To compile it as a module, choose M here. If unsure, say N. 213 To compile it as a module, choose M here. If unsure, say N.
214 214
215config BRIDGE_EBT_NFLOG
216 tristate "ebt: nflog support"
217 depends on BRIDGE_NF_EBTABLES
218 help
219 This option enables the nflog watcher, which allows to LOG
220 messages through the netfilter logging API, which can use
221 either the old LOG target, the old ULOG target or nfnetlink_log
222 as backend.
223
224 This option adds the ulog watcher, that you can use in any rule
225 in any ebtables table.
226
227 To compile it as a module, choose M here. If unsure, say N.
228
215endmenu 229endmenu
diff --git a/net/bridge/netfilter/Makefile b/net/bridge/netfilter/Makefile
index 905087e0d485..83715d73a503 100644
--- a/net/bridge/netfilter/Makefile
+++ b/net/bridge/netfilter/Makefile
@@ -30,3 +30,4 @@ obj-$(CONFIG_BRIDGE_EBT_SNAT) += ebt_snat.o
30# watchers 30# watchers
31obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o 31obj-$(CONFIG_BRIDGE_EBT_LOG) += ebt_log.o
32obj-$(CONFIG_BRIDGE_EBT_ULOG) += ebt_ulog.o 32obj-$(CONFIG_BRIDGE_EBT_ULOG) += ebt_ulog.o
33obj-$(CONFIG_BRIDGE_EBT_NFLOG) += ebt_nflog.o
diff --git a/net/bridge/netfilter/ebt_nflog.c b/net/bridge/netfilter/ebt_nflog.c
new file mode 100644
index 000000000000..8e799aa9e560
--- /dev/null
+++ b/net/bridge/netfilter/ebt_nflog.c
@@ -0,0 +1,74 @@
1/*
2 * ebt_nflog
3 *
4 * Author:
5 * Peter Warasin <peter@endian.com>
6 *
7 * February, 2008
8 *
9 * Based on:
10 * xt_NFLOG.c, (C) 2006 by Patrick McHardy <kaber@trash.net>
11 * ebt_ulog.c, (C) 2004 by Bart De Schuymer <bdschuym@pandora.be>
12 *
13 */
14
15#include <linux/module.h>
16#include <linux/spinlock.h>
17#include <linux/netfilter_bridge/ebtables.h>
18#include <linux/netfilter_bridge/ebt_nflog.h>
19#include <net/netfilter/nf_log.h>
20
21static void ebt_nflog(const struct sk_buff *skb,
22 unsigned int hooknr,
23 const struct net_device *in,
24 const struct net_device *out,
25 const void *data, unsigned int datalen)
26{
27 struct ebt_nflog_info *info = (struct ebt_nflog_info *)data;
28 struct nf_loginfo li;
29
30 li.type = NF_LOG_TYPE_ULOG;
31 li.u.ulog.copy_len = info->len;
32 li.u.ulog.group = info->group;
33 li.u.ulog.qthreshold = info->threshold;
34
35 nf_log_packet(PF_BRIDGE, hooknr, skb, in, out, &li, "%s", info->prefix);
36}
37
38static int ebt_nflog_check(const char *tablename,
39 unsigned int hookmask,
40 const struct ebt_entry *e,
41 void *data, unsigned int datalen)
42{
43 struct ebt_nflog_info *info = (struct ebt_nflog_info *)data;
44
45 if (datalen != EBT_ALIGN(sizeof(struct ebt_nflog_info)))
46 return -EINVAL;
47 if (info->flags & ~EBT_NFLOG_MASK)
48 return -EINVAL;
49 info->prefix[EBT_NFLOG_PREFIX_SIZE - 1] = '\0';
50 return 0;
51}
52
53static struct ebt_watcher nflog __read_mostly = {
54 .name = EBT_NFLOG_WATCHER,
55 .watcher = ebt_nflog,
56 .check = ebt_nflog_check,
57 .me = THIS_MODULE,
58};
59
60static int __init ebt_nflog_init(void)
61{
62 return ebt_register_watcher(&nflog);
63}
64
65static void __exit ebt_nflog_fini(void)
66{
67 ebt_unregister_watcher(&nflog);
68}
69
70module_init(ebt_nflog_init);
71module_exit(ebt_nflog_fini);
72MODULE_LICENSE("GPL");
73MODULE_AUTHOR("Peter Warasin <peter@endian.com>");
74MODULE_DESCRIPTION("ebtables NFLOG netfilter logging module");
diff --git a/net/bridge/netfilter/ebtable_broute.c b/net/bridge/netfilter/ebtable_broute.c
index be6f18681053..246626bb0c87 100644
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -46,7 +46,7 @@ static struct ebt_table broute_table =
46 .name = "broute", 46 .name = "broute",
47 .table = &initial_table, 47 .table = &initial_table,
48 .valid_hooks = 1 << NF_BR_BROUTING, 48 .valid_hooks = 1 << NF_BR_BROUTING,
49 .lock = RW_LOCK_UNLOCKED, 49 .lock = __RW_LOCK_UNLOCKED(broute_table.lock),
50 .check = check, 50 .check = check,
51 .me = THIS_MODULE, 51 .me = THIS_MODULE,
52}; 52};
diff --git a/net/bridge/netfilter/ebtable_filter.c b/net/bridge/netfilter/ebtable_filter.c
index fb810908732f..690bc3ab186c 100644
--- a/net/bridge/netfilter/ebtable_filter.c
+++ b/net/bridge/netfilter/ebtable_filter.c
@@ -55,7 +55,7 @@ static struct ebt_table frame_filter =
55 .name = "filter", 55 .name = "filter",
56 .table = &initial_table, 56 .table = &initial_table,
57 .valid_hooks = FILTER_VALID_HOOKS, 57 .valid_hooks = FILTER_VALID_HOOKS,
58 .lock = RW_LOCK_UNLOCKED, 58 .lock = __RW_LOCK_UNLOCKED(frame_filter.lock),
59 .check = check, 59 .check = check,
60 .me = THIS_MODULE, 60 .me = THIS_MODULE,
61}; 61};
diff --git a/net/bridge/netfilter/ebtable_nat.c b/net/bridge/netfilter/ebtable_nat.c
index bc712730c54a..5b495fe2d0b6 100644
--- a/net/bridge/netfilter/ebtable_nat.c
+++ b/net/bridge/netfilter/ebtable_nat.c
@@ -55,7 +55,7 @@ static struct ebt_table frame_nat =
55 .name = "nat", 55 .name = "nat",
56 .table = &initial_table, 56 .table = &initial_table,
57 .valid_hooks = NAT_VALID_HOOKS, 57 .valid_hooks = NAT_VALID_HOOKS,
58 .lock = RW_LOCK_UNLOCKED, 58 .lock = __RW_LOCK_UNLOCKED(frame_nat.lock),
59 .check = check, 59 .check = check,
60 .me = THIS_MODULE, 60 .me = THIS_MODULE,
61}; 61};