From: adobriyan@gmail.com
To: shemminger@linux-foundation.org, netdev@vger.kernel.org,
containers@lists.linux-foundation.org, kaber@trash.net
Subject: [PATCH 3/6] netns brnetfilter: per-netns broute table
Date: Fri, 22 Aug 2008 02:21:47 +0400 [thread overview]
Message-ID: <20080821222147.GQ31136@x200.localdomain> (raw)
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
include/net/netns/bridge.h | 1
net/bridge/netfilter/ebtable_broute.c | 36 +++++++++++++++++++++++++---------
2 files changed, 28 insertions(+), 9 deletions(-)
--- a/include/net/netns/bridge.h
+++ b/include/net/netns/bridge.h
@@ -5,5 +5,6 @@
struct netns_br {
struct list_head ebt_tables;
+ struct ebt_table *broute_table;
};
#endif
--- a/net/bridge/netfilter/ebtable_broute.c
+++ b/net/bridge/netfilter/ebtable_broute.c
@@ -41,33 +41,52 @@ static int check(const struct ebt_table_info *info, unsigned int valid_hooks)
return 0;
}
-static struct ebt_table __broute_table =
+static struct ebt_table broute_table =
{
.name = "broute",
.table = &initial_table,
.valid_hooks = 1 << NF_BR_BROUTING,
- .lock = __RW_LOCK_UNLOCKED(__broute_table.lock),
+ .lock = __RW_LOCK_UNLOCKED(broute_table.lock),
.check = check,
.me = THIS_MODULE,
};
-static struct ebt_table *broute_table;
static int ebt_broute(struct sk_buff *skb)
{
int ret;
ret = ebt_do_table(NF_BR_BROUTING, skb, skb->dev, NULL,
- broute_table);
+ dev_net(skb->dev)->br.broute_table);
if (ret == NF_DROP)
return 1; /* route it */
return 0; /* bridge it */
}
+static int ebtable_broute_net_init(struct net *net)
+{
+ net->br.broute_table = ebt_register_table(net, &broute_table);
+ if (IS_ERR(net->br.broute_table))
+ return PTR_ERR(net->br.broute_table);
+ return 0;
+}
+
+static void ebtable_broute_net_exit(struct net *net)
+{
+ ebt_unregister_table(net->br.broute_table);
+}
+
+static struct pernet_operations ebtable_broute_net_ops = {
+ .init = ebtable_broute_net_init,
+ .exit = ebtable_broute_net_exit,
+};
+
static int __init ebtable_broute_init(void)
{
- broute_table = ebt_register_table(&init_net, &__broute_table);
- if (IS_ERR(broute_table))
- return PTR_ERR(broute_table);
+ int ret;
+
+ ret = register_pernet_subsys(&ebtable_broute_net_ops);
+ if (ret < 0)
+ return ret;
/* see br_input.c */
rcu_assign_pointer(br_should_route_hook, ebt_broute);
return 0;
@@ -77,7 +96,7 @@ static void __exit ebtable_broute_fini(void)
{
rcu_assign_pointer(br_should_route_hook, NULL);
synchronize_net();
- ebt_unregister_table(broute_table);
+ unregister_pernet_subsys(&ebtable_broute_net_ops);
}
module_init(ebtable_broute_init);
--
1.5.6.3
reply other threads:[~2008-08-21 22:20 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080821222147.GQ31136@x200.localdomain \
--to=adobriyan@gmail.com \
--cc=containers@lists.linux-foundation.org \
--cc=kaber@trash.net \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox