netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@denx.de>
To: kernel list <linux-kernel@vger.kernel.org>,
	fabio.estevam@freescale.com, l.stach@pengutronix.de,
	Frank.Li@freescale.com, netdev@vger.kernel.org
Subject: Freescale FEC: fall back to random address
Date: Sun, 31 Mar 2013 23:06:05 +0200	[thread overview]
Message-ID: <20130331210605.GA29191@amd.pavel.ucw.cz> (raw)

If there's no valid ethernet address, fall back to randomly generated
one.

(Yes, I need to get newer u-boot for the board, but as the only
available one is from 2009... this might be good idea).

Signed-off-by: Pavel Machek <pavel@denx.de>


index e3f3937..5a7d1e1 100644
pp--- a/drivers/net/ethernet/freescale/fec.c
+++ b/drivers/net/ethernet/freescale/fec.c
@@ -906,6 +914,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);
+		netdev_info(ndev, "Using random MAC address: %pM\n", iap);
+	}
+
 	memcpy(ndev->dev_addr, iap, ETH_ALEN);
 
 	/* Adjust MAC if using macaddr */

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

             reply	other threads:[~2013-03-31 21:06 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-31 21:06 Pavel Machek [this message]
2013-04-02  8:23 ` Freescale FEC: fall back to random address Frank Li
2013-04-02 11:35   ` Pavel Machek
     [not found]     ` <CAHrpEqTdTnRx_htZkFyG2KU5wixdhqmWZ-3R5s=fdedQYc6D9w@mail.gmail.com>
2013-04-02 15:49       ` 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=20130331210605.GA29191@amd.pavel.ucw.cz \
    --to=pavel@denx.de \
    --cc=Frank.Li@freescale.com \
    --cc=fabio.estevam@freescale.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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).