diff options
| -rw-r--r-- | net/8021q/vlan.c | 141 | ||||
| -rw-r--r-- | net/8021q/vlanproc.c | 21 |
2 files changed, 70 insertions, 92 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 69a9e0207b13..006d9a9bac90 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
| @@ -50,16 +50,6 @@ static char vlan_version[] = DRV_VERSION; | |||
| 50 | static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; | 50 | static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; |
| 51 | static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; | 51 | static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; |
| 52 | 52 | ||
| 53 | static int vlan_device_event(struct notifier_block *, unsigned long, void *); | ||
| 54 | static int vlan_ioctl_handler(struct net *net, void __user *); | ||
| 55 | static int unregister_vlan_dev(struct net_device *, unsigned short ); | ||
| 56 | |||
| 57 | static struct notifier_block vlan_notifier_block = { | ||
| 58 | .notifier_call = vlan_device_event, | ||
| 59 | }; | ||
| 60 | |||
| 61 | /* These may be changed at run-time through IOCTLs */ | ||
| 62 | |||
| 63 | /* Determines interface naming scheme. */ | 53 | /* Determines interface naming scheme. */ |
| 64 | unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; | 54 | unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; |
| 65 | 55 | ||
| @@ -70,79 +60,6 @@ static struct packet_type vlan_packet_type = { | |||
| 70 | 60 | ||
| 71 | /* End of global variables definitions. */ | 61 | /* End of global variables definitions. */ |
| 72 | 62 | ||
| 73 | /* | ||
| 74 | * Function vlan_proto_init (pro) | ||
| 75 | * | ||
| 76 | * Initialize VLAN protocol layer, | ||
| 77 | * | ||
| 78 | */ | ||
| 79 | static int __init vlan_proto_init(void) | ||
| 80 | { | ||
| 81 | int err; | ||
| 82 | |||
| 83 | pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright); | ||
| 84 | pr_info("All bugs added by %s\n", vlan_buggyright); | ||
| 85 | |||
| 86 | /* proc file system initialization */ | ||
| 87 | err = vlan_proc_init(); | ||
| 88 | if (err < 0) { | ||
| 89 | pr_err("%s: can't create entry in proc filesystem!\n", | ||
| 90 | __FUNCTION__); | ||
| 91 | return err; | ||
| 92 | } | ||
| 93 | |||
| 94 | dev_add_pack(&vlan_packet_type); | ||
| 95 | |||
| 96 | /* Register us to receive netdevice events */ | ||
| 97 | err = register_netdevice_notifier(&vlan_notifier_block); | ||
| 98 | if (err < 0) | ||
| 99 | goto err1; | ||
| 100 | |||
| 101 | err = vlan_netlink_init(); | ||
| 102 | if (err < 0) | ||
| 103 | goto err2; | ||
| 104 | |||
| 105 | vlan_ioctl_set(vlan_ioctl_handler); | ||
| 106 | return 0; | ||
| 107 | |||
| 108 | err2: | ||
| 109 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
| 110 | err1: | ||
| 111 | vlan_proc_cleanup(); | ||
| 112 | dev_remove_pack(&vlan_packet_type); | ||
| 113 | return err; | ||
| 114 | } | ||
| 115 | |||
| 116 | /* | ||
| 117 | * Module 'remove' entry point. | ||
| 118 | * o delete /proc/net/router directory and static entries. | ||
| 119 | */ | ||
| 120 | static void __exit vlan_cleanup_module(void) | ||
| 121 | { | ||
| 122 | int i; | ||
| 123 | |||
| 124 | vlan_ioctl_set(NULL); | ||
| 125 | vlan_netlink_fini(); | ||
| 126 | |||
| 127 | /* Un-register us from receiving netdevice events */ | ||
| 128 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
| 129 | |||
| 130 | dev_remove_pack(&vlan_packet_type); | ||
| 131 | |||
| 132 | /* This table must be empty if there are no module | ||
| 133 | * references left. | ||
| 134 | */ | ||
| 135 | for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) { | ||
| 136 | BUG_ON(!hlist_empty(&vlan_group_hash[i])); | ||
| 137 | } | ||
| 138 | vlan_proc_cleanup(); | ||
| 139 | |||
| 140 | synchronize_net(); | ||
| 141 | } | ||
| 142 | |||
| 143 | module_init(vlan_proto_init); | ||
| 144 | module_exit(vlan_cleanup_module); | ||
| 145 | |||
| 146 | /* Must be invoked with RCU read lock (no preempt) */ | 63 | /* Must be invoked with RCU read lock (no preempt) */ |
| 147 | static struct vlan_group *__vlan_find_group(int real_dev_ifindex) | 64 | static struct vlan_group *__vlan_find_group(int real_dev_ifindex) |
| 148 | { | 65 | { |
| @@ -592,6 +509,10 @@ out: | |||
| 592 | return NOTIFY_DONE; | 509 | return NOTIFY_DONE; |
| 593 | } | 510 | } |
| 594 | 511 | ||
| 512 | static struct notifier_block vlan_notifier_block __read_mostly = { | ||
| 513 | .notifier_call = vlan_device_event, | ||
| 514 | }; | ||
| 515 | |||
| 595 | /* | 516 | /* |
| 596 | * VLAN IOCTL handler. | 517 | * VLAN IOCTL handler. |
| 597 | * o execute requested action or pass command to the device driver | 518 | * o execute requested action or pass command to the device driver |
| @@ -716,5 +637,59 @@ out: | |||
| 716 | return err; | 637 | return err; |
| 717 | } | 638 | } |
| 718 | 639 | ||
| 640 | static int __init vlan_proto_init(void) | ||
| 641 | { | ||
| 642 | int err; | ||
| 643 | |||
| 644 | pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright); | ||
| 645 | pr_info("All bugs added by %s\n", vlan_buggyright); | ||
| 646 | |||
| 647 | err = vlan_proc_init(); | ||
| 648 | if (err < 0) | ||
| 649 | goto err1; | ||
| 650 | |||
| 651 | err = register_netdevice_notifier(&vlan_notifier_block); | ||
| 652 | if (err < 0) | ||
| 653 | goto err2; | ||
| 654 | |||
| 655 | err = vlan_netlink_init(); | ||
| 656 | if (err < 0) | ||
| 657 | goto err3; | ||
| 658 | |||
| 659 | dev_add_pack(&vlan_packet_type); | ||
| 660 | vlan_ioctl_set(vlan_ioctl_handler); | ||
| 661 | return 0; | ||
| 662 | |||
| 663 | err3: | ||
| 664 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
| 665 | err2: | ||
| 666 | vlan_proc_cleanup(); | ||
| 667 | err1: | ||
| 668 | return err; | ||
| 669 | } | ||
| 670 | |||
| 671 | static void __exit vlan_cleanup_module(void) | ||
| 672 | { | ||
| 673 | unsigned int i; | ||
| 674 | |||
| 675 | vlan_ioctl_set(NULL); | ||
| 676 | vlan_netlink_fini(); | ||
| 677 | |||
| 678 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
| 679 | |||
| 680 | dev_remove_pack(&vlan_packet_type); | ||
| 681 | |||
| 682 | /* This table must be empty if there are no module references left. */ | ||
| 683 | for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) | ||
| 684 | BUG_ON(!hlist_empty(&vlan_group_hash[i])); | ||
| 685 | |||
| 686 | vlan_proc_cleanup(); | ||
| 687 | |||
| 688 | synchronize_net(); | ||
| 689 | } | ||
| 690 | |||
| 691 | module_init(vlan_proto_init); | ||
| 692 | module_exit(vlan_cleanup_module); | ||
| 693 | |||
| 719 | MODULE_LICENSE("GPL"); | 694 | MODULE_LICENSE("GPL"); |
| 720 | MODULE_VERSION(DRV_VERSION); | 695 | MODULE_VERSION(DRV_VERSION); |
diff --git a/net/8021q/vlanproc.c b/net/8021q/vlanproc.c index 5da02e29a2c6..971e6233801e 100644 --- a/net/8021q/vlanproc.c +++ b/net/8021q/vlanproc.c | |||
| @@ -158,15 +158,18 @@ void vlan_proc_cleanup(void) | |||
| 158 | int __init vlan_proc_init(void) | 158 | int __init vlan_proc_init(void) |
| 159 | { | 159 | { |
| 160 | proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net); | 160 | proc_vlan_dir = proc_mkdir(name_root, init_net.proc_net); |
| 161 | if (proc_vlan_dir) { | 161 | if (!proc_vlan_dir) |
| 162 | proc_vlan_conf = create_proc_entry(name_conf, | 162 | goto err; |
| 163 | S_IFREG|S_IRUSR|S_IWUSR, | 163 | |
| 164 | proc_vlan_dir); | 164 | proc_vlan_conf = create_proc_entry(name_conf, S_IFREG|S_IRUSR|S_IWUSR, |
| 165 | if (proc_vlan_conf) { | 165 | proc_vlan_dir); |
| 166 | proc_vlan_conf->proc_fops = &vlan_fops; | 166 | if (!proc_vlan_conf) |
| 167 | return 0; | 167 | goto err; |
| 168 | } | 168 | proc_vlan_conf->proc_fops = &vlan_fops; |
| 169 | } | 169 | return 0; |
| 170 | |||
| 171 | err: | ||
| 172 | pr_err("%s: can't create entry in proc filesystem!\n", __FUNCTION__); | ||
| 170 | vlan_proc_cleanup(); | 173 | vlan_proc_cleanup(); |
| 171 | return -ENOBUFS; | 174 | return -ENOBUFS; |
| 172 | } | 175 | } |
