net: use random ethernet address if invalid and not zero

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>
This commit is contained in:
Siva Durga Prasad Paladugu 2016-11-02 12:52:13 +01:00 committed by Joe Hershberger
parent 6ecf9e21b5
commit aa555fe9f0

View 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",