2013-03-31 21:06:08

by Pavel Machek

[permalink] [raw]
Subject: Freescale FEC: fall back to random address

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 <[email protected]>


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


2013-04-02 08:23:19

by Zhi Li

[permalink] [raw]
Subject: Re: Freescale FEC: fall back to random address

I think it is okay.

2013/4/1 Pavel Machek <[email protected]>:
> 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 <[email protected]>
>
>
> 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
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2013-04-02 11:35:37

by Pavel Machek

[permalink] [raw]
Subject: Re: Freescale FEC: fall back to random address

Hi!

> I think it is okay.

Ok, now... is there someone maintianing Freescale FEC? Or, Dave, can
you merge the patch?

Thanks,
Pavel


> 2013/4/1 Pavel Machek <[email protected]>:
> > 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 <[email protected]>
> >
> >
> > 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

2013-04-02 15:49:35

by David Miller

[permalink] [raw]
Subject: Re: Freescale FEC: fall back to random address

From: Frank Li <[email protected]>
Date: Tue, 2 Apr 2013 21:23:17 +0800

> David will merge it

Someone needs to make a clean resubmission of it though, thanks.