lkml.org 
[lkml]   [2012]   [Jan]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH] r8169: Randomise invalid MAC addresses
From
Date
On Mon, 2012-01-23 at 18:32 +0000, Torne (Richard Coles) wrote:
> 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.
[]
> diff --git 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);

Perhaps this should be on 1 line.
If KERN_level filtering is higher then KERN_INFO,
the new MAC will not be shown.

if (!is_valid_ether_addr(dev->dev_addr)) {
u8 mac[ETH_ALEN];
random_ether_addr(mac);
netdev_err(dev, "Hardware has invalid mac address %pM, using %pM\n",
dev->dev_addr, mac);
memcpy(dev->dev_addr, mac, ETH_ALEN);
}



\
 
 \ /
  Last update: 2012-01-23 19:51    [from the cache]
©2003-2011 Jasper Spaans