diff options
-rw-r--r-- | include/net/net_namespace.h | 4 | ||||
-rw-r--r-- | include/net/netns/xfrm.h | 7 | ||||
-rw-r--r-- | include/net/xfrm.h | 3 | ||||
-rw-r--r-- | net/xfrm/xfrm_policy.c | 45 | ||||
-rw-r--r-- | net/xfrm/xfrm_state.c | 7 |
5 files changed, 59 insertions, 7 deletions
diff --git a/include/net/net_namespace.h b/include/net/net_namespace.h index 319557789a40..6fc13d905c5f 100644 --- a/include/net/net_namespace.h +++ b/include/net/net_namespace.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) | 19 | #if defined(CONFIG_NF_CONNTRACK) || defined(CONFIG_NF_CONNTRACK_MODULE) |
20 | #include <net/netns/conntrack.h> | 20 | #include <net/netns/conntrack.h> |
21 | #endif | 21 | #endif |
22 | #include <net/netns/xfrm.h> | ||
22 | 23 | ||
23 | struct proc_dir_entry; | 24 | struct proc_dir_entry; |
24 | struct net_device; | 25 | struct net_device; |
@@ -74,6 +75,9 @@ struct net { | |||
74 | struct netns_ct ct; | 75 | struct netns_ct ct; |
75 | #endif | 76 | #endif |
76 | #endif | 77 | #endif |
78 | #ifdef CONFIG_XFRM | ||
79 | struct netns_xfrm xfrm; | ||
80 | #endif | ||
77 | struct net_generic *gen; | 81 | struct net_generic *gen; |
78 | }; | 82 | }; |
79 | 83 | ||
diff --git a/include/net/netns/xfrm.h b/include/net/netns/xfrm.h new file mode 100644 index 000000000000..1cb0024a3b47 --- /dev/null +++ b/include/net/netns/xfrm.h | |||
@@ -0,0 +1,7 @@ | |||
1 | #ifndef __NETNS_XFRM_H | ||
2 | #define __NETNS_XFRM_H | ||
3 | |||
4 | struct netns_xfrm { | ||
5 | }; | ||
6 | |||
7 | #endif | ||
diff --git a/include/net/xfrm.h b/include/net/xfrm.h index 45e11b3631e4..9107d6f5c297 100644 --- a/include/net/xfrm.h +++ b/include/net/xfrm.h | |||
@@ -1269,7 +1269,8 @@ struct xfrm6_tunnel { | |||
1269 | 1269 | ||
1270 | extern void xfrm_init(void); | 1270 | extern void xfrm_init(void); |
1271 | extern void xfrm4_init(void); | 1271 | extern void xfrm4_init(void); |
1272 | extern void xfrm_state_init(void); | 1272 | extern int xfrm_state_init(struct net *net); |
1273 | extern void xfrm_state_fini(struct net *net); | ||
1273 | extern void xfrm4_state_init(void); | 1274 | extern void xfrm4_state_init(void); |
1274 | #ifdef CONFIG_XFRM | 1275 | #ifdef CONFIG_XFRM |
1275 | extern int xfrm6_init(void); | 1276 | extern int xfrm6_init(void); |
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 |