net: use random ethernet address if invalid and not zero
authorSiva Durga Prasad Paladugu <siva.durga.paladugu@xilinx.com>
Wed, 2 Nov 2016 11:52:13 +0000 (12:52 +0100)
committerJoe Hershberger <joe.hershberger@ni.com>
Mon, 7 Nov 2016 17:28:16 +0000 (11:28 -0600)
Use random ethernet address if the ethernet address found
is invalid, not zero and config for random address
is defined.

Signed-off-by: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
net/eth-uclass.c

index a32961e6ceaae8e819a247c1f30bac24b3bc370f..1d130110890ec402048fea58eb1a52461e9899a0 100644 (file)
@@ -512,7 +512,8 @@ static int eth_post_probe(struct udevice *dev)
                eth_setenv_enetaddr_by_index("eth", dev->seq, pdata->enetaddr);
                printf("\nWarning: %s using MAC address from ROM\n",
                       dev->name);
-       } else if (is_zero_ethaddr(pdata->enetaddr)) {
+       } else if (is_zero_ethaddr(pdata->enetaddr) ||
+                  !is_valid_ethaddr(pdata->enetaddr)) {
 #ifdef CONFIG_NET_RANDOM_ETHADDR
                net_random_ethaddr(pdata->enetaddr);
                printf("\nWarning: %s (eth%d) using random MAC address - %pM\n",