summaryrefslogtreecommitdiffstats
path: root/src/net/netdev_settings.c
diff options
context:
space:
mode:
authorMichael Brown2013-05-16 16:40:44 +0200
committerMichael Brown2013-05-16 16:41:20 +0200
commitc4bce43c3c4d3c5ebb2d926b58ad16dc9642c19d (patch)
tree57b3c941b89894b20d551cd253983ffdab61ae0f /src/net/netdev_settings.c
parent[netdevice] Add "chip" setting (diff)
downloadipxe-c4bce43c3c4d3c5ebb2d926b58ad16dc9642c19d.tar.gz
ipxe-c4bce43c3c4d3c5ebb2d926b58ad16dc9642c19d.tar.xz
ipxe-c4bce43c3c4d3c5ebb2d926b58ad16dc9642c19d.zip
[netdevice] Reset MAC address when asked to clear the "mac" setting
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/net/netdev_settings.c')
-rw-r--r--src/net/netdev_settings.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/net/netdev_settings.c b/src/net/netdev_settings.c
index 8f66c553..028a62ca 100644
--- a/src/net/netdev_settings.c
+++ b/src/net/netdev_settings.c
@@ -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;
}