aboutsummaryrefslogtreecommitdiffstats
path: root/net/key
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-11-29 10:46:06 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-01 19:15:54 -0500
commit23c049ca92548483d5e12c94cc983afb3040f626 (patch)
tree549eceb6f09828f11d8cc8c4ad4cb3fdfbeffb42 /net/key
parent946d1a9298c9e592b189a168326603c92d782b5f (diff)
net: Simplify af_key pernet operations.
Take advantage of the new pernet automatic storage management, and stop using compatibility network namespace functions. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/key')
-rw-r--r--net/key/af_key.c25
1 files changed, 6 insertions, 19 deletions
diff --git a/net/key/af_key.c b/net/key/af_key.c
index 478c8b32a5fb..84209fbbeb17 100644
--- a/net/key/af_key.c
+++ b/net/key/af_key.c
@@ -3765,28 +3765,14 @@ static struct xfrm_mgr pfkeyv2_mgr =
3765 3765
3766static int __net_init pfkey_net_init(struct net *net) 3766static int __net_init pfkey_net_init(struct net *net)
3767{ 3767{
3768 struct netns_pfkey *net_pfkey; 3768 struct netns_pfkey *net_pfkey = net_generic(net, pfkey_net_id);
3769 int rv; 3769 int rv;
3770 3770
3771 net_pfkey = kmalloc(sizeof(struct netns_pfkey), GFP_KERNEL);
3772 if (!net_pfkey) {
3773 rv = -ENOMEM;
3774 goto out_kmalloc;
3775 }
3776 INIT_HLIST_HEAD(&net_pfkey->table); 3771 INIT_HLIST_HEAD(&net_pfkey->table);
3777 atomic_set(&net_pfkey->socks_nr, 0); 3772 atomic_set(&net_pfkey->socks_nr, 0);
3778 rv = net_assign_generic(net, pfkey_net_id, net_pfkey); 3773
3779 if (rv < 0)
3780 goto out_assign;
3781 rv = pfkey_init_proc(net); 3774 rv = pfkey_init_proc(net);
3782 if (rv < 0)
3783 goto out_proc;
3784 return 0;
3785 3775
3786out_proc:
3787out_assign:
3788 kfree(net_pfkey);
3789out_kmalloc:
3790 return rv; 3776 return rv;
3791} 3777}
3792 3778
@@ -3796,17 +3782,18 @@ static void __net_exit pfkey_net_exit(struct net *net)
3796 3782
3797 pfkey_exit_proc(net); 3783 pfkey_exit_proc(net);
3798 BUG_ON(!hlist_empty(&net_pfkey->table)); 3784 BUG_ON(!hlist_empty(&net_pfkey->table));
3799 kfree(net_pfkey);
3800} 3785}
3801 3786
3802static struct pernet_operations pfkey_net_ops = { 3787static struct pernet_operations pfkey_net_ops = {
3803 .init = pfkey_net_init, 3788 .init = pfkey_net_init,
3804 .exit = pfkey_net_exit, 3789 .exit = pfkey_net_exit,
3790 .id = &pfkey_net_id,
3791 .size = sizeof(struct netns_pfkey),
3805}; 3792};
3806 3793
3807static void __exit ipsec_pfkey_exit(void) 3794static void __exit ipsec_pfkey_exit(void)
3808{ 3795{
3809 unregister_pernet_gen_subsys(pfkey_net_id, &pfkey_net_ops); 3796 unregister_pernet_subsys(&pfkey_net_ops);
3810 xfrm_unregister_km(&pfkeyv2_mgr); 3797 xfrm_unregister_km(&pfkeyv2_mgr);
3811 sock_unregister(PF_KEY); 3798 sock_unregister(PF_KEY);
3812 proto_unregister(&key_proto); 3799 proto_unregister(&key_proto);
@@ -3825,7 +3812,7 @@ static int __init ipsec_pfkey_init(void)
3825 err = xfrm_register_km(&pfkeyv2_mgr); 3812 err = xfrm_register_km(&pfkeyv2_mgr);
3826 if (err != 0) 3813 if (err != 0)
3827 goto out_sock_unregister; 3814 goto out_sock_unregister;
3828 err = register_pernet_gen_subsys(&pfkey_net_id, &pfkey_net_ops); 3815 err = register_pernet_subsys(&pfkey_net_ops);
3829 if (err != 0) 3816 if (err != 0)
3830 goto out_xfrm_unregister_km; 3817 goto out_xfrm_unregister_km;
3831out: 3818out: