* [PATCH net] net: sparx5: make ports inherit the switch base mac address type
@ 2026-09-28 4:50 Quentin Freimanis
2026-09-28 10:11 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Quentin Freimanis @ 2026-09-28 4:50 UTC (permalink / raw)
To: netdev
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Steen Hegelund, Daniel Machon, UNGLinuxDriver,
Lars Povlsen, Bjarni Jonasson, linux-arm-kernel, linux-kernel
When the switch uses a random base MAC address it does not mark each
port's address as random:
$ dmesg | grep "MAC addr"
sparx5-switch e00c0000.switch: MAC addr was not set, use random MAC
$ cat /sys/class/net/eth0/addr_assign_type
0
0 is NET_ADDR_PERM, so userspace thinks this is a stable address. Fix by
tracking the base MAC address assign type in the sparx5 struct and
applying it to each port's netdev.
Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support")
Signed-off-by: Quentin Freimanis <quentin@q-lab.dev>
---
drivers/net/ethernet/microchip/sparx5/sparx5_main.c | 1 +
drivers/net/ethernet/microchip/sparx5/sparx5_main.h | 1 +
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c | 1 +
3 files changed, 3 insertions(+)
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
index dad713e9ddd5..b530fb6d3d0c 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.c
@@ -898,6 +898,7 @@ static int mchp_sparx5_probe(struct platform_device *pdev)
dev_info(sparx5->dev, "MAC addr was not set, use random MAC\n");
eth_random_addr(sparx5->base_mac);
sparx5->base_mac[5] = 0;
+ sparx5->base_mac_assign_type = NET_ADDR_RANDOM;
}
sparx5->fdma_irq = platform_get_irq_byname(sparx5->pdev, "fdma");
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
index eb57b86fbe22..0f7d8440f614 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_main.h
@@ -392,6 +392,7 @@ struct sparx5 {
struct notifier_block switchdev_blocking_nb;
/* Switch state */
u8 base_mac[ETH_ALEN];
+ u8 base_mac_assign_type;
/* Associated bridge device (when bridged) */
struct net_device *hw_bridge_dev;
/* Bridged interfaces */
diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
index 4dedf5d92641..b3725cf2dd44 100644
--- a/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
+++ b/drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c
@@ -294,6 +294,7 @@ struct net_device *sparx5_create_netdev(struct sparx5 *sparx5, u32 portno)
ndev->ethtool_ops = &sparx5_ethtool_ops;
eth_hw_addr_gen(ndev, sparx5->base_mac, portno + 1);
+ ndev->addr_assign_type = sparx5->base_mac_assign_type;
return ndev;
}
--
2.55.0
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: sparx5: make ports inherit the switch base mac address type
2026-09-28 4:50 [PATCH net] net: sparx5: make ports inherit the switch base mac address type Quentin Freimanis
@ 2026-09-28 10:11 ` Simon Horman
2026-09-28 11:20 ` Daniel Machon
2026-09-30 1:59 ` Jakub Kicinski
2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2026-09-28 10:11 UTC (permalink / raw)
To: Quentin Freimanis
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Steen Hegelund, Daniel Machon,
UNGLinuxDriver, Lars Povlsen, Bjarni Jonasson, linux-arm-kernel,
linux-kernel
On Sun, Sep 27, 2026 at 09:50:12PM -0700, Quentin Freimanis wrote:
> When the switch uses a random base MAC address it does not mark each
> port's address as random:
>
> $ dmesg | grep "MAC addr"
> sparx5-switch e00c0000.switch: MAC addr was not set, use random MAC
> $ cat /sys/class/net/eth0/addr_assign_type
> 0
>
> 0 is NET_ADDR_PERM, so userspace thinks this is a stable address. Fix by
> tracking the base MAC address assign type in the sparx5 struct and
> applying it to each port's netdev.
>
> Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support")
> Signed-off-by: Quentin Freimanis <quentin@q-lab.dev>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: sparx5: make ports inherit the switch base mac address type
2026-09-28 4:50 [PATCH net] net: sparx5: make ports inherit the switch base mac address type Quentin Freimanis
2026-09-28 10:11 ` Simon Horman
@ 2026-09-28 11:20 ` Daniel Machon
2026-09-30 1:59 ` Jakub Kicinski
2 siblings, 0 replies; 5+ messages in thread
From: Daniel Machon @ 2026-09-28 11:20 UTC (permalink / raw)
To: Quentin Freimanis
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, Steen Hegelund, UNGLinuxDriver,
Lars Povlsen, Bjarni Jonasson, linux-arm-kernel, linux-kernel
> When the switch uses a random base MAC address it does not mark each
> port's address as random:
>
> $ dmesg | grep "MAC addr"
> sparx5-switch e00c0000.switch: MAC addr was not set, use random MAC
> $ cat /sys/class/net/eth0/addr_assign_type
> 0
>
> 0 is NET_ADDR_PERM, so userspace thinks this is a stable address. Fix by
> tracking the base MAC address assign type in the sparx5 struct and
> applying it to each port's netdev.
>
> Fixes: f3cad2611a77 ("net: sparx5: add hostmode with phylink support")
> Signed-off-by: Quentin Freimanis <quentin@q-lab.dev>
Reviewed-by: Daniel Machon <daniel.machon@microchip.com>
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [PATCH net] net: sparx5: make ports inherit the switch base mac address type
2026-09-28 4:50 [PATCH net] net: sparx5: make ports inherit the switch base mac address type Quentin Freimanis
2026-09-28 10:11 ` Simon Horman
2026-09-28 11:20 ` Daniel Machon
@ 2026-09-30 1:59 ` Jakub Kicinski
2026-09-30 8:00 ` Quentin Freimanis
2 siblings, 1 reply; 5+ messages in thread
From: Jakub Kicinski @ 2026-09-30 1:59 UTC (permalink / raw)
To: Quentin Freimanis
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Steen Hegelund, Daniel Machon, UNGLinuxDriver, Lars Povlsen,
Bjarni Jonasson, linux-arm-kernel, linux-kernel
On Sun, 27 Sep 2026 21:50:12 -0700 Quentin Freimanis wrote:
> 0 is NET_ADDR_PERM, so userspace thinks this is a stable address.
Could you please explain the end-user impact of this?
Unclear to me from the commit msg if this is something that broke
your deployment / scripts or maybe you simply noticed it from code
inspection / LLM scan.
No need to repost, just explain, I'll add it when applying.
> Fix by tracking the base MAC address assign type in the sparx5 struct
> and applying it to each port's netdev.
Generally no need to repeat what an average reader can easily grok
from the diff.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH net] net: sparx5: make ports inherit the switch base mac address type
2026-09-30 1:59 ` Jakub Kicinski
@ 2026-09-30 8:00 ` Quentin Freimanis
0 siblings, 0 replies; 5+ messages in thread
From: Quentin Freimanis @ 2026-09-30 8:00 UTC (permalink / raw)
To: Jakub Kicinski
Cc: netdev, Andrew Lunn, David S. Miller, Eric Dumazet, Paolo Abeni,
Steen Hegelund, Daniel Machon, UNGLinuxDriver, Lars Povlsen,
Bjarni Jonasson, linux-arm-kernel, linux-kernel
Hi Jakub,
On 9/29/26 6:59 PM, Jakub Kicinski wrote:
> On Sun, 27 Sep 2026 21:50:12 -0700 Quentin Freimanis wrote:
>> 0 is NET_ADDR_PERM, so userspace thinks this is a stable address.
>
> Could you please explain the end-user impact of this?
> Unclear to me from the commit msg if this is something that broke
> your deployment / scripts or maybe you simply noticed it from code
> inspection / LLM scan.
>
> No need to repost, just explain, I'll add it when applying.
>
With a random MAC reported as NET_ADDR_PERM, systemd's
MACAddressPolicy=persistent [1] leaves it unchanged, so a DHCP client
gets a new IP address every boot and a static reservation can't be used.
Reporting it as NET_ADDR_RANDOM makes systemd replace it with a stable
address derived from the interface name and machine-id.
(this is my use case, and how I found the bug)
>> Fix by tracking the base MAC address assign type in the sparx5 struct
>> and applying it to each port's netdev.
>
> Generally no need to repeat what an average reader can easily grok
> from the diff.
Ack.
- Quentin
[1]
https://www.freedesktop.org/software/systemd/man/latest/systemd.link.html#MACAddressPolicy=
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-09-30 8:01 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 4:50 [PATCH net] net: sparx5: make ports inherit the switch base mac address type Quentin Freimanis
2026-09-28 10:11 ` Simon Horman
2026-09-28 11:20 ` Daniel Machon
2026-09-30 1:59 ` Jakub Kicinski
2026-09-30 8:00 ` Quentin Freimanis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®