aboutsummaryrefslogtreecommitdiffstats
path: root/net/8021q
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2009-11-29 10:46:05 -0500
committerDavid S. Miller <davem@davemloft.net>2009-12-01 19:15:53 -0500
commit946d1a9298c9e592b189a168326603c92d782b5f (patch)
tree170e0e7410172146c99068ed17159a80c9d02f94 /net/8021q
parent15449745e5d181ae214ceaf0880350bb4e63512a (diff)
net: Simplify vlan 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/8021q')
-rw-r--r--net/8021q/vlan.c33
1 files changed, 7 insertions, 26 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index 225aa2fac0e3..91e9073e1995 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -686,47 +686,28 @@ out:
686 686
687static int vlan_init_net(struct net *net) 687static int vlan_init_net(struct net *net)
688{ 688{
689 struct vlan_net *vn = net_generic(net, vlan_net_id);
689 int err; 690 int err;
690 struct vlan_net *vn;
691
692 err = -ENOMEM;
693 vn = kzalloc(sizeof(struct vlan_net), GFP_KERNEL);
694 if (vn == NULL)
695 goto err_alloc;
696
697 err = net_assign_generic(net, vlan_net_id, vn);
698 if (err < 0)
699 goto err_assign;
700 691
701 vn->name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; 692 vn->name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
702 693
703 err = vlan_proc_init(net); 694 err = vlan_proc_init(net);
704 if (err < 0)
705 goto err_proc;
706 695
707 return 0;
708
709err_proc:
710 /* nothing */
711err_assign:
712 kfree(vn);
713err_alloc:
714 return err; 696 return err;
715} 697}
716 698
717static void vlan_exit_net(struct net *net) 699static void vlan_exit_net(struct net *net)
718{ 700{
719 struct vlan_net *vn;
720
721 vn = net_generic(net, vlan_net_id);
722 rtnl_kill_links(net, &vlan_link_ops); 701 rtnl_kill_links(net, &vlan_link_ops);
702
723 vlan_proc_cleanup(net); 703 vlan_proc_cleanup(net);
724 kfree(vn);
725} 704}
726 705
727static struct pernet_operations vlan_net_ops = { 706static struct pernet_operations vlan_net_ops = {
728 .init = vlan_init_net, 707 .init = vlan_init_net,
729 .exit = vlan_exit_net, 708 .exit = vlan_exit_net,
709 .id = &vlan_net_id,
710 .size = sizeof(struct vlan_net),
730}; 711};
731 712
732static int __init vlan_proto_init(void) 713static int __init vlan_proto_init(void)
@@ -736,7 +717,7 @@ static int __init vlan_proto_init(void)
736 pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright); 717 pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
737 pr_info("All bugs added by %s\n", vlan_buggyright); 718 pr_info("All bugs added by %s\n", vlan_buggyright);
738 719
739 err = register_pernet_gen_device(&vlan_net_id, &vlan_net_ops); 720 err = register_pernet_device(&vlan_net_ops);
740 if (err < 0) 721 if (err < 0)
741 goto err0; 722 goto err0;
742 723
@@ -761,7 +742,7 @@ err4:
761err3: 742err3:
762 unregister_netdevice_notifier(&vlan_notifier_block); 743 unregister_netdevice_notifier(&vlan_notifier_block);
763err2: 744err2:
764 unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops); 745 unregister_pernet_device(&vlan_net_ops);
765err0: 746err0:
766 return err; 747 return err;
767} 748}
@@ -781,7 +762,7 @@ static void __exit vlan_cleanup_module(void)
781 for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) 762 for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
782 BUG_ON(!hlist_empty(&vlan_group_hash[i])); 763 BUG_ON(!hlist_empty(&vlan_group_hash[i]));
783 764
784 unregister_pernet_gen_device(vlan_net_id, &vlan_net_ops); 765 unregister_pernet_device(&vlan_net_ops);
785 rcu_barrier(); /* Wait for completion of call_rcu()'s */ 766 rcu_barrier(); /* Wait for completion of call_rcu()'s */
786 767
787 vlan_gvrp_uninit(); 768 vlan_gvrp_uninit();