[vlan] Provide vlan_can_be_trunk()
Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
parent
f1e1545372
commit
b4706c88c9
|
@ -59,6 +59,7 @@ struct vlan_header {
|
||||||
*/
|
*/
|
||||||
#define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
|
#define VLAN_PRIORITY_IS_VALID( priority ) ( (priority) <= 7 )
|
||||||
|
|
||||||
|
extern int vlan_can_be_trunk ( struct net_device *trunk );
|
||||||
extern int vlan_create ( struct net_device *trunk, unsigned int tag,
|
extern int vlan_create ( struct net_device *trunk, unsigned int tag,
|
||||||
unsigned int priority );
|
unsigned int priority );
|
||||||
extern int vlan_destroy ( struct net_device *netdev );
|
extern int vlan_destroy ( struct net_device *netdev );
|
||||||
|
|
|
@ -280,20 +280,35 @@ struct net_protocol vlan_protocol __net_protocol = {
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create VLAN device
|
* Check if network device can be used as a VLAN trunk device
|
||||||
*
|
*
|
||||||
* @v trunk Trunk network device
|
* @v trunk Trunk network device
|
||||||
* @v tag VLAN tag
|
* @ret is_ok Trunk network device is usable
|
||||||
* @v priority Default VLAN priority
|
|
||||||
* @ret rc Return status code
|
|
||||||
*
|
*
|
||||||
* The VLAN device will be created as an Ethernet device. (We cannot
|
* VLAN devices will be created as Ethernet devices. (We cannot
|
||||||
* simply clone the link layer of the trunk network device, because
|
* simply clone the link layer of the trunk network device, because
|
||||||
* this link layer may expect the network device structure to contain
|
* this link layer may expect the network device structure to contain
|
||||||
* some link-layer-private data.) The trunk network device must
|
* some link-layer-private data.) The trunk network device must
|
||||||
* therefore have a link layer that is in some sense 'compatible' with
|
* therefore have a link layer that is in some sense 'compatible' with
|
||||||
* Ethernet; specifically, it must have link-layer addresses that are
|
* Ethernet; specifically, it must have link-layer addresses that are
|
||||||
* the same length as Ethernet link-layer addresses.
|
* the same length as Ethernet link-layer addresses.
|
||||||
|
*
|
||||||
|
* As an additional check, and primarily to assist with the sanity of
|
||||||
|
* the FCoE code, we refuse to allow nested VLANs.
|
||||||
|
*/
|
||||||
|
int vlan_can_be_trunk ( struct net_device *trunk ) {
|
||||||
|
|
||||||
|
return ( ( trunk->ll_protocol->ll_addr_len == ETH_ALEN ) &&
|
||||||
|
( trunk->op != &vlan_operations ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create VLAN device
|
||||||
|
*
|
||||||
|
* @v trunk Trunk network device
|
||||||
|
* @v tag VLAN tag
|
||||||
|
* @v priority Default VLAN priority
|
||||||
|
* @ret rc Return status code
|
||||||
*/
|
*/
|
||||||
int vlan_create ( struct net_device *trunk, unsigned int tag,
|
int vlan_create ( struct net_device *trunk, unsigned int tag,
|
||||||
unsigned int priority ) {
|
unsigned int priority ) {
|
||||||
|
@ -313,9 +328,9 @@ int vlan_create ( struct net_device *trunk, unsigned int tag,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sanity checks */
|
/* Sanity checks */
|
||||||
if ( trunk->ll_protocol->ll_addr_len != ETH_ALEN ) {
|
if ( ! vlan_can_be_trunk ( trunk ) ) {
|
||||||
DBGC ( trunk, "VLAN %s cannot create VLAN for %s device\n",
|
DBGC ( trunk, "VLAN %s cannot create VLAN on non-trunk "
|
||||||
trunk->name, trunk->ll_protocol->name );
|
"device\n", trunk->name );
|
||||||
rc = -ENOTTY;
|
rc = -ENOTTY;
|
||||||
goto err_sanity;
|
goto err_sanity;
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue