summaryrefslogtreecommitdiffstats
path: root/net/xfrm/xfrm_policy.c
diff options
context:
space:
mode:
authorAlexey Dobriyan <adobriyan@gmail.com>2008-11-25 17:14:31 -0800
committerDavid S. Miller <davem@davemloft.net>2008-11-25 17:14:31 -0800
commitd62ddc21b674b5ac1466091ff3fbf7baa53bc92c (patch)
tree13e57abe023b5258b168e7f9108015a78493e481 /net/xfrm/xfrm_policy.c
parentc95839693d2a6612af7f75ad877012eba2f69757 (diff)
downloadop-kernel-dev-d62ddc21b674b5ac1466091ff3fbf7baa53bc92c.zip
op-kernel-dev-d62ddc21b674b5ac1466091ff3fbf7baa53bc92c.tar.gz
netns xfrm: add netns boilerplate
Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/xfrm/xfrm_policy.c')
-rw-r--r--net/xfrm/xfrm_policy.c45
1 files changed, 40 insertions, 5 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c
index ea3456d..8e7671b 100644
--- a/net/xfrm/xfrm_policy.c
+++ b/net/xfrm/xfrm_policy.c
@@ -2394,12 +2394,13 @@ static int __init xfrm_statistics_init(void)
}
#endif
-static void __init xfrm_policy_init(void)
+static int __net_init xfrm_policy_init(struct net *net)
{
unsigned int hmask, sz;
int dir;
- xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache",
+ if (net_eq(net, &init_net))
+ xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache",
sizeof(struct xfrm_dst),
0, SLAB_HWCACHE_ALIGN|SLAB_PANIC,
NULL);
@@ -2425,16 +2426,50 @@ static void __init xfrm_policy_init(void)
}
INIT_LIST_HEAD(&xfrm_policy_all);
- register_netdevice_notifier(&xfrm_dev_notifier);
+ if (net_eq(net, &init_net))
+ register_netdevice_notifier(&xfrm_dev_notifier);
+ return 0;
+}
+
+static void xfrm_policy_fini(struct net *net)
+{
}
+static int __net_init xfrm_net_init(struct net *net)
+{
+ int rv;
+
+ rv = xfrm_state_init(net);
+ if (rv < 0)
+ goto out_state;
+ rv = xfrm_policy_init(net);
+ if (rv < 0)
+ goto out_policy;
+ return 0;
+
+out_policy:
+ xfrm_state_fini(net);
+out_state:
+ return rv;
+}
+
+static void __net_exit xfrm_net_exit(struct net *net)
+{
+ xfrm_policy_fini(net);
+ xfrm_state_fini(net);
+}
+
+static struct pernet_operations __net_initdata xfrm_net_ops = {
+ .init = xfrm_net_init,
+ .exit = xfrm_net_exit,
+};
+
void __init xfrm_init(void)
{
+ register_pernet_subsys(&xfrm_net_ops);
#ifdef CONFIG_XFRM_STATISTICS
xfrm_statistics_init();
#endif
- xfrm_state_init();
- xfrm_policy_init();
xfrm_input_init();
#ifdef CONFIG_XFRM_STATISTICS
xfrm_proc_init();
OpenPOWER on IntegriCloud