david/ipxe
Archived
1
0

[netdevice] Reset MAC address when asked to clear the "mac" setting

Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
Michael Brown 2013-05-16 15:40:44 +01:00
parent 08bf79582a
commit c4bce43c3c

View File

@ -61,10 +61,18 @@ struct setting chip_setting __setting ( SETTING_NETDEV ) = {
*/
static int netdev_store_mac ( struct net_device *netdev,
const void *data, size_t len ) {
struct ll_protocol *ll_protocol = netdev->ll_protocol;
/* Record new MAC address */
if ( data ) {
if ( len != netdev->ll_protocol->ll_addr_len )
return -EINVAL;
memcpy ( netdev->ll_addr, data, len );
} else {
/* Reset MAC address if clearing setting */
ll_protocol->init_addr ( netdev->hw_addr, netdev->ll_addr );
}
if ( len != netdev->ll_protocol->ll_addr_len )
return -EINVAL;
memcpy ( netdev->ll_addr, data, len );
return 0;
}