[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1434554932-4552-37-git-send-email-ebiederm@xmission.com>
Date: Wed, 17 Jun 2015 10:28:46 -0500
From: "Eric W. Biederman" <ebiederm@...ssion.com>
To: David Miller <davem@...emloft.net>
Cc: <netdev@...r.kernel.org>, netfilter-devel@...r.kernel.org,
Stephen Hemminger <stephen@...workplumber.org>,
Juanjo Ciarlante <jjciarla@...z.uncu.edu.ar>,
Wensong Zhang <wensong@...ux-vs.org>,
Simon Horman <horms@...ge.net.au>,
Julian Anastasov <ja@....bg>,
Pablo Neira Ayuso <pablo@...filter.org>,
Patrick McHardy <kaber@...sh.net>,
Jozsef Kadlecsik <kadlec@...ckhole.kfki.hu>,
Jamal Hadi Salim <jhs@...atatu.com>,
Steffen Klassert <steffen.klassert@...unet.com>,
Herbert Xu <herbert@...dor.apana.org.au>
Subject: [PATCH net-next 37/43] netfilter: nf_defrag: Register netfilter hooks in all network namespaces
From: Eric W Biederman <ebiederm@...ssion.com>
Signed-off-by: "Eric W. Biederman" <ebiederm@...ssion.com>
---
net/ipv4/netfilter/nf_defrag_ipv4.c | 21 ++++++++++++++++++---
net/ipv6/netfilter/nf_defrag_ipv6_hooks.c | 21 ++++++++++++++++++---
2 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/net/ipv4/netfilter/nf_defrag_ipv4.c b/net/ipv4/netfilter/nf_defrag_ipv4.c
index e9f4088d4759..8d5a45ddf9b5 100644
--- a/net/ipv4/netfilter/nf_defrag_ipv4.c
+++ b/net/ipv4/netfilter/nf_defrag_ipv4.c
@@ -109,15 +109,30 @@ static struct nf_hook_ops ipv4_defrag_ops[] = {
},
};
-static int __init nf_defrag_init(void)
+static int __net_init nf_defrag_net_init(struct net *net)
{
- return nf_register_hooks(&init_net, ipv4_defrag_ops,
+ return nf_register_hooks(net, ipv4_defrag_ops,
ARRAY_SIZE(ipv4_defrag_ops));
}
+static void __net_exit nf_defrag_net_exit(struct net *net)
+{
+ nf_unregister_hooks(net, ipv4_defrag_ops, ARRAY_SIZE(ipv4_defrag_ops));
+}
+
+static struct pernet_operations nf_defrag_net_ops = {
+ .init = nf_defrag_net_init,
+ .exit = nf_defrag_net_exit,
+};
+
+static int __init nf_defrag_init(void)
+{
+ return register_pernet_subsys(&nf_defrag_net_ops);
+}
+
static void __exit nf_defrag_fini(void)
{
- nf_unregister_hooks(&init_net, ipv4_defrag_ops, ARRAY_SIZE(ipv4_defrag_ops));
+ unregister_pernet_subsys(&nf_defrag_net_ops);
}
void nf_defrag_ipv4_enable(void)
diff --git a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
index 2bd7aa696382..a20d461fbd89 100644
--- a/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
+++ b/net/ipv6/netfilter/nf_defrag_ipv6_hooks.c
@@ -100,6 +100,22 @@ static struct nf_hook_ops ipv6_defrag_ops[] = {
},
};
+static int __net_init nf_defrag_net_init(struct net *net)
+{
+ return nf_register_hooks(net, ipv6_defrag_ops,
+ ARRAY_SIZE(ipv6_defrag_ops));
+}
+
+static void __net_exit nf_defrag_net_exit(struct net *net)
+{
+ nf_unregister_hooks(net, ipv6_defrag_ops, ARRAY_SIZE(ipv6_defrag_ops));
+}
+
+static struct pernet_operations nf_defrag_net_ops = {
+ .init = nf_defrag_net_init,
+ .exit = nf_defrag_net_exit,
+};
+
static int __init nf_defrag_init(void)
{
int ret = 0;
@@ -109,8 +125,7 @@ static int __init nf_defrag_init(void)
pr_err("nf_defrag_ipv6: can't initialize frag6.\n");
return ret;
}
- ret = nf_register_hooks(&init_net, ipv6_defrag_ops,
- ARRAY_SIZE(ipv6_defrag_ops));
+ ret = register_pernet_subsys(&nf_defrag_net_ops);
if (ret < 0) {
pr_err("nf_defrag_ipv6: can't register hooks\n");
goto cleanup_frag6;
@@ -125,7 +140,7 @@ cleanup_frag6:
static void __exit nf_defrag_fini(void)
{
- nf_unregister_hooks(&init_net, ipv6_defrag_ops, ARRAY_SIZE(ipv6_defrag_ops));
+ unregister_pernet_subsys(&nf_defrag_net_ops);
nf_ct_frag6_cleanup();
}
--
2.2.1
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists