[VLAN]: Split up device checks
Move the checks of the underlying device to a seperate function. Signed-off-by: Patrick McHardy <kaber@trash.net> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
committed by
David S. Miller
parent
42429aaee5
commit
c1d3ee9925
@@ -410,6 +410,43 @@ static void vlan_transfer_operstate(const struct net_device *dev, struct net_dev
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int vlan_check_real_dev(struct net_device *real_dev, unsigned short vlan_id)
|
||||||
|
{
|
||||||
|
if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
|
||||||
|
printk(VLAN_DBG "%s: VLANs not supported on %s.\n",
|
||||||
|
__FUNCTION__, real_dev->name);
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
|
||||||
|
!real_dev->vlan_rx_register) {
|
||||||
|
printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
|
||||||
|
__FUNCTION__, real_dev->name);
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
|
||||||
|
(!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
|
||||||
|
printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
|
||||||
|
__FUNCTION__, real_dev->name);
|
||||||
|
return -EOPNOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The real device must be up and operating in order to
|
||||||
|
* assosciate a VLAN device with it.
|
||||||
|
*/
|
||||||
|
if (!(real_dev->flags & IFF_UP))
|
||||||
|
return -ENETDOWN;
|
||||||
|
|
||||||
|
if (__find_vlan_dev(real_dev, vlan_id) != NULL) {
|
||||||
|
/* was already registered. */
|
||||||
|
printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__);
|
||||||
|
return -EEXIST;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* Attach a VLAN device to a mac address (ie Ethernet Card).
|
/* Attach a VLAN device to a mac address (ie Ethernet Card).
|
||||||
* Returns the device that was created, or NULL if there was
|
* Returns the device that was created, or NULL if there was
|
||||||
* an error of some kind.
|
* an error of some kind.
|
||||||
@@ -429,37 +466,8 @@ static struct net_device *register_vlan_device(struct net_device *real_dev,
|
|||||||
if (VLAN_ID >= VLAN_VID_MASK)
|
if (VLAN_ID >= VLAN_VID_MASK)
|
||||||
goto out_ret_null;
|
goto out_ret_null;
|
||||||
|
|
||||||
if (real_dev->features & NETIF_F_VLAN_CHALLENGED) {
|
if (vlan_check_real_dev(real_dev, VLAN_ID) < 0)
|
||||||
printk(VLAN_DBG "%s: VLANs not supported on %s.\n",
|
|
||||||
__FUNCTION__, real_dev->name);
|
|
||||||
goto out_ret_null;
|
goto out_ret_null;
|
||||||
}
|
|
||||||
|
|
||||||
if ((real_dev->features & NETIF_F_HW_VLAN_RX) &&
|
|
||||||
!real_dev->vlan_rx_register) {
|
|
||||||
printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
|
|
||||||
__FUNCTION__, real_dev->name);
|
|
||||||
goto out_ret_null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((real_dev->features & NETIF_F_HW_VLAN_FILTER) &&
|
|
||||||
(!real_dev->vlan_rx_add_vid || !real_dev->vlan_rx_kill_vid)) {
|
|
||||||
printk(VLAN_DBG "%s: Device %s has buggy VLAN hw accel.\n",
|
|
||||||
__FUNCTION__, real_dev->name);
|
|
||||||
goto out_ret_null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* The real device must be up and operating in order to
|
|
||||||
* assosciate a VLAN device with it.
|
|
||||||
*/
|
|
||||||
if (!(real_dev->flags & IFF_UP))
|
|
||||||
goto out_ret_null;
|
|
||||||
|
|
||||||
if (__find_vlan_dev(real_dev, VLAN_ID) != NULL) {
|
|
||||||
/* was already registered. */
|
|
||||||
printk(VLAN_DBG "%s: ALREADY had VLAN registered\n", __FUNCTION__);
|
|
||||||
goto out_ret_null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Gotta set up the fields for the device. */
|
/* Gotta set up the fields for the device. */
|
||||||
#ifdef VLAN_DEBUG
|
#ifdef VLAN_DEBUG
|
||||||
|
Reference in New Issue
Block a user