Patchwork smsc95xx: panda: don't blindly overwrite MAC address

login
register
mail settings
Submitter Paolo Pisati
Date Feb. 21, 2012, 10:47 a.m.
Message ID <1329821231-7144-2-git-send-email-paolo.pisati@canonical.com>
Download mbox | patch
Permalink /patch/142280/
State New
Headers show

Comments

Paolo Pisati - Feb. 21, 2012, 10:47 a.m.
During eth0 registration (NETDEV_REGISTER) don't blindly overwrite
eth0 MAC address using die id supplied one, but check if the
actual MAC was randomly generated and, only in that case, overwrite it.

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
---
 arch/arm/mach-omap2/board-omap4panda.c |    4 ++++
 drivers/net/usb/smsc95xx.c             |    2 +-
 2 files changed, 5 insertions(+), 1 deletions(-)
Tim Gardner - Feb. 22, 2012, 9:51 p.m.

Patch

diff --git a/arch/arm/mach-omap2/board-omap4panda.c b/arch/arm/mach-omap2/board-omap4panda.c
index 035d56f..f1e8e6d 100644
--- a/arch/arm/mach-omap2/board-omap4panda.c
+++ b/arch/arm/mach-omap2/board-omap4panda.c
@@ -738,6 +738,10 @@  static int omap_panda_netdev_event(struct notifier_block *this,
 	if (event != NETDEV_REGISTER)
 		return NOTIFY_DONE;
 
+	if (strncmp(dev->name, "eth0", 4) == 0 &&
+		!(dev->addr_assign_type & NET_ADDR_RANDOM))
+		return NOTIFY_DONE;
+
 	n = panda_device_path_need_mac(dev->dev.parent);
 	if (n >= 0) {
 		sa.sa_family = dev->type;
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c
index 89b51bd..ea95dd1 100644
--- a/drivers/net/usb/smsc95xx.c
+++ b/drivers/net/usb/smsc95xx.c
@@ -669,7 +669,7 @@  static void smsc95xx_init_mac_address(struct usbnet *dev)
 	}
 
 	/* no eeprom, or eeprom values are invalid. generate random MAC */
-	random_ether_addr(dev->net->dev_addr);
+	dev_hw_addr_random(dev->net, dev->net->dev_addr);
 	netif_dbg(dev, ifup, dev->net, "MAC address set to random_ether_addr\n");
 }