diff mbox series

of: net: Add option for random mac address

Message ID 20241010190508.196894-1-igilca1980@gmail.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series of: net: Add option for random mac address | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 5 this patch: 5
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 7 of 7 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 10 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 5 this patch: 5
netdev/source_inline success Was 0 now: 0

Commit Message

Iulian Gilca Oct. 10, 2024, 7:05 p.m. UTC
Embedded devices that may not have fixed mac address
may want to use a randomly generated one.
DSA switch ports are some of these.

Signed-off-by: Iulian Gilca <igilca1980@gmail.com>
---
 net/core/of_net.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Andrew Lunn Oct. 10, 2024, 7:53 p.m. UTC | #1
On Thu, Oct 10, 2024 at 03:05:03PM -0400, Iulian Gilca wrote:
> Embedded devices that may not have fixed mac address
> may want to use a randomly generated one.
> DSA switch ports are some of these.

Sorry, i don't follow what this patch is doing. You are looking in DT
for a property "random-address". DT is static, so how is it going to
be random?

I also don't understand you use case. Generally, a MAC driver will try
to find a fixed MAC address. If one cannot be found, it generates a
random one.

For DSA, it takes the MAC address from the conduit interface for the
user interfaces. If userspace whats to use come other MAC address on
user ports, it can change the MAC address in the usual way.

	Andrew
diff mbox series

Patch

diff --git a/net/core/of_net.c b/net/core/of_net.c
index 93ea425b9248..aa4acdffc710 100644
--- a/net/core/of_net.c
+++ b/net/core/of_net.c
@@ -142,6 +142,10 @@  int of_get_mac_address(struct device_node *np, u8 *addr)
 	if (!ret)
 		return 0;
 
+	ret = of_get_mac_addr(np, "random-address", addr);
+	if (!ret)
+		return 0;
+
 	return of_get_mac_address_nvmem(np, addr);
 }
 EXPORT_SYMBOL(of_get_mac_address);