linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] r8169: Randomise invalid MAC addresses
@ 2012-01-23 18:32 Torne (Richard Coles)
  2012-01-23 18:49 ` Joe Perches
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Torne (Richard Coles) @ 2012-01-23 18:32 UTC (permalink / raw)
  To: nic_swsd, romieu; +Cc: netdev, linux-kernel, Torne (Richard Coles)

From: "Torne (Richard Coles)" <torne@google.com>

If the default MAC address stored in the card is invalid, replace it
with a random address and complain about it.

Signed-off-by: Torne (Richard Coles) <torne@google.com>
---
 drivers/net/ethernet/realtek/r8169.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 7a0c800..ec5ebbb 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -4103,6 +4103,14 @@ rtl8169_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	/* Get MAC address */
 	for (i = 0; i < ETH_ALEN; i++)
 		dev->dev_addr[i] = RTL_R8(MAC0 + i);
+
+	if (!is_valid_ether_addr(dev->dev_addr)) {
+		/* Report it and use a random ethernet address instead */
+		netdev_err(dev, "Invalid MAC address: %pM\n", dev->dev_addr);
+		random_ether_addr(dev->dev_addr);
+		netdev_info(dev, "Using random MAC address: %pM\n",
+			    dev->dev_addr);
+	}
 	memcpy(dev->perm_addr, dev->dev_addr, dev->addr_len);
 
 	SET_ETHTOOL_OPS(dev, &rtl8169_ethtool_ops);
-- 
1.7.7.3


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

end of thread, other threads:[~2012-01-24 20:20 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-23 18:32 [PATCH] r8169: Randomise invalid MAC addresses Torne (Richard Coles)
2012-01-23 18:49 ` Joe Perches
2012-01-23 20:53 ` Paul Gortmaker
2012-01-23 21:35   ` Torne (Richard Coles)
2012-01-23 21:43     ` Alan Cox
2012-01-24 13:29       ` Torne (Richard Coles)
2012-01-23 21:29 ` Alan Cox
2012-01-24 17:15   ` Pavel Machek
2012-01-24 18:28     ` Francois Romieu
2012-01-24 18:47       ` Ben Hutchings
2012-01-24 20:19         ` 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).