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 |
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 --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);
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(+)