diff options
Diffstat (limited to 'net/8021q/vlan.c')
-rw-r--r-- | net/8021q/vlan.c | 56 |
1 files changed, 32 insertions, 24 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 1b9dc5ecd448..1e33dbb85d14 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -410,57 +410,65 @@ static void vlan_transfer_operstate(const struct net_device *dev, struct net_dev | |||
410 | } | 410 | } |
411 | } | 411 | } |
412 | 412 | ||
413 | /* Attach a VLAN device to a mac address (ie Ethernet Card). | 413 | static int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id) |
414 | * Returns the device that was created, or NULL if there was | ||
415 | * an error of some kind. | ||
416 | */ | ||
417 | static struct net_device *register_vlan_device(struct net_device *real_dev, | ||
418 | unsigned short VLAN_ID) | ||
419 | { | 414 | { |
420 | struct vlan_group *grp, *ngrp = NULL; | ||
421 | struct net_device *new_dev; | ||
422 | char name[IFNAMSIZ]; | ||
423 | |||
424 | #ifdef VLAN_DEBUG | ||
425 | printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n", | ||
426 | __FUNCTION__, eth_IF_name, VLAN_ID); | ||
427 | #endif | ||
428 | |||
429 | if (VLAN_ID >= VLAN_VID_MASK) | ||
430 | goto out_ret_null; | ||
431 | |||
432 | if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { | 415 | if (real_dev->features & NETIF_F_VLAN_CHALLENGED) { |
433 | printk(VLAN_DBG "%s: VLANs not supported on %s.\n", | 416 | printk(VLAN_DBG "%s: VLANs not supported on %s.\n", |
434 | __FUNCTION__, real_dev->name); | 417 | __FUNCTION__, real_dev->name); |
435 | goto out_ret_null; | 418 | return -EOPNOTSUPP; |
436 | } | 419 | } |
437 | 420 | ||
438 | if ((real_dev->features & NETIF_F_HW_VLAN_RX) && | 421 | if ((real_dev->features & NETIF_F_HW_VLAN_RX) && |
439 | !real_dev->vlan_rx_register) { | 422 | !real_dev->vlan_rx_register) { |
440 | printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", | 423 | printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", |
441 | __FUNCTION__, real_dev->name); | 424 | __FUNCTION__, real_dev->name); |
442 | goto out_ret_null; | 425 | return -EOPNOTSUPP; |
443 | } | 426 | } |
444 | 427 | ||
445 | if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && | 428 | if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) && |
446 | (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) { | 429 | (!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) { |
447 | printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", | 430 | printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n", |
448 | __FUNCTION__, real_dev->name); | 431 | __FUNCTION__, real_dev->name); |
449 | goto out_ret_null; | 432 | return -EOPNOTSUPP; |
450 | } | 433 | } |
451 | 434 | ||
452 | /* The real device must be up and operating in order to | 435 | /* The real device must be up and operating in order to |
453 | * assosciate a VLAN device with it. | 436 | * assosciate a VLAN device with it. |
454 | */ | 437 | */ |
455 | if (!(real_dev->flags & IFF_UP)) | 438 | if (!(real_dev->flags & IFF_UP)) |
456 | goto out_ret_null; | 439 | return -ENETDOWN; |
457 | 440 | ||
458 | if (__find_vlan_dev(real_dev, VLAN_ID) != NULL) { | 441 | if (__find_vlan_dev(real_dev, vlan_id) != NULL) { |
459 | /* was already registered. */ | 442 | /* was already registered. */ |
460 | printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__); | 443 | printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__); |
461 | goto out_ret_null; | 444 | return -EEXIST; |
462 | } | 445 | } |
463 | 446 | ||
447 | return 0; | ||
448 | } | ||
449 | |||
450 | /* Attach a VLAN device to a mac address (ie Ethernet Card). | ||
451 | * Returns the device that was created, or NULL if there was | ||
452 | * an error of some kind. | ||
453 | */ | ||
454 | static struct net_device *register_vlan_device(struct net_device *real_dev, | ||
455 | unsigned short VLAN_ID) | ||
456 | { | ||
457 | struct vlan_group *grp, *ngrp = NULL; | ||
458 | struct net_device *new_dev; | ||
459 | char name[IFNAMSIZ]; | ||
460 | |||
461 | #ifdef VLAN_DEBUG | ||
462 | printk(VLAN_DBG "%s: if_name -:%s:- vid: %i\n", | ||
463 | __FUNCTION__, eth_IF_name, VLAN_ID); | ||
464 | #endif | ||
465 | |||
466 | if (VLAN_ID >= VLAN_VID_MASK) | ||
467 | goto out_ret_null; | ||
468 | |||
469 | if (vlan_check_real_dev(real_dev, VLAN_ID) < 0) | ||
470 | goto out_ret_null; | ||
471 | |||
464 | /* Gotta set up the fields for the device. */ | 472 | /* Gotta set up the fields for the device. */ |
465 | #ifdef VLAN_DEBUG | 473 | #ifdef VLAN_DEBUG |
466 | printk(VLAN_DBG "About to allocate name, vlan_name_type: %i\n", | 474 | printk(VLAN_DBG "About to allocate name, vlan_name_type: %i\n", |