Commit aaab3405e03e91d0e8d30c9d327a2265a7121854
Committed by
David S. Miller
1 parent
c879a6fcd6
Exists in
master
and in
7 other branches
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>
Showing 1 changed file with 7 additions and 29 deletions Side-by-side Diff
drivers/net/pppol2tp.c
... | ... | @@ -2605,53 +2605,31 @@ |
2605 | 2605 | |
2606 | 2606 | static __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 | 2609 | struct proc_dir_entry *pde; |
2610 | - int err; | |
2611 | 2610 | |
2612 | - pn = kzalloc(sizeof(*pn), GFP_KERNEL); | |
2613 | - if (!pn) | |
2614 | - return -ENOMEM; | |
2615 | - | |
2616 | 2611 | INIT_LIST_HEAD(&pn->pppol2tp_tunnel_list); |
2617 | 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 | 2614 | pde = proc_net_fops_create(net, "pppol2tp", S_IRUGO, &pppol2tp_proc_fops); |
2624 | 2615 | #ifdef CONFIG_PROC_FS |
2625 | - if (!pde) { | |
2626 | - err = -ENOMEM; | |
2627 | - goto out; | |
2628 | - } | |
2616 | + if (!pde) | |
2617 | + return -ENOMEM; | |
2629 | 2618 | #endif |
2630 | 2619 | |
2631 | 2620 | return 0; |
2632 | - | |
2633 | -out: | |
2634 | - kfree(pn); | |
2635 | - return err; | |
2636 | 2621 | } |
2637 | 2622 | |
2638 | 2623 | static __net_exit void pppol2tp_exit_net(struct net *net) |
2639 | 2624 | { |
2640 | - struct pppoe_net *pn; | |
2641 | - | |
2642 | 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 | |
2652 | 2628 | static struct pernet_operations pppol2tp_net_ops = { |
2653 | 2629 | .init = pppol2tp_init_net, |
2654 | 2630 | .exit = pppol2tp_exit_net, |
2631 | + .id = &pppol2tp_net_id, | |
2632 | + .size = sizeof(struct pppol2tp_net), | |
2655 | 2633 | }; |
2656 | 2634 | |
2657 | 2635 | static int __init pppol2tp_init(void) |
... | ... | @@ -2665,7 +2643,7 @@ |
2665 | 2643 | if (err) |
2666 | 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 | 2647 | if (err) |
2670 | 2648 | goto out_unregister_pppox_proto; |
2671 | 2649 | |
... | ... | @@ -2684,7 +2662,7 @@ |
2684 | 2662 | static void __exit pppol2tp_exit(void) |
2685 | 2663 | { |
2686 | 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 | 2666 | proto_unregister(&pppol2tp_sk_proto); |
2689 | 2667 | } |
2690 | 2668 |