i2c-viapro: Add support for the VT8237A and VT8251
[linux/fpc-iii.git] / net / 8021q / vlan.c
blobfa76220708ce7cb068ae127c0ea35c8bd72fdfe6
1 /*
2 * INET 802.1Q VLAN
3 * Ethernet-type device handling.
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>
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.
21 #include <asm/uaccess.h> /* for copy_from_user */
22 #include <linux/capability.h>
23 #include <linux/module.h>
24 #include <linux/netdevice.h>
25 #include <linux/skbuff.h>
26 #include <net/datalink.h>
27 #include <linux/mm.h>
28 #include <linux/in.h>
29 #include <linux/init.h>
30 #include <net/p8022.h>
31 #include <net/arp.h>
32 #include <linux/rtnetlink.h>
33 #include <linux/notifier.h>
35 #include <linux/if_vlan.h>
36 #include "vlan.h"
37 #include "vlanproc.h"
39 #define DRV_VERSION "1.8"
41 /* Global VLAN variables */
43 /* Our listing of VLAN group(s) */
44 static struct hlist_head vlan_group_hash[VLAN_GRP_HASH_SIZE];
45 #define vlan_grp_hashfn(IDX) ((((IDX) >> VLAN_GRP_HASH_SHIFT) ^ (IDX)) & VLAN_GRP_HASH_MASK)
47 static char vlan_fullname[] = "802.1Q VLAN Support";
48 static char vlan_version[] = DRV_VERSION;
49 static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>";
50 static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>";
52 static int vlan_device_event(struct notifier_block *, unsigned long, void *);
53 static int vlan_ioctl_handler(void __user *);
54 static int unregister_vlan_dev(struct net_device *, unsigned short );
56 static struct notifier_block vlan_notifier_block = {
57 .notifier_call = vlan_device_event,
60 /* These may be changed at run-time through IOCTLs */
62 /* Determines interface naming scheme. */
63 unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD;
65 static struct packet_type vlan_packet_type = {
66 .type = __constant_htons(ETH_P_8021Q),
67 .func = vlan_skb_recv, /* VLAN receive method */
70 /* Bits of netdev state that are propagated from real device to virtual */
71 #define VLAN_LINK_STATE_MASK \
72 ((1<<__LINK_STATE_PRESENT)|(1<<__LINK_STATE_NOCARRIER))
74 /* End of global variables definitions. */
77 * Function vlan_proto_init (pro)
79 * Initialize VLAN protocol layer,
82 static int __init vlan_proto_init(void)
84 int err;
86 printk(VLAN_INF "%s v%s %s\n",
87 vlan_fullname, vlan_version, vlan_copyright);
88 printk(VLAN_INF "All bugs added by %s\n",
89 vlan_buggyright);
91 /* proc file system initialization */
92 err = vlan_proc_init();
93 if (err < 0) {
94 printk(KERN_ERR
95 "%s %s: can't create entry in proc filesystem!\n",
96 __FUNCTION__, VLAN_NAME);
97 return err;
100 dev_add_pack(&vlan_packet_type);
102 /* Register us to receive netdevice events */
103 err = register_netdevice_notifier(&vlan_notifier_block);
104 if (err < 0) {
105 dev_remove_pack(&vlan_packet_type);
106 vlan_proc_cleanup();
107 return err;
110 vlan_ioctl_set(vlan_ioctl_handler);
112 return 0;
115 /* Cleanup all vlan devices
116 * Note: devices that have been registered that but not
117 * brought up will exist but have no module ref count.
119 static void __exit vlan_cleanup_devices(void)
121 struct net_device *dev, *nxt;
123 rtnl_lock();
124 for (dev = dev_base; dev; dev = nxt) {
125 nxt = dev->next;
126 if (dev->priv_flags & IFF_802_1Q_VLAN) {
127 unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
128 VLAN_DEV_INFO(dev)->vlan_id);
130 unregister_netdevice(dev);
133 rtnl_unlock();
137 * Module 'remove' entry point.
138 * o delete /proc/net/router directory and static entries.
140 static void __exit vlan_cleanup_module(void)
142 int i;
144 vlan_ioctl_set(NULL);
146 /* Un-register us from receiving netdevice events */
147 unregister_netdevice_notifier(&vlan_notifier_block);
149 dev_remove_pack(&vlan_packet_type);
150 vlan_cleanup_devices();
152 /* This table must be empty if there are no module
153 * references left.
155 for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) {
156 BUG_ON(!hlist_empty(&vlan_group_hash[i]));
158 vlan_proc_cleanup();
160 synchronize_net();
163 module_init(vlan_proto_init);
164 module_exit(vlan_cleanup_module);
166 /* Must be invoked with RCU read lock (no preempt) */
167 static struct vlan_group *__vlan_find_group(int real_dev_ifindex)
169 struct vlan_group *grp;
170 struct hlist_node *n;
171 int hash = vlan_grp_hashfn(real_dev_ifindex);
173 hlist_for_each_entry_rcu(grp, n, &vlan_group_hash[hash], hlist) {
174 if (grp->real_dev_ifindex == real_dev_ifindex)
175 return grp;
178 return NULL;
181 /* Find the protocol handler. Assumes VID < VLAN_VID_MASK.
183 * Must be invoked with RCU read lock (no preempt)
185 struct net_device *__find_vlan_dev(struct net_device *real_dev,
186 unsigned short VID)
188 struct vlan_group *grp = __vlan_find_group(real_dev->ifindex);
190 if (grp)
191 return grp->vlan_devices[VID];
193 return NULL;
196 static void vlan_rcu_free(struct rcu_head *rcu)
198 kfree(container_of(rcu, struct vlan_group, rcu));
202 /* This returns 0 if everything went fine.
203 * It will return 1 if the group was killed as a result.
204 * A negative return indicates failure.
206 * The RTNL lock must be held.
208 static int unregister_vlan_dev(struct net_device *real_dev,
209 unsigned short vlan_id)
211 struct net_device *dev = NULL;
212 int real_dev_ifindex = real_dev->ifindex;
213 struct vlan_group *grp;
214 int i, ret;
216 #ifdef VLAN_DEBUG
217 printk(VLAN_DBG "%s: VID: %i\n", __FUNCTION__, vlan_id);
218 #endif
220 /* sanity check */
221 if (vlan_id >= VLAN_VID_MASK)
222 return -EINVAL;
224 ASSERT_RTNL();
225 grp = __vlan_find_group(real_dev_ifindex);
227 ret = 0;
229 if (grp) {
230 dev = grp->vlan_devices[vlan_id];
231 if (dev) {
232 /* Remove proc entry */
233 vlan_proc_rem_dev(dev);
235 /* Take it out of our own structures, but be sure to
236 * interlock with HW accelerating devices or SW vlan
237 * input packet processing.
239 if (real_dev->features &
240 (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_FILTER)) {
241 real_dev->vlan_rx_kill_vid(real_dev, vlan_id);
244 grp->vlan_devices[vlan_id] = NULL;
245 synchronize_net();
248 /* Caller unregisters (and if necessary, puts)
249 * VLAN device, but we get rid of the reference to
250 * real_dev here.
252 dev_put(real_dev);
254 /* If the group is now empty, kill off the
255 * group.
257 for (i = 0; i < VLAN_VID_MASK; i++)
258 if (grp->vlan_devices[i])
259 break;
261 if (i == VLAN_VID_MASK) {
262 if (real_dev->features & NETIF_F_HW_VLAN_RX)
263 real_dev->vlan_rx_register(real_dev, NULL);
265 hlist_del_rcu(&grp->hlist);
267 /* Free the group, after all cpu's are done. */
268 call_rcu(&grp->rcu, vlan_rcu_free);
270 grp = NULL;
271 ret = 1;
276 return ret;
279 static int unregister_vlan_device(const char *vlan_IF_name)
281 struct net_device *dev = NULL;
282 int ret;
285 dev = dev_get_by_name(vlan_IF_name);
286 ret = -EINVAL;
287 if (dev) {
288 if (dev->priv_flags & IFF_802_1Q_VLAN) {
289 rtnl_lock();
291 ret = unregister_vlan_dev(VLAN_DEV_INFO(dev)->real_dev,
292 VLAN_DEV_INFO(dev)->vlan_id);
294 dev_put(dev);
295 unregister_netdevice(dev);
297 rtnl_unlock();
299 if (ret == 1)
300 ret = 0;
301 } else {
302 printk(VLAN_ERR
303 "%s: ERROR: Tried to remove a non-vlan device "
304 "with VLAN code, name: %s priv_flags: %hX\n",
305 __FUNCTION__, dev->name, dev->priv_flags);
306 dev_put(dev);
307 ret = -EPERM;
309 } else {
310 #ifdef VLAN_DEBUG
311 printk(VLAN_DBG "%s: WARNING: Could not find dev.\n", __FUNCTION__);
312 #endif
313 ret = -EINVAL;
316 return ret;
319 static void vlan_setup(struct net_device *new_dev)
321 SET_MODULE_OWNER(new_dev);
323 /* new_dev->ifindex = 0; it will be set when added to
324 * the global list.
325 * iflink is set as well.
327 new_dev->get_stats = vlan_dev_get_stats;
329 /* Make this thing known as a VLAN device */
330 new_dev->priv_flags |= IFF_802_1Q_VLAN;
332 /* Set us up to have no queue, as the underlying Hardware device
333 * can do all the queueing we could want.
335 new_dev->tx_queue_len = 0;
337 /* set up method calls */
338 new_dev->change_mtu = vlan_dev_change_mtu;
339 new_dev->open = vlan_dev_open;
340 new_dev->stop = vlan_dev_stop;
341 new_dev->set_mac_address = vlan_dev_set_mac_address;
342 new_dev->set_multicast_list = vlan_dev_set_multicast_list;
343 new_dev->destructor = free_netdev;
344 new_dev->do_ioctl = vlan_dev_ioctl;
347 /* Attach a VLAN device to a mac address (ie Ethernet Card).
348 * Returns the device that was created, or NULL if there was
349 * an error of some kind.
351 static struct net_device *register_vlan_device(const char *eth_IF_name,
352 unsigned short VLAN_ID)
354 struct vlan_group *grp;
355 struct net_device *new_dev;
356 struct net_device *real_dev; /* the ethernet device */
357 char name[IFNAMSIZ];
359 #ifdef VLAN_DEBUG
360 printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n",
361 __FUNCTION__, eth_IF_name, VLAN_ID);
362 #endif
364 if (VLAN_ID >= VLAN_VID_MASK)
365 goto out_ret_null;
367 /* find the device relating to eth_IF_name. */
368 real_dev = dev_get_by_name(eth_IF_name);
369 if (!real_dev)
370 goto out_ret_null;
372 if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
373 printk(VLAN_DBG "%s: VLANs not supported on %s.\n",
374 __FUNCTION__, real_dev->name);
375 goto out_put_dev;
378 if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
379 (real_dev->vlan_rx_register == NULL ||
380 real_dev->vlan_rx_kill_vid == NULL)) {
381 printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
382 __FUNCTION__, real_dev->name);
383 goto out_put_dev;
386 if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
387 (real_dev->vlan_rx_add_vid == NULL ||
388 real_dev->vlan_rx_kill_vid == NULL)) {
389 printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
390 __FUNCTION__, real_dev->name);
391 goto out_put_dev;
394 /* From this point on, all the data structures must remain
395 * consistent.
397 rtnl_lock();
399 /* The real device must be up and operating in order to
400 * assosciate a VLAN device with it.
402 if (!(real_dev->flags & IFF_UP))
403 goto out_unlock;
405 if (__find_vlan_dev(real_dev, VLAN_ID) != NULL) {
406 /* was already registered. */
407 printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__);
408 goto out_unlock;
411 /* Gotta set up the fields for the device. */
412 #ifdef VLAN_DEBUG
413 printk(VLAN_DBG "About to allocate name, vlan_name_type: %i\n",
414 vlan_name_type);
415 #endif
416 switch (vlan_name_type) {
417 case VLAN_NAME_TYPE_RAW_PLUS_VID:
418 /* name will look like: eth1.0005 */
419 snprintf(name, IFNAMSIZ, "%s.%.4i", real_dev->name, VLAN_ID);
420 break;
421 case VLAN_NAME_TYPE_PLUS_VID_NO_PAD:
422 /* Put our vlan.VID in the name.
423 * Name will look like: vlan5
425 snprintf(name, IFNAMSIZ, "vlan%i", VLAN_ID);
426 break;
427 case VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD:
428 /* Put our vlan.VID in the name.
429 * Name will look like: eth0.5
431 snprintf(name, IFNAMSIZ, "%s.%i", real_dev->name, VLAN_ID);
432 break;
433 case VLAN_NAME_TYPE_PLUS_VID:
434 /* Put our vlan.VID in the name.
435 * Name will look like: vlan0005
437 default:
438 snprintf(name, IFNAMSIZ, "vlan%.4i", VLAN_ID);
441 new_dev = alloc_netdev(sizeof(struct vlan_dev_info), name,
442 vlan_setup);
443 if (new_dev == NULL)
444 goto out_unlock;
446 #ifdef VLAN_DEBUG
447 printk(VLAN_DBG "Allocated new name -:%s:-\n", new_dev->name);
448 #endif
449 /* IFF_BROADCAST|IFF_MULTICAST; ??? */
450 new_dev->flags = real_dev->flags;
451 new_dev->flags &= ~IFF_UP;
453 new_dev->state = real_dev->state & VLAN_LINK_STATE_MASK;
455 /* need 4 bytes for extra VLAN header info,
456 * hope the underlying device can handle it.
458 new_dev->mtu = real_dev->mtu;
460 /* TODO: maybe just assign it to be ETHERNET? */
461 new_dev->type = real_dev->type;
463 new_dev->hard_header_len = real_dev->hard_header_len;
464 if (!(real_dev->features & NETIF_F_HW_VLAN_TX)) {
465 /* Regular ethernet + 4 bytes (18 total). */
466 new_dev->hard_header_len += VLAN_HLEN;
469 VLAN_MEM_DBG("new_dev->priv malloc, addr: %p size: %i\n",
470 new_dev->priv,
471 sizeof(struct vlan_dev_info));
473 memcpy(new_dev->broadcast, real_dev->broadcast, real_dev->addr_len);
474 memcpy(new_dev->dev_addr, real_dev->dev_addr, real_dev->addr_len);
475 new_dev->addr_len = real_dev->addr_len;
477 if (real_dev->features & NETIF_F_HW_VLAN_TX) {
478 new_dev->hard_header = real_dev->hard_header;
479 new_dev->hard_start_xmit = vlan_dev_hwaccel_hard_start_xmit;
480 new_dev->rebuild_header = real_dev->rebuild_header;
481 } else {
482 new_dev->hard_header = vlan_dev_hard_header;
483 new_dev->hard_start_xmit = vlan_dev_hard_start_xmit;
484 new_dev->rebuild_header = vlan_dev_rebuild_header;
486 new_dev->hard_header_parse = real_dev->hard_header_parse;
488 VLAN_DEV_INFO(new_dev)->vlan_id = VLAN_ID; /* 1 through VLAN_VID_MASK */
489 VLAN_DEV_INFO(new_dev)->real_dev = real_dev;
490 VLAN_DEV_INFO(new_dev)->dent = NULL;
491 VLAN_DEV_INFO(new_dev)->flags = 1;
493 #ifdef VLAN_DEBUG
494 printk(VLAN_DBG "About to go find the group for idx: %i\n",
495 real_dev->ifindex);
496 #endif
498 if (register_netdevice(new_dev))
499 goto out_free_newdev;
501 /* So, got the sucker initialized, now lets place
502 * it into our local structure.
504 grp = __vlan_find_group(real_dev->ifindex);
506 /* Note, we are running under the RTNL semaphore
507 * so it cannot "appear" on us.
509 if (!grp) { /* need to add a new group */
510 grp = kmalloc(sizeof(struct vlan_group), GFP_KERNEL);
511 if (!grp)
512 goto out_free_unregister;
514 /* printk(KERN_ALERT "VLAN REGISTER: Allocated new group.\n"); */
515 memset(grp, 0, sizeof(struct vlan_group));
516 grp->real_dev_ifindex = real_dev->ifindex;
518 hlist_add_head_rcu(&grp->hlist,
519 &vlan_group_hash[vlan_grp_hashfn(real_dev->ifindex)]);
521 if (real_dev->features & NETIF_F_HW_VLAN_RX)
522 real_dev->vlan_rx_register(real_dev, grp);
525 grp->vlan_devices[VLAN_ID] = new_dev;
527 if (vlan_proc_add_dev(new_dev)<0)/* create it's proc entry */
528 printk(KERN_WARNING "VLAN: failed to add proc entry for %s\n",
529 new_dev->name);
531 if (real_dev->features & NETIF_F_HW_VLAN_FILTER)
532 real_dev->vlan_rx_add_vid(real_dev, VLAN_ID);
534 rtnl_unlock();
537 #ifdef VLAN_DEBUG
538 printk(VLAN_DBG "Allocated new device successfully, returning.\n");
539 #endif
540 return new_dev;
542 out_free_unregister:
543 unregister_netdev(new_dev);
544 goto out_unlock;
546 out_free_newdev:
547 free_netdev(new_dev);
549 out_unlock:
550 rtnl_unlock();
552 out_put_dev:
553 dev_put(real_dev);
555 out_ret_null:
556 return NULL;
559 static int vlan_device_event(struct notifier_block *unused, unsigned long event, void *ptr)
561 struct net_device *dev = ptr;
562 struct vlan_group *grp = __vlan_find_group(dev->ifindex);
563 int i, flgs;
564 struct net_device *vlandev;
566 if (!grp)
567 goto out;
569 /* It is OK that we do not hold the group lock right now,
570 * as we run under the RTNL lock.
573 switch (event) {
574 case NETDEV_CHANGE:
575 /* Propagate real device state to vlan devices */
576 flgs = dev->state & VLAN_LINK_STATE_MASK;
577 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
578 vlandev = grp->vlan_devices[i];
579 if (!vlandev)
580 continue;
582 if (netif_carrier_ok(dev)) {
583 if (!netif_carrier_ok(vlandev))
584 netif_carrier_on(vlandev);
585 } else {
586 if (netif_carrier_ok(vlandev))
587 netif_carrier_off(vlandev);
590 if ((vlandev->state & VLAN_LINK_STATE_MASK) != flgs) {
591 vlandev->state = (vlandev->state &~ VLAN_LINK_STATE_MASK)
592 | flgs;
593 netdev_state_change(vlandev);
596 break;
598 case NETDEV_DOWN:
599 /* Put all VLANs for this dev in the down state too. */
600 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
601 vlandev = grp->vlan_devices[i];
602 if (!vlandev)
603 continue;
605 flgs = vlandev->flags;
606 if (!(flgs & IFF_UP))
607 continue;
609 dev_change_flags(vlandev, flgs & ~IFF_UP);
611 break;
613 case NETDEV_UP:
614 /* Put all VLANs for this dev in the up state too. */
615 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
616 vlandev = grp->vlan_devices[i];
617 if (!vlandev)
618 continue;
620 flgs = vlandev->flags;
621 if (flgs & IFF_UP)
622 continue;
624 dev_change_flags(vlandev, flgs | IFF_UP);
626 break;
628 case NETDEV_UNREGISTER:
629 /* Delete all VLANs for this dev. */
630 for (i = 0; i < VLAN_GROUP_ARRAY_LEN; i++) {
631 int ret;
633 vlandev = grp->vlan_devices[i];
634 if (!vlandev)
635 continue;
637 ret = unregister_vlan_dev(dev,
638 VLAN_DEV_INFO(vlandev)->vlan_id);
640 unregister_netdevice(vlandev);
642 /* Group was destroyed? */
643 if (ret == 1)
644 break;
646 break;
649 out:
650 return NOTIFY_DONE;
654 * VLAN IOCTL handler.
655 * o execute requested action or pass command to the device driver
656 * arg is really a struct vlan_ioctl_args __user *.
658 static int vlan_ioctl_handler(void __user *arg)
660 int err = 0;
661 unsigned short vid = 0;
662 struct vlan_ioctl_args args;
664 if (copy_from_user(&args, arg, sizeof(struct vlan_ioctl_args)))
665 return -EFAULT;
667 /* Null terminate this sucker, just in case. */
668 args.device1[23] = 0;
669 args.u.device2[23] = 0;
671 #ifdef VLAN_DEBUG
672 printk(VLAN_DBG "%s: args.cmd: %x\n", __FUNCTION__, args.cmd);
673 #endif
675 switch (args.cmd) {
676 case SET_VLAN_INGRESS_PRIORITY_CMD:
677 if (!capable(CAP_NET_ADMIN))
678 return -EPERM;
679 err = vlan_dev_set_ingress_priority(args.device1,
680 args.u.skb_priority,
681 args.vlan_qos);
682 break;
684 case SET_VLAN_EGRESS_PRIORITY_CMD:
685 if (!capable(CAP_NET_ADMIN))
686 return -EPERM;
687 err = vlan_dev_set_egress_priority(args.device1,
688 args.u.skb_priority,
689 args.vlan_qos);
690 break;
692 case SET_VLAN_FLAG_CMD:
693 if (!capable(CAP_NET_ADMIN))
694 return -EPERM;
695 err = vlan_dev_set_vlan_flag(args.device1,
696 args.u.flag,
697 args.vlan_qos);
698 break;
700 case SET_VLAN_NAME_TYPE_CMD:
701 if (!capable(CAP_NET_ADMIN))
702 return -EPERM;
703 if ((args.u.name_type >= 0) &&
704 (args.u.name_type < VLAN_NAME_TYPE_HIGHEST)) {
705 vlan_name_type = args.u.name_type;
706 err = 0;
707 } else {
708 err = -EINVAL;
710 break;
712 case ADD_VLAN_CMD:
713 if (!capable(CAP_NET_ADMIN))
714 return -EPERM;
715 /* we have been given the name of the Ethernet Device we want to
716 * talk to: args.dev1 We also have the
717 * VLAN ID: args.u.VID
719 if (register_vlan_device(args.device1, args.u.VID)) {
720 err = 0;
721 } else {
722 err = -EINVAL;
724 break;
726 case DEL_VLAN_CMD:
727 if (!capable(CAP_NET_ADMIN))
728 return -EPERM;
729 /* Here, the args.dev1 is the actual VLAN we want
730 * to get rid of.
732 err = unregister_vlan_device(args.device1);
733 break;
735 case GET_VLAN_INGRESS_PRIORITY_CMD:
736 /* TODO: Implement
737 err = vlan_dev_get_ingress_priority(args);
738 if (copy_to_user((void*)arg, &args,
739 sizeof(struct vlan_ioctl_args))) {
740 err = -EFAULT;
743 err = -EINVAL;
744 break;
745 case GET_VLAN_EGRESS_PRIORITY_CMD:
746 /* TODO: Implement
747 err = vlan_dev_get_egress_priority(args.device1, &(args.args);
748 if (copy_to_user((void*)arg, &args,
749 sizeof(struct vlan_ioctl_args))) {
750 err = -EFAULT;
753 err = -EINVAL;
754 break;
755 case GET_VLAN_REALDEV_NAME_CMD:
756 err = vlan_dev_get_realdev_name(args.device1, args.u.device2);
757 if (err)
758 goto out;
759 if (copy_to_user(arg, &args,
760 sizeof(struct vlan_ioctl_args))) {
761 err = -EFAULT;
763 break;
765 case GET_VLAN_VID_CMD:
766 err = vlan_dev_get_vid(args.device1, &vid);
767 if (err)
768 goto out;
769 args.u.VID = vid;
770 if (copy_to_user(arg, &args,
771 sizeof(struct vlan_ioctl_args))) {
772 err = -EFAULT;
774 break;
776 default:
777 /* pass on to underlying device instead?? */
778 printk(VLAN_DBG "%s: Unknown VLAN CMD: %x \n",
779 __FUNCTION__, args.cmd);
780 return -EINVAL;
782 out:
783 return err;
786 MODULE_LICENSE("GPL");
787 MODULE_VERSION(DRV_VERSION);