net: uclass: Save generated ethernet MAC addresses to the environment
When a MAC address is randomly generated we currently only update the
appropriate data structure. For consistency and to re-align with
historic usage, it should be also saved to the appropriate environment
variable as well.
Cc: Wolfgang Denk <wd@denx.de>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
[trini: Update Kconfig, handle legacy networking case as well]
Signed-off-by: Tom Rini <trini@konsulko.com>
Acked-by: Ramon Fried <rfried.dev@gmail.com>
Link: https://lore.kernel.org/r/1a2518e3cc19c14a41875ef64c5acc1f16edc813.1641893287.git.michal.simek@xilinx.com
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 0da0e85..58c308f 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -583,6 +583,8 @@
net_random_ethaddr(pdata->enetaddr);
printf("\nWarning: %s (eth%d) using random MAC address - %pM\n",
dev->name, dev_seq(dev), pdata->enetaddr);
+ eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
+ pdata->enetaddr);
#else
printf("\nError: %s address not set.\n",
dev->name);