]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[netdevice] Reset MAC address when asked to clear the "mac" setting
authorMichael Brown <mcb30@ipxe.org>
Thu, 16 May 2013 14:40:44 +0000 (15:40 +0100)
committerMichael Brown <mcb30@ipxe.org>
Thu, 16 May 2013 14:41:20 +0000 (15:41 +0100)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/netdev_settings.c

index 8f66c5538d42dcf95e70a841c53b84a55cd6641a..028a62ca8f38531abd84d9b6120a8a7f99ba325d 100644 (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;
 }