diff options
author | David S. Miller <davem@davemloft.net> | 2012-06-09 19:27:05 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2012-06-09 19:27:05 -0400 |
commit | c3426b47190d7c6785230c91a706fd42208b4120 (patch) | |
tree | 5444acfb2ef8a59c46e580cda8101c32fd3c2973 /net/ipv6/route.c | |
parent | 2397849baa7c44c242e5d5142d5d16d1e7ed53d0 (diff) |
inet: Initialize per-netns inetpeer roots in net/ipv{4,6}/route.c
Instead of net/ipv4/inetpeer.c
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ipv6/route.c')
-rw-r--r-- | net/ipv6/route.c | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/net/ipv6/route.c b/net/ipv6/route.c index 8a986be4aeda..3e1e4e0da096 100644 --- a/net/ipv6/route.c +++ b/net/ipv6/route.c | |||
@@ -2996,6 +2996,31 @@ static struct pernet_operations ip6_route_net_ops = { | |||
2996 | .exit = ip6_route_net_exit, | 2996 | .exit = ip6_route_net_exit, |
2997 | }; | 2997 | }; |
2998 | 2998 | ||
2999 | static int __net_init ipv6_inetpeer_init(struct net *net) | ||
3000 | { | ||
3001 | struct inet_peer_base *bp = kmalloc(sizeof(*bp), GFP_KERNEL); | ||
3002 | |||
3003 | if (!bp) | ||
3004 | return -ENOMEM; | ||
3005 | inet_peer_base_init(bp); | ||
3006 | net->ipv6.peers = bp; | ||
3007 | return 0; | ||
3008 | } | ||
3009 | |||
3010 | static void __net_exit ipv6_inetpeer_exit(struct net *net) | ||
3011 | { | ||
3012 | struct inet_peer_base *bp = net->ipv6.peers; | ||
3013 | |||
3014 | net->ipv6.peers = NULL; | ||
3015 | __inetpeer_invalidate_tree(bp); | ||
3016 | kfree(bp); | ||
3017 | } | ||
3018 | |||
3019 | static __net_initdata struct pernet_operations ipv6_inetpeer_ops = { | ||
3020 | .init = ipv6_inetpeer_init, | ||
3021 | .exit = ipv6_inetpeer_exit, | ||
3022 | }; | ||
3023 | |||
2999 | static struct notifier_block ip6_route_dev_notifier = { | 3024 | static struct notifier_block ip6_route_dev_notifier = { |
3000 | .notifier_call = ip6_route_dev_notify, | 3025 | .notifier_call = ip6_route_dev_notify, |
3001 | .priority = 0, | 3026 | .priority = 0, |
@@ -3020,6 +3045,10 @@ int __init ip6_route_init(void) | |||
3020 | if (ret) | 3045 | if (ret) |
3021 | goto out_dst_entries; | 3046 | goto out_dst_entries; |
3022 | 3047 | ||
3048 | ret = register_pernet_subsys(&ipv6_inetpeer_ops); | ||
3049 | if (ret) | ||
3050 | goto out_register_subsys; | ||
3051 | |||
3023 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops_template.kmem_cachep; | 3052 | ip6_dst_blackhole_ops.kmem_cachep = ip6_dst_ops_template.kmem_cachep; |
3024 | 3053 | ||
3025 | /* Registering of the loopback is done before this portion of code, | 3054 | /* Registering of the loopback is done before this portion of code, |
@@ -3035,7 +3064,7 @@ int __init ip6_route_init(void) | |||
3035 | #endif | 3064 | #endif |
3036 | ret = fib6_init(); | 3065 | ret = fib6_init(); |
3037 | if (ret) | 3066 | if (ret) |
3038 | goto out_register_subsys; | 3067 | goto out_register_inetpeer; |
3039 | 3068 | ||
3040 | ret = xfrm6_init(); | 3069 | ret = xfrm6_init(); |
3041 | if (ret) | 3070 | if (ret) |
@@ -3064,6 +3093,8 @@ xfrm6_init: | |||
3064 | xfrm6_fini(); | 3093 | xfrm6_fini(); |
3065 | out_fib6_init: | 3094 | out_fib6_init: |
3066 | fib6_gc_cleanup(); | 3095 | fib6_gc_cleanup(); |
3096 | out_register_inetpeer: | ||
3097 | unregister_pernet_subsys(&ipv6_inetpeer_ops); | ||
3067 | out_register_subsys: | 3098 | out_register_subsys: |
3068 | unregister_pernet_subsys(&ip6_route_net_ops); | 3099 | unregister_pernet_subsys(&ip6_route_net_ops); |
3069 | out_dst_entries: | 3100 | out_dst_entries: |
@@ -3079,6 +3110,7 @@ void ip6_route_cleanup(void) | |||
3079 | fib6_rules_cleanup(); | 3110 | fib6_rules_cleanup(); |
3080 | xfrm6_fini(); | 3111 | xfrm6_fini(); |
3081 | fib6_gc_cleanup(); | 3112 | fib6_gc_cleanup(); |
3113 | unregister_pernet_subsys(&ipv6_inetpeer_ops); | ||
3082 | unregister_pernet_subsys(&ip6_route_net_ops); | 3114 | unregister_pernet_subsys(&ip6_route_net_ops); |
3083 | dst_entries_destroy(&ip6_dst_blackhole_ops); | 3115 | dst_entries_destroy(&ip6_dst_blackhole_ops); |
3084 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); | 3116 | kmem_cache_destroy(ip6_dst_ops_template.kmem_cachep); |