Sfoglia il codice sorgente

[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 anni fa
parent
commit
c4bce43c3c
1 ha cambiato i file con 11 aggiunte e 3 eliminazioni
  1. 11
    3
      src/net/netdev_settings.c

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

@@ -61,10 +61,18 @@ struct setting chip_setting __setting ( SETTING_NETDEV ) = {
61 61
  */
62 62
 static int netdev_store_mac ( struct net_device *netdev,
63 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 76
 	return 0;
69 77
 }
70 78
 

Loading…
Annulla
Salva