diff options
Diffstat (limited to 'net/xfrm')
-rw-r--r-- | net/xfrm/xfrm_policy.c | 45 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 7 |
2 files changed, 46 insertions, 6 deletions
diff --git a/net/xfrm/xfrm_policy.c b/net/xfrm/xfrm_policy.c index ea3456daa9cb..8e7671b9e76e 100644 --- a/net/xfrm/xfrm_policy.c +++ b/net/xfrm/xfrm_policy.c | |||
@@ -2394,12 +2394,13 @@ static int __init xfrm_statistics_init(void) | |||
2394 | } | 2394 | } |
2395 | #endif | 2395 | #endif |
2396 | 2396 | ||
2397 | static void __init xfrm_policy_init(void) | 2397 | static int __net_init xfrm_policy_init(struct net *net) |
2398 | { | 2398 | { |
2399 | unsigned int hmask, sz; | 2399 | unsigned int hmask, sz; |
2400 | int dir; | 2400 | int dir; |
2401 | 2401 | ||
2402 | xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache", | 2402 | if (net_eq(net, &init_net)) |
2403 | xfrm_dst_cache = kmem_cache_create("xfrm_dst_cache", | ||
2403 | sizeof(struct xfrm_dst), | 2404 | sizeof(struct xfrm_dst), |
2404 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, | 2405 | 0, SLAB_HWCACHE_ALIGN|SLAB_PANIC, |
2405 | NULL); | 2406 | NULL); |
@@ -2425,16 +2426,50 @@ static void __init xfrm_policy_init(void) | |||
2425 | } | 2426 | } |
2426 | 2427 | ||
2427 | INIT_LIST_HEAD(&xfrm_policy_all); | 2428 | INIT_LIST_HEAD(&xfrm_policy_all); |
2428 | register_netdevice_notifier(&xfrm_dev_notifier); | 2429 | if (net_eq(net, &init_net)) |
2430 | register_netdevice_notifier(&xfrm_dev_notifier); | ||
2431 | return 0; | ||
2432 | } | ||
2433 | |||
2434 | static void xfrm_policy_fini(struct net *net) | ||
2435 | { | ||
2429 | } | 2436 | } |
2430 | 2437 | ||
2438 | static int __net_init xfrm_net_init(struct net *net) | ||
2439 | { | ||
2440 | int rv; | ||
2441 | |||
2442 | rv = xfrm_state_init(net); | ||
2443 | if (rv < 0) | ||
2444 | goto out_state; | ||
2445 | rv = xfrm_policy_init(net); | ||
2446 | if (rv < 0) | ||
2447 | goto out_policy; | ||
2448 | return 0; | ||
2449 | |||
2450 | out_policy: | ||
2451 | xfrm_state_fini(net); | ||
2452 | out_state: | ||
2453 | return rv; | ||
2454 | } | ||
2455 | |||
2456 | static void __net_exit xfrm_net_exit(struct net *net) | ||
2457 | { | ||
2458 | xfrm_policy_fini(net); | ||
2459 | xfrm_state_fini(net); | ||
2460 | } | ||
2461 | |||
2462 | static struct pernet_operations __net_initdata xfrm_net_ops = { | ||
2463 | .init = xfrm_net_init, | ||
2464 | .exit = xfrm_net_exit, | ||
2465 | }; | ||
2466 | |||
2431 | void __init xfrm_init(void) | 2467 | void __init xfrm_init(void) |
2432 | { | 2468 | { |
2469 | register_pernet_subsys(&xfrm_net_ops); | ||
2433 | #ifdef CONFIG_XFRM_STATISTICS | 2470 | #ifdef CONFIG_XFRM_STATISTICS |
2434 | xfrm_statistics_init(); | 2471 | xfrm_statistics_init(); |
2435 | #endif | 2472 | #endif |
2436 | xfrm_state_init(); | ||
2437 | xfrm_policy_init(); | ||
2438 | xfrm_input_init(); | 2473 | xfrm_input_init(); |
2439 | #ifdef CONFIG_XFRM_STATISTICS | 2474 | #ifdef CONFIG_XFRM_STATISTICS |
2440 | xfrm_proc_init(); | 2475 | xfrm_proc_init(); |
diff --git a/net/xfrm/xfrm_state.c b/net/xfrm/xfrm_state.c index cd9d9171ded7..268fe3f9e498 100644 --- a/net/xfrm/xfrm_state.c +++ b/net/xfrm/xfrm_state.c | |||
@@ -2080,7 +2080,7 @@ error: | |||
2080 | 2080 | ||
2081 | EXPORT_SYMBOL(xfrm_init_state); | 2081 | EXPORT_SYMBOL(xfrm_init_state); |
2082 | 2082 | ||
2083 | void __init xfrm_state_init(void) | 2083 | int __net_init xfrm_state_init(struct net *net) |
2084 | { | 2084 | { |
2085 | unsigned int sz; | 2085 | unsigned int sz; |
2086 | 2086 | ||
@@ -2094,6 +2094,11 @@ void __init xfrm_state_init(void) | |||
2094 | xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1); | 2094 | xfrm_state_hmask = ((sz / sizeof(struct hlist_head)) - 1); |
2095 | 2095 | ||
2096 | INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task); | 2096 | INIT_WORK(&xfrm_state_gc_work, xfrm_state_gc_task); |
2097 | return 0; | ||
2098 | } | ||
2099 | |||
2100 | void xfrm_state_fini(struct net *net) | ||
2101 | { | ||
2097 | } | 2102 | } |
2098 | 2103 | ||
2099 | #ifdef CONFIG_AUDITSYSCALL | 2104 | #ifdef CONFIG_AUDITSYSCALL |