[ipxe-devel] [PATCH 1/2] igbvf: Assign random MAC address if none is set

Hannes Reinecke hare at suse.de
Tue Jun 3 12:01:16 UTC 2014


If the VF doesn't have a MAC address assigned we should create
a random MAC address. Not doing so results in the probe function
to abort and an unuseable device.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 src/drivers/net/igbvf/igbvf_main.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/src/drivers/net/igbvf/igbvf_main.c b/src/drivers/net/igbvf/igbvf_main.c
index cd189ec..c4d1b0d 100644
--- a/src/drivers/net/igbvf/igbvf_main.c
+++ b/src/drivers/net/igbvf/igbvf_main.c
@@ -871,16 +871,20 @@ int igbvf_probe ( struct pci_device *pdev )
 			DBG ("Error reading MAC address\n");
 			goto err_hw_init;
 		}
+		if ( ! is_valid_ether_addr(adapter->hw.mac.addr) ) {
+			/* Assign random MAC address */
+			eth_random_addr(adapter->hw.mac.addr);
+		}
 	}
 
 	memcpy ( netdev->hw_addr, adapter->hw.mac.addr, ETH_ALEN );
 
 	if ( ! is_valid_ether_addr( netdev->hw_addr ) ) {
 		DBG ("Invalid MAC Address: "
-		        "%02x:%02x:%02x:%02x:%02x:%02x\n",
-		        netdev->hw_addr[0], netdev->hw_addr[1],
-		        netdev->hw_addr[2], netdev->hw_addr[3],
-		        netdev->hw_addr[4], netdev->hw_addr[5]);
+		     "%02x:%02x:%02x:%02x:%02x:%02x\n",
+		     netdev->hw_addr[0], netdev->hw_addr[1],
+		     netdev->hw_addr[2], netdev->hw_addr[3],
+		     netdev->hw_addr[4], netdev->hw_addr[5]);
 		err = -EIO;
 		goto err_hw_init;
 	}
-- 
1.8.4.5




More information about the ipxe-devel mailing list