All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
To: Lucas Stach <l.stach@pengutronix.de>
Cc: netdev@vger.kernel.org, davem@davemloft.net,
	Pavel Machek <pavel@denx.de>
Subject: Re: [PATCH net-next] net: fec: add fallback to random MAC address
Date: Fri, 31 May 2013 21:57:21 +0400	[thread overview]
Message-ID: <51A8E481.802@cogentembedded.com> (raw)
In-Reply-To: <1370020942-8342-1-git-send-email-l.stach@pengutronix.de>

Hello.

On 05/31/2013 09:22 PM, Lucas Stach wrote:

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

    eth_hw_addr_random(ndev) might be a bit better -- it classifies the MAC
address in 'struct net_device' as random.

WBR, Sergei

  reply	other threads:[~2013-05-31 17:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2013-05-31 23:18   ` 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=51A8E481.802@cogentembedded.com \
    --to=sergei.shtylyov@cogentembedded.com \
    --cc=davem@davemloft.net \
    --cc=l.stach@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=pavel@denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.