vlan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. /*
  2. * INET 802.1Q VLAN
  3. * Ethernet-type device handling.
  4. *
  5. * Authors: Ben Greear <greearb@candelatech.com>
  6. * Please send support related email to: vlan@scry.wanfear.com
  7. * VLAN Home Page: http://www.candelatech.com/~greear/vlan.html
  8. *
  9. * Fixes:
  10. * Fix for packet capture - Nick Eggleston <nick@dccinc.com>;
  11. * Add HW acceleration hooks - David S. Miller <davem@redhat.com>;
  12. * Correct all the locking - David S. Miller <davem@redhat.com>;
  13. * Use hash table for VLAN groups - David S. Miller <davem@redhat.com>
  14. *
  15. * This program is free software; you can redistribute it and/or
  16. * modify it under the terms of the GNU General Public License
  17. * as published by the Free Software Foundation; either version
  18. * 2 of the License, or (at your option) any later version.
  19. */
  20. #include <asm/uaccess.h> /* for copy_from_user */
  21. #include <linux/capability.h>
  22. #include <linux/module.h>
  23. #include <linux/netdevice.h>
  24. #include <linux/skbuff.h>
  25. #include <net/datalink.h>
  26. #include <linux/mm.h>
  27. #include <linux/in.h>
  28. #include <linux/init.h>
  29. #include <net/p8022.h>
  30. #include <net/arp.h>
  31. #include <linux/rtnetlink.h>
  32. #include <linux/notifier.h>
  33. #include <net/net_namespace.h>
  34. #include <linux/if_vlan.h>
  35. #include "vlan.h"
  36. #include "vlanproc.h"
  37. #define DRV_VERSION "1.8"
  38. /* Global VLAN variables */
  39. /* Our listing of VLAN group(s) */
  40. static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
  41. #define vlan_grp_hashfn(IDX) ((((IDX) >> VLAN_GRP_HASH_SHIFT) ^ (IDX)) & VLAN_GRP_HASH_MASK)
  42. static char vlan_fullname[] = "802.1Q VLAN Support";
  43. static char vlan_version[] = DRV_VERSION;
  44. static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
  45. static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
  46. /* Determines interface naming scheme. */
  47. unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
  48. static struct packet_type vlan_packet_type = {
  49. .type = __constant_htons(ETH_P_8021Q),
  50. .func = vlan_skb_recv, /* VLAN receive method */
  51. };
  52. /* End of global variables definitions. */
  53. /* Must be invoked with RCU read lock (no preempt) */
  54. static struct vlan_group *__vlan_find_group(int real_dev_ifindex)
  55. {
  56. struct vlan_group *grp;
  57. struct hlist_node *n;
  58. int hash = vlan_grp_hashfn(real_dev_ifindex);
  59. hlist_for_each_entry_rcu(grp, n, &vlan_group_hash[hash], hlist) {
  60. if (grp->real_dev_ifindex == real_dev_ifindex)
  61. return grp;
  62. }
  63. return NULL;
  64. }
  65. /* Find the protocol handler. Assumes VID < VLAN_VID_MASK.
  66. *
  67. * Must be invoked with RCU read lock (no preempt)
  68. */
  69. struct net_device *__find_vlan_dev(struct net_device *real_dev,
  70. unsigned short VID)
  71. {
  72. struct vlan_group *grp = __vlan_find_group(real_dev->ifindex);
  73. if (grp)
  74. return vlan_group_get_device(grp, VID);
  75. return NULL;
  76. }
  77. static void vlan_group_free(struct vlan_group *grp)
  78. {
  79. int i;
  80. for (i=0; i < VLAN_GROUP_ARRAY_SPLIT_PARTS; i++)
  81. kfree(grp->vlan_devices_arrays[i]);
  82. kfree(grp);
  83. }
  84. static struct vlan_group *vlan_group_alloc(int ifindex)
  85. {
  86. struct vlan_group *grp;
  87. unsigned int size;
  88. unsigned int i;
  89. grp = kzalloc(sizeof(struct vlan_group), GFP_KERNEL);
  90. if (!grp)
  91. return NULL;
  92. size = sizeof(struct net_device *) * VLAN_GROUP_ARRAY_PART_LEN;
  93. for (i = 0; i < VLAN_GROUP_ARRAY_SPLIT_PARTS; i++) {
  94. grp->vlan_devices_arrays[i] = kzalloc(size, GFP_KERNEL);
  95. if (!grp->vlan_devices_arrays[i])
  96. goto err;
  97. }
  98. grp->real_dev_ifindex = ifindex;
  99. hlist_add_head_rcu(&grp->hlist,
  100. &vlan_group_hash[vlan_grp_hashfn(ifindex)]);
  101. return grp;
  102. err:
  103. vlan_group_free(grp);
  104. return NULL;
  105. }
  106. static void vlan_rcu_free(struct rcu_head *rcu)
  107. {
  108. vlan_group_free(container_of(rcu, struct vlan_group, rcu));
  109. }
  110. /* This returns 0 if everything went fine.
  111. * It will return 1 if the group was killed as a result.
  112. * A negative return indicates failure.
  113. *
  114. * The RTNL lock must be held.
  115. */
  116. static int unregister_vlan_dev(struct net_device *real_dev,
  117. unsigned short vlan_id)
  118. {
  119. struct net_device *dev = NULL;
  120. int real_dev_ifindex = real_dev->ifindex;
  121. struct vlan_group *grp;
  122. int i, ret;
  123. /* sanity check */
  124. if (vlan_id >= VLAN_VID_MASK)
  125. return -EINVAL;
  126. ASSERT_RTNL();
  127. grp = __vlan_find_group(real_dev_ifindex);
  128. ret = 0;
  129. if (grp) {
  130. dev = vlan_group_get_device(grp, vlan_id);
  131. if (dev) {
  132. /* Remove proc entry */
  133. vlan_proc_rem_dev(dev);
  134. /* Take it out of our own structures, but be sure to
  135. * interlock with HW accelerating devices or SW vlan
  136. * input packet processing.
  137. */
  138. if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
  139. real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
  140. vlan_group_set_device(grp, vlan_id, NULL);
  141. synchronize_net();
  142. /* Caller unregisters (and if necessary, puts)
  143. * VLAN device, but we get rid of the reference to
  144. * real_dev here.
  145. */
  146. dev_put(real_dev);
  147. /* If the group is now empty, kill off the
  148. * group.
  149. */
  150. for (i = 0; i < VLAN_VID_MASK; i++)
  151. if (vlan_group_get_device(grp, i))
  152. break;
  153. if (i == VLAN_VID_MASK) {
  154. if (real_dev->features & NETIF_F_HW_VLAN_RX)
  155. real_dev->vlan_rx_register(real_dev, NULL);
  156. hlist_del_rcu(&grp->hlist);
  157. /* Free the group, after all cpu's are done. */
  158. call_rcu(&grp->rcu, vlan_rcu_free);
  159. grp = NULL;
  160. ret = 1;
  161. }
  162. }
  163. }
  164. return ret;
  165. }
  166. int unregister_vlan_device(struct net_device *dev)
  167. {
  168. int ret;
  169. ret = unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
  170. VLAN_DEV_INFO(dev)->vlan_id);
  171. unregister_netdevice(dev);
  172. if (ret == 1)
  173. ret = 0;
  174. return ret;
  175. }
  176. static void vlan_transfer_operstate(const struct net_device *dev, struct net_device *vlandev)
  177. {
  178. /* Have to respect userspace enforced dormant state
  179. * of real device, also must allow supplicant running
  180. * on VLAN device
  181. */
  182. if (dev->operstate == IF_OPER_DORMANT)
  183. netif_dormant_on(vlandev);
  184. else
  185. netif_dormant_off(vlandev);
  186. if (netif_carrier_ok(dev)) {
  187. if (!netif_carrier_ok(vlandev))
  188. netif_carrier_on(vlandev);
  189. } else {
  190. if (netif_carrier_ok(vlandev))
  191. netif_carrier_off(vlandev);
  192. }
  193. }
  194. int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
  195. {
  196. char *name = real_dev->name;
  197. if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
  198. pr_info("8021q: VLANs not supported on %s\n", name);
  199. return -EOPNOTSUPP;
  200. }
  201. if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
  202. !real_dev->vlan_rx_register) {
  203. pr_info("8021q: device %s has buggy VLAN hw accel\n", name);
  204. return -EOPNOTSUPP;
  205. }
  206. if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
  207. (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
  208. pr_info("8021q: Device %s has buggy VLAN hw accel\n", name);
  209. return -EOPNOTSUPP;
  210. }
  211. /* The real device must be up and operating in order to
  212. * assosciate a VLAN device with it.
  213. */
  214. if (!(real_dev->flags & IFF_UP))
  215. return -ENETDOWN;
  216. if (__find_vlan_dev(real_dev, vlan_id) != NULL)
  217. return -EEXIST;
  218. return 0;
  219. }
  220. int register_vlan_dev(struct net_device *dev)
  221. {
  222. struct vlan_dev_info *vlan = VLAN_DEV_INFO(dev);
  223. struct net_device *real_dev = vlan->real_dev;
  224. unsigned short vlan_id = vlan->vlan_id;
  225. struct vlan_group *grp, *ngrp = NULL;
  226. int err;
  227. grp = __vlan_find_group(real_dev->ifindex);
  228. if (!grp) {
  229. ngrp = grp = vlan_group_alloc(real_dev->ifindex);
  230. if (!grp)
  231. return -ENOBUFS;
  232. }
  233. err = register_netdevice(dev);
  234. if (err < 0)
  235. goto out_free_group;
  236. /* Account for reference in struct vlan_dev_info */
  237. dev_hold(real_dev);
  238. vlan_transfer_operstate(real_dev, dev);
  239. linkwatch_fire_event(dev); /* _MUST_ call rfc2863_policy() */
  240. /* So, got the sucker initialized, now lets place
  241. * it into our local structure.
  242. */
  243. vlan_group_set_device(grp, vlan_id, dev);
  244. if (ngrp && real_dev->features & NETIF_F_HW_VLAN_RX)
  245. real_dev->vlan_rx_register(real_dev, ngrp);
  246. if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
  247. real_dev->vlan_rx_add_vid(real_dev, vlan_id);
  248. if (vlan_proc_add_dev(dev) < 0)
  249. pr_warning("8021q: failed to add proc entry for %s\n",
  250. dev->name);
  251. return 0;
  252. out_free_group:
  253. if (ngrp)
  254. vlan_group_free(ngrp);
  255. return err;
  256. }
  257. /* Attach a VLAN device to a mac address (ie Ethernet Card).
  258. * Returns 0 if the device was created or a negative error code otherwise.
  259. */
  260. static int register_vlan_device(struct net_device *real_dev,
  261. unsigned short VLAN_ID)
  262. {
  263. struct net_device *new_dev;
  264. char name[IFNAMSIZ];
  265. int err;
  266. if (VLAN_ID >= VLAN_VID_MASK)
  267. return -ERANGE;
  268. err = vlan_check_real_dev(real_dev, VLAN_ID);
  269. if (err < 0)
  270. return err;
  271. /* Gotta set up the fields for the device. */
  272. switch (vlan_name_type) {
  273. case VLAN_NAME_TYPE_RAW_PLUS_VID:
  274. /* name will look like: eth1.0005 */
  275. snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID);
  276. break;
  277. case VLAN_NAME_TYPE_PLUS_VID_NO_PAD:
  278. /* Put our vlan.VID in the name.
  279. * Name will look like: vlan5
  280. */
  281. snprintf(name, IFNAMSIZ, "vlan%i", VLAN_ID);
  282. break;
  283. case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
  284. /* Put our vlan.VID in the name.
  285. * Name will look like: eth0.5
  286. */
  287. snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, VLAN_ID);
  288. break;
  289. case VLAN_NAME_TYPE_PLUS_VID:
  290. /* Put our vlan.VID in the name.
  291. * Name will look like: vlan0005
  292. */
  293. default:
  294. snprintf(name, IFNAMSIZ, "vlan%.4i", VLAN_ID);
  295. }
  296. new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name,
  297. vlan_setup);
  298. if (new_dev == NULL)
  299. return -ENOBUFS;
  300. /* need 4 bytes for extra VLAN header info,
  301. * hope the underlying device can handle it.
  302. */
  303. new_dev->mtu = real_dev->mtu;
  304. VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
  305. VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
  306. VLAN_DEV_INFO(new_dev)->dent = NULL;
  307. VLAN_DEV_INFO(new_dev)->flags = VLAN_FLAG_REORDER_HDR;
  308. new_dev->rtnl_link_ops = &vlan_link_ops;
  309. err = register_vlan_dev(new_dev);
  310. if (err < 0)
  311. goto out_free_newdev;
  312. return 0;
  313. out_free_newdev:
  314. free_netdev(new_dev);
  315. return err;
  316. }
  317. static void vlan_sync_address(struct net_device *dev,
  318. struct net_device *vlandev)
  319. {
  320. struct vlan_dev_info *vlan = VLAN_DEV_INFO(vlandev);
  321. /* May be called without an actual change */
  322. if (!compare_ether_addr(vlan->real_dev_addr, dev->dev_addr))
  323. return;
  324. /* vlan address was different from the old address and is equal to
  325. * the new address */
  326. if (compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) &&
  327. !compare_ether_addr(vlandev->dev_addr, dev->dev_addr))
  328. dev_unicast_delete(dev, vlandev->dev_addr, ETH_ALEN);
  329. /* vlan address was equal to the old address and is different from
  330. * the new address */
  331. if (!compare_ether_addr(vlandev->dev_addr, vlan->real_dev_addr) &&
  332. compare_ether_addr(vlandev->dev_addr, dev->dev_addr))
  333. dev_unicast_add(dev, vlandev->dev_addr, ETH_ALEN);
  334. memcpy(vlan->real_dev_addr, dev->dev_addr, ETH_ALEN);
  335. }
  336. static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
  337. {
  338. struct net_device *dev = ptr;
  339. struct vlan_group *grp = __vlan_find_group(dev->ifindex);
  340. int i, flgs;
  341. struct net_device *vlandev;
  342. if (dev->nd_net != &init_net)
  343. return NOTIFY_DONE;
  344. if (!grp)
  345. goto out;
  346. /* It is OK that we do not hold the group lock right now,
  347. * as we run under the RTNL lock.
  348. */
  349. switch (event) {
  350. case NETDEV_CHANGE:
  351. /* Propagate real device state to vlan devices */
  352. for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
  353. vlandev = vlan_group_get_device(grp, i);
  354. if (!vlandev)
  355. continue;
  356. vlan_transfer_operstate(dev, vlandev);
  357. }
  358. break;
  359. case NETDEV_CHANGEADDR:
  360. /* Adjust unicast filters on underlying device */
  361. for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
  362. vlandev = vlan_group_get_device(grp, i);
  363. if (!vlandev)
  364. continue;
  365. flgs = vlandev->flags;
  366. if (!(flgs & IFF_UP))
  367. continue;
  368. vlan_sync_address(dev, vlandev);
  369. }
  370. break;
  371. case NETDEV_DOWN:
  372. /* Put all VLANs for this dev in the down state too. */
  373. for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
  374. vlandev = vlan_group_get_device(grp, i);
  375. if (!vlandev)
  376. continue;
  377. flgs = vlandev->flags;
  378. if (!(flgs & IFF_UP))
  379. continue;
  380. dev_change_flags(vlandev, flgs & ~IFF_UP);
  381. }
  382. break;
  383. case NETDEV_UP:
  384. /* Put all VLANs for this dev in the up state too. */
  385. for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
  386. vlandev = vlan_group_get_device(grp, i);
  387. if (!vlandev)
  388. continue;
  389. flgs = vlandev->flags;
  390. if (flgs & IFF_UP)
  391. continue;
  392. dev_change_flags(vlandev, flgs | IFF_UP);
  393. }
  394. break;
  395. case NETDEV_UNREGISTER:
  396. /* Delete all VLANs for this dev. */
  397. for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
  398. int ret;
  399. vlandev = vlan_group_get_device(grp, i);
  400. if (!vlandev)
  401. continue;
  402. ret = unregister_vlan_dev(dev,
  403. VLAN_DEV_INFO(vlandev)->vlan_id);
  404. unregister_netdevice(vlandev);
  405. /* Group was destroyed? */
  406. if (ret == 1)
  407. break;
  408. }
  409. break;
  410. }
  411. out:
  412. return NOTIFY_DONE;
  413. }
  414. static struct notifier_block vlan_notifier_block __read_mostly = {
  415. .notifier_call = vlan_device_event,
  416. };
  417. /*
  418. * VLAN IOCTL handler.
  419. * o execute requested action or pass command to the device driver
  420. * arg is really a struct vlan_ioctl_args __user *.
  421. */
  422. static int vlan_ioctl_handler(struct net *net, void __user *arg)
  423. {
  424. int err;
  425. unsigned short vid = 0;
  426. struct vlan_ioctl_args args;
  427. struct net_device *dev = NULL;
  428. if (copy_from_user(&args, arg, sizeof(struct vlan_ioctl_args)))
  429. return -EFAULT;
  430. /* Null terminate this sucker, just in case. */
  431. args.device1[23] = 0;
  432. args.u.device2[23] = 0;
  433. rtnl_lock();
  434. switch (args.cmd) {
  435. case SET_VLAN_INGRESS_PRIORITY_CMD:
  436. case SET_VLAN_EGRESS_PRIORITY_CMD:
  437. case SET_VLAN_FLAG_CMD:
  438. case ADD_VLAN_CMD:
  439. case DEL_VLAN_CMD:
  440. case GET_VLAN_REALDEV_NAME_CMD:
  441. case GET_VLAN_VID_CMD:
  442. err = -ENODEV;
  443. dev = __dev_get_by_name(&init_net, args.device1);
  444. if (!dev)
  445. goto out;
  446. err = -EINVAL;
  447. if (args.cmd != ADD_VLAN_CMD &&
  448. !(dev->priv_flags & IFF_802_1Q_VLAN))
  449. goto out;
  450. }
  451. switch (args.cmd) {
  452. case SET_VLAN_INGRESS_PRIORITY_CMD:
  453. err = -EPERM;
  454. if (!capable(CAP_NET_ADMIN))
  455. break;
  456. vlan_dev_set_ingress_priority(dev,
  457. args.u.skb_priority,
  458. args.vlan_qos);
  459. err = 0;
  460. break;
  461. case SET_VLAN_EGRESS_PRIORITY_CMD:
  462. err = -EPERM;
  463. if (!capable(CAP_NET_ADMIN))
  464. break;
  465. err = vlan_dev_set_egress_priority(dev,
  466. args.u.skb_priority,
  467. args.vlan_qos);
  468. break;
  469. case SET_VLAN_FLAG_CMD:
  470. err = -EPERM;
  471. if (!capable(CAP_NET_ADMIN))
  472. break;
  473. err = vlan_dev_set_vlan_flag(dev,
  474. args.u.flag,
  475. args.vlan_qos);
  476. break;
  477. case SET_VLAN_NAME_TYPE_CMD:
  478. err = -EPERM;
  479. if (!capable(CAP_NET_ADMIN))
  480. break;
  481. if ((args.u.name_type >= 0) &&
  482. (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
  483. vlan_name_type = args.u.name_type;
  484. err = 0;
  485. } else {
  486. err = -EINVAL;
  487. }
  488. break;
  489. case ADD_VLAN_CMD:
  490. err = -EPERM;
  491. if (!capable(CAP_NET_ADMIN))
  492. break;
  493. err = register_vlan_device(dev, args.u.VID);
  494. break;
  495. case DEL_VLAN_CMD:
  496. err = -EPERM;
  497. if (!capable(CAP_NET_ADMIN))
  498. break;
  499. err = unregister_vlan_device(dev);
  500. break;
  501. case GET_VLAN_REALDEV_NAME_CMD:
  502. err = 0;
  503. vlan_dev_get_realdev_name(dev, args.u.device2);
  504. if (copy_to_user(arg, &args,
  505. sizeof(struct vlan_ioctl_args))) {
  506. err = -EFAULT;
  507. }
  508. break;
  509. case GET_VLAN_VID_CMD:
  510. err = 0;
  511. vlan_dev_get_vid(dev, &vid);
  512. args.u.VID = vid;
  513. if (copy_to_user(arg, &args,
  514. sizeof(struct vlan_ioctl_args))) {
  515. err = -EFAULT;
  516. }
  517. break;
  518. default:
  519. err = -EOPNOTSUPP;
  520. break;
  521. }
  522. out:
  523. rtnl_unlock();
  524. return err;
  525. }
  526. static int __init vlan_proto_init(void)
  527. {
  528. int err;
  529. pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright);
  530. pr_info("All bugs added by %s\n", vlan_buggyright);
  531. err = vlan_proc_init();
  532. if (err < 0)
  533. goto err1;
  534. err = register_netdevice_notifier(&vlan_notifier_block);
  535. if (err < 0)
  536. goto err2;
  537. err = vlan_netlink_init();
  538. if (err < 0)
  539. goto err3;
  540. dev_add_pack(&vlan_packet_type);
  541. vlan_ioctl_set(vlan_ioctl_handler);
  542. return 0;
  543. err3:
  544. unregister_netdevice_notifier(&vlan_notifier_block);
  545. err2:
  546. vlan_proc_cleanup();
  547. err1:
  548. return err;
  549. }
  550. static void __exit vlan_cleanup_module(void)
  551. {
  552. unsigned int i;
  553. vlan_ioctl_set(NULL);
  554. vlan_netlink_fini();
  555. unregister_netdevice_notifier(&vlan_notifier_block);
  556. dev_remove_pack(&vlan_packet_type);
  557. /* This table must be empty if there are no module references left. */
  558. for (i = 0; i < VLAN_GRP_HASH_SIZE; i++)
  559. BUG_ON(!hlist_empty(&vlan_group_hash[i]));
  560. vlan_proc_cleanup();
  561. synchronize_net();
  562. }
  563. module_init(vlan_proto_init);
  564. module_exit(vlan_cleanup_module);
  565. MODULE_LICENSE("GPL");
  566. MODULE_VERSION(DRV_VERSION);