aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/pppol2tp.c
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-11-29 10:46:11 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-01 19:15:57 -0500
commitaaab3405e03e91d0e8d30c9d327a2265a7121854 (patch)
tree6fcf9b779b0b5773ceefe1f494cbc62e1f31407b /drivers/net/pppol2tp.c
parentc879a6fcd6382415015e246b443dc2a1eab604dc (diff)
net: Simplify pppol2tp 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 'drivers/net/pppol2tp.c')
-rw-r--r--drivers/net/pppol2tp.c36
1 files changed, 7 insertions, 29 deletions
diff --git a/drivers/net/pppol2tp.c b/drivers/net/pppol2tp.c
index c58b50f8ba3b..9fbb2eba9a06 100644
--- a/drivers/net/pppol2tp.c
+++ b/drivers/net/pppol2tp.c
@@ -2605,53 +2605,31 @@ static struct pppox_proto pppol2tp_proto = {
2605 2605
2606static __net_init int pppol2tp_init_net(struct net *net) 2606static __net_init int pppol2tp_init_net(struct net *net)
2607{ 2607{
2608 struct pppol2tp_net *pn; 2608 struct pppol2tp_net *pn = pppol2tp_pernet(net);
2609 struct proc_dir_entry *pde; 2609 struct proc_dir_entry *pde;
2610 int err;
2611
2612 pn = kzalloc(sizeof(*pn), GFP_KERNEL);
2613 if (!pn)
2614 return -ENOMEM;
2615 2610
2616 INIT_LIST_HEAD(&pn->pppol2tp_tunnel_list); 2611 INIT_LIST_HEAD(&pn->pppol2tp_tunnel_list);
2617 rwlock_init(&pn->pppol2tp_tunnel_list_lock); 2612 rwlock_init(&pn->pppol2tp_tunnel_list_lock);
2618 2613
2619 err = net_assign_generic(net, pppol2tp_net_id, pn);
2620 if (err)
2621 goto out;
2622
2623 pde = proc_net_fops_create(net, "pppol2tp", S_IRUGO, &pppol2tp_proc_fops); 2614 pde = proc_net_fops_create(net, "pppol2tp", S_IRUGO, &pppol2tp_proc_fops);
2624#ifdef CONFIG_PROC_FS 2615#ifdef CONFIG_PROC_FS
2625 if (!pde) { 2616 if (!pde)
2626 err = -ENOMEM; 2617 return -ENOMEM;
2627 goto out;
2628 }
2629#endif 2618#endif
2630 2619
2631 return 0; 2620 return 0;
2632
2633out:
2634 kfree(pn);
2635 return err;
2636} 2621}
2637 2622
2638static __net_exit void pppol2tp_exit_net(struct net *net) 2623static __net_exit void pppol2tp_exit_net(struct net *net)
2639{ 2624{
2640 struct pppoe_net *pn;
2641
2642 proc_net_remove(net, "pppol2tp"); 2625 proc_net_remove(net, "pppol2tp");
2643 pn = net_generic(net, pppol2tp_net_id);
2644 /*
2645 * if someone has cached our net then
2646 * further net_generic call will return NULL
2647 */
2648 net_assign_generic(net, pppol2tp_net_id, NULL);
2649 kfree(pn);
2650} 2626}
2651 2627
2652static struct pernet_operations pppol2tp_net_ops = { 2628static struct pernet_operations pppol2tp_net_ops = {
2653 .init = pppol2tp_init_net, 2629 .init = pppol2tp_init_net,
2654 .exit = pppol2tp_exit_net, 2630 .exit = pppol2tp_exit_net,
2631 .id = &pppol2tp_net_id,
2632 .size = sizeof(struct pppol2tp_net),
2655}; 2633};
2656 2634
2657static int __init pppol2tp_init(void) 2635static int __init pppol2tp_init(void)
@@ -2665,7 +2643,7 @@ static int __init pppol2tp_init(void)
2665 if (err) 2643 if (err)
2666 goto out_unregister_pppol2tp_proto; 2644 goto out_unregister_pppol2tp_proto;
2667 2645
2668 err = register_pernet_gen_device(&pppol2tp_net_id, &pppol2tp_net_ops); 2646 err = register_pernet_device(&pppol2tp_net_ops);
2669 if (err) 2647 if (err)
2670 goto out_unregister_pppox_proto; 2648 goto out_unregister_pppox_proto;
2671 2649
@@ -2684,7 +2662,7 @@ out_unregister_pppol2tp_proto:
2684static void __exit pppol2tp_exit(void) 2662static void __exit pppol2tp_exit(void)
2685{ 2663{
2686 unregister_pppox_proto(PX_PROTO_OL2TP); 2664 unregister_pppox_proto(PX_PROTO_OL2TP);
2687 unregister_pernet_gen_device(pppol2tp_net_id, &pppol2tp_net_ops); 2665 unregister_pernet_device(&pppol2tp_net_ops);
2688 proto_unregister(&pppol2tp_sk_proto); 2666 proto_unregister(&pppol2tp_sk_proto);
2689} 2667}
2690 2668