Subject: Re: [PATCH net-next] net: fec: add fallback to random MAC address

From: Sergei Shtylyov <[email-masked]>
Date: Fri, 31 May 2013 21:57:21 +0400

Hello.

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

> From: Pavel Machek <[email-masked]>
>
> If no valid MAC address could be obtained from the hardware,
> fall back to a randomly generated one.
>
> Signed-off-by: Pavel Machek <[email-masked]>
> Signed-off-by: Lucas Stach <[email-masked]>
> ---
>   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