linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Torne (Richard Coles)" <torne@google.com>
Cc: nic_swsd@realtek.com, romieu@fr.zoreil.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] r8169: Randomise invalid MAC addresses
Date: Mon, 23 Jan 2012 10:49:33 -0800	[thread overview]
Message-ID: <1327344573.6447.5.camel@joe2Laptop> (raw)
In-Reply-To: <1327343540-30348-1-git-send-email-torne@google.com>

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);
	}



  reply	other threads:[~2012-01-23 18:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-23 18:32 [PATCH] r8169: Randomise invalid MAC addresses Torne (Richard Coles)
2012-01-23 18:49 ` Joe Perches [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1327344573.6447.5.camel@joe2Laptop \
    --to=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nic_swsd@realtek.com \
    --cc=romieu@fr.zoreil.com \
    --cc=torne@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).