net: uclass: Save generated ethernet MAC addresses to the environment
PATCH v3 1/1 net: uclass: Save generated ethernet MAC addresses to the environment
From: Michal Simek <[email protected]>
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.
---
Changes in v3:
- Update Kconfig help text with Wolfgang's suggestion
- Reword the commit message to hopefully be clearer
Changes in v2:
- Update Kconfig help text to reflect this change.
- Update the legacy path to match.
--- net/Kconfig | 9 +++++---- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-)
net/Kconfig +5 -4
@@ -27,10 +27,11 @@ config BOOTP_SEND_HOSTNAME config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help - Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. config NETCONSOLE bool "NetConsole support"
net/eth-uclass.c +2 -0
@@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev)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);
net/eth_legacy.c +2 -0
@@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,net_random_ethaddr (dev->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , dev->name, eth_number, dev->enetaddr); +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), + pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name);
Signature · 1 line
2.25.1
Quoted 74 lines · Tom Rini
From: Michal Simek <[email protected]>
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 <[email protected]>Signed-off-by Michal Simek <[email protected]>Reviewed-by Ramon Fried <[email protected]>[trini: Update Kconfig, handle legacy networking case as well]Signed-off-by Tom Rini <[email protected]>---
Changes in v3:
- UpdateKconfighelp text with Wolfgang's suggestion
- Reword the commit message to hopefully be clearerChanges in v2:
- UpdateKconfighelp text to reflect this change.
- Update the legacy path to match.--- net/Kconfig | 9 +++++---- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-)net/Kconfig +5
-4@@ -27,10 +27,11 @@ config BOOTP_SEND_HOSTNAME config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help - Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. config NETCONSOLE bool "NetConsole support"net/eth-uclass.c +2
-0@@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev)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);net/eth_legacy.c +2
-1@@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,net_random_ethaddr (dev->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , dev->name, eth_number, dev->enetaddr); +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), + pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name); --
Quoted 2 lines
2.25.1
so 27. 11. 2021 v 20:37 odesílatel Ramon Fried <[email protected]> napsal:
Quoted 71 lines · Tom Rini
Quoted 69 lines
From: Michal Simek <[email protected]>
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 <[email protected]>Signed-off-by Michal Simek <[email protected]>Reviewed-by Ramon Fried <[email protected]>[trini: Update Kconfig, handle legacy networking case as well]Signed-off-by Tom Rini <[email protected]>---
Changes in v3:
- UpdateKconfighelp text with Wolfgang's suggestion
- Reword the commit message to hopefully be clearerChanges in v2:
- UpdateKconfighelp text to reflect this change.
- Update the legacy path to match.--- net/Kconfig | 9 +++++---- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-)net/Kconfig +5
-4@@ -27,10 +27,11 @@ config BOOTP_SEND_HOSTNAME config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help - Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. config NETCONSOLE bool "NetConsole support"net/eth-uclass.c +2
-0@@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev)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);net/eth_legacy.c +1
-0@@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,net_random_ethaddr (dev->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , dev->name, eth_number, dev->enetaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev),
Quoted 8 lines
Quoted 7 lines
net/eth_legacy.c +1
-1+ pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name); --2.25.1
Acked-by Ramon Fried <[email protected]>
Ramon/Tom: Did anybody take this patch? Or you want me to take it?
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs
Quoted 81 lines · Michal Simek
so 27. 11. 2021 v 20:37 odesílatel Ramon Fried <[email protected]> napsal:
Quoted 71 lines · Tom Rini
Quoted 69 lines
From: Michal Simek <[email protected]>
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 <[email protected]>Signed-off-by Michal Simek <[email protected]>Reviewed-by Ramon Fried <[email protected]>[trini: Update Kconfig, handle legacy networking case as well]Signed-off-by Tom Rini <[email protected]>---
Changes in v3:
- UpdateKconfighelp text with Wolfgang's suggestion
- Reword the commit message to hopefully be clearerChanges in v2:
- UpdateKconfighelp text to reflect this change.
- Update the legacy path to match.--- net/Kconfig | 9 +++++---- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-)net/Kconfig +5
-4@@ -27,10 +27,11 @@ config BOOTP_SEND_HOSTNAME config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help - Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. config NETCONSOLE bool "NetConsole support"net/eth-uclass.c +2
-0@@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev)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);net/eth_legacy.c +1
-0@@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,net_random_ethaddr (dev->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , dev->name, eth_number, dev->enetaddr); + eth_env_set_enetaddr_by_index("eth", dev_seq(dev),Quoted 8 lines
Quoted 7 lines
net/eth_legacy.c +1
-1+ pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name); --2.25.1
Acked-by Ramon Fried <[email protected]>
Quoted 1 line
Ramon/Tom: Did anybody take this patch? Or you want me to take it?
I don't think I picked it up, and I'm fine with it coming via your tree.
Signature · 1 line
Tom
Michal Simek
AppliedQuoted 82 lines · Tom Rini
Quoted 81 lines · Michal Simek
so 27. 11. 2021 v 20:37 odesílatel Ramon Fried <[email protected]> napsal:
Quoted 79 lines · Tom Rini
Quoted 74 lines
From: Michal Simek <[email protected]>
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 <[email protected]>Signed-off-by Michal Simek <[email protected]>Reviewed-by Ramon Fried <[email protected]>[trini: Update Kconfig, handle legacy networking case as well]Signed-off-by Tom Rini <[email protected]>---
Changes in v3:
- UpdateKconfighelp text with Wolfgang's suggestion
- Reword the commit message to hopefully be clearerChanges in v2:
- UpdateKconfighelp text to reflect this change.
- Update the legacy path to match.--- net/Kconfig | 9 +++++---- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-)net/Kconfig +5
-4@@ -27,10 +27,11 @@ config BOOTP_SEND_HOSTNAME config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help - Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. config NETCONSOLE bool "NetConsole support"net/eth-uclass.c +2
-0@@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev)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);net/eth_legacy.c +2
-1@@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,net_random_ethaddr (dev->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , dev->name, eth_number, dev->enetaddr); +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), + pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name); --Quoted 2 lines
2.25.1
Acked-by Ramon Fried <[email protected]>
Quoted 4 lines
Quoted 1 line
Ramon/Tom: Did anybody take this patch? Or you want me to take it?
I don't think I picked it up, and I'm fine with it coming via your tree.
Applied.
M
po 10. 1. 2022 v 15:09 odesílatel Michal Simek <[email protected]> napsal:
Quoted 86 lines · Tom Rini
Quoted 82 lines · Michal Simek
Quoted 81 lines
so 27. 11. 2021 v 20:37 odesílatel Ramon Fried <[email protected]> napsal:
Quoted 79 lines · Tom Rini
Quoted 74 lines
From: Michal Simek <[email protected]>
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 <[email protected]>Signed-off-by Michal Simek <[email protected]>Reviewed-by Ramon Fried <[email protected]>[trini: Update Kconfig, handle legacy networking case as well]Signed-off-by Tom Rini <[email protected]>---
Changes in v3:
- UpdateKconfighelp text with Wolfgang's suggestion
- Reword the commit message to hopefully be clearerChanges in v2:
- UpdateKconfighelp text to reflect this change.
- Update the legacy path to match.--- net/Kconfig | 9 +++++---- net/eth-uclass.c | 2 ++ net/eth_legacy.c | 2 ++ 3 files changed, 9 insertions(+), 4 deletions(-)net/Kconfig +5
-4@@ -27,10 +27,11 @@ config BOOTP_SEND_HOSTNAME config NET_RANDOM_ETHADDR bool "Random ethaddr if unset" help - Selecting this will allow the Ethernet interface to function - even when the ethaddr variable for that interface is unset. - A new MAC address will be generated on every boot and it will - not be added to the environment. + Selecting this will allow the Ethernet interface to function even + when the ethaddr variable for that interface is unset. In this case, + a random MAC address in the locally administered address space is + generated. It will be saved to the appropriate environment variable, + too. config NETCONSOLE bool "NetConsole support"net/eth-uclass.c +2
-0@@ -583,6 +583,8 @@ static int eth_post_probe(struct udevice *dev)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);net/eth_legacy.c +2
-1@@ -164,6 +164,8 @@ int eth_write_hwaddr(struct eth_device *dev, const char *base_name,net_random_ethaddr (dev->enetaddr);printf ("\nWarning: %s (eth%d) using random MAC address - %pM\n" , dev->name, eth_number, dev->enetaddr); +eth_env_set_enetaddr_by_index ("eth" ,dev_seq (dev), + pdata->enetaddr);#else printf ("\nError: %s address not set.\n" , dev->name); --Quoted 2 lines
2.25.1
Acked-by Ramon Fried <[email protected]>
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Ramon/Tom: Did anybody take this patch? Or you want me to take it?
I don't think I picked it up, and I'm fine with it coming via your tree.
Applied.
M
CI found that legacy case code is broken. It was just c&p from DM case that's why I removed it from my queue and sent v4
version.
Thanks,
Michal
Signature · 5 lines
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91 w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel - Xilinx Microblaze Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs