Browse Source

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

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 11 years ago
parent
commit
c4bce43c3c
1 changed files with 11 additions and 3 deletions
  1. 11
    3
      src/net/netdev_settings.c

+ 11
- 3
src/net/netdev_settings.c View File

61
  */
61
  */
62
 static int netdev_store_mac ( struct net_device *netdev,
62
 static int netdev_store_mac ( struct net_device *netdev,
63
 			      const void *data, size_t len ) {
63
 			      const void *data, size_t len ) {
64
+	struct ll_protocol *ll_protocol = netdev->ll_protocol;
65
+
66
+	/* Record new MAC address */
67
+	if ( data ) {
68
+		if ( len != netdev->ll_protocol->ll_addr_len )
69
+			return -EINVAL;
70
+		memcpy ( netdev->ll_addr, data, len );
71
+	} else {
72
+		/* Reset MAC address if clearing setting */
73
+		ll_protocol->init_addr ( netdev->hw_addr, netdev->ll_addr );
74
+	}
64
 
75
 
65
-	if ( len != netdev->ll_protocol->ll_addr_len )
66
-		return -EINVAL;
67
-	memcpy ( netdev->ll_addr, data, len );
68
 	return 0;
76
 	return 0;
69
 }
77
 }
70
 
78
 

Loading…
Cancel
Save