netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: fec: add fallback to random MAC address
@ 2013-05-31 17:22 Lucas Stach
  2013-05-31 17:57 ` Sergei Shtylyov
  0 siblings, 1 reply; 3+ messages in thread
From: Lucas Stach @ 2013-05-31 17:22 UTC (permalink / raw)
  To: netdev; +Cc: davem, Pavel Machek, Lucas Stach

From: Pavel Machek <pavel@denx.de>

If no valid MAC address could be obtained from the hardware,
fall back to a randomly generated one.

Signed-off-by: Pavel Machek <pavel@denx.de>
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/net/ethernet/freescale/fec_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 9b0c647..3694a56 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -1037,6 +1037,16 @@ static void fec_get_mac(struct net_device *ndev)
 		iap = &tmpaddr[0];
 	}
 
+	/*
+	 * 5) random mac address
+	 */
+	if (!is_valid_ether_addr(iap)) {
+		/* Report it and use a random ethernet address instead */
+		netdev_err(ndev, "Invalid MAC address: %pM\n", iap);
+		random_ether_addr(iap);
+		netdev_info(ndev, "Using random MAC address: %pM\n", iap);
+	}
+
 	memcpy(ndev->dev_addr, iap, ETH_ALEN);
 
 	/* Adjust MAC if using macaddr */
-- 
1.8.2.rc2

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-05-31 23:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-31 17:22 [PATCH net-next] net: fec: add fallback to random MAC address Lucas Stach
2013-05-31 17:57 ` Sergei Shtylyov
2013-05-31 23:18   ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).