Commit 23c049ca92548483d5e12c94cc983afb3040f626

Authored by Eric W. Biederman
Committed by David S. Miller
1 parent 946d1a9298

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>

Showing 1 changed file with 6 additions and 19 deletions Side-by-side Diff

... ... @@ -3765,28 +3765,14 @@
3765 3765  
3766 3766 static 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 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 3771 INIT_HLIST_HEAD(&net_pfkey->table);
3777 3772 atomic_set(&net_pfkey->socks_nr, 0);
3778   - rv = net_assign_generic(net, pfkey_net_id, net_pfkey);
3779   - if (rv < 0)
3780   - goto out_assign;
  3773 +
3781 3774 rv = pfkey_init_proc(net);
3782   - if (rv < 0)
3783   - goto out_proc;
3784   - return 0;
3785 3775  
3786   -out_proc:
3787   -out_assign:
3788   - kfree(net_pfkey);
3789   -out_kmalloc:
3790 3776 return rv;
3791 3777 }
3792 3778  
3793 3779  
3794 3780  
... ... @@ -3796,17 +3782,18 @@
3796 3782  
3797 3783 pfkey_exit_proc(net);
3798 3784 BUG_ON(!hlist_empty(&net_pfkey->table));
3799   - kfree(net_pfkey);
3800 3785 }
3801 3786  
3802 3787 static struct pernet_operations pfkey_net_ops = {
3803 3788 .init = pfkey_net_init,
3804 3789 .exit = pfkey_net_exit,
  3790 + .id = &pfkey_net_id,
  3791 + .size = sizeof(struct netns_pfkey),
3805 3792 };
3806 3793  
3807 3794 static 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 3797 xfrm_unregister_km(&pfkeyv2_mgr);
3811 3798 sock_unregister(PF_KEY);
3812 3799 proto_unregister(&key_proto);
... ... @@ -3825,7 +3812,7 @@
3825 3812 err = xfrm_register_km(&pfkeyv2_mgr);
3826 3813 if (err != 0)
3827 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 3816 if (err != 0)
3830 3817 goto out_xfrm_unregister_km;
3831 3818 out: