net: sparx5: make ports inherit the switch base mac address type
Subsystems (3)
PATCH 1/1 net: sparx5: make ports inherit the switch base mac address type
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.
--- 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(+)
drivers/net/ethernet/microchip/sparx5/sparx5_main.c +1 -0
@@ -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" );
drivers/net/ethernet/microchip/sparx5/sparx5_main.h +1 -0
@@ -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 */
drivers/net/ethernet/microchip/sparx5/sparx5_netdev.c +1 -0
@@ -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; }
Signature · 1 line
2.55.0
Quoted 8 lines · Quentin Freimanis
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
Quoted 6 lines
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 <[email protected]>
Quoted 8 lines
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
Quoted 6 lines
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 <[email protected]>
Jakub Kicinski
maintainerQuoted 1 line · 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.
Quoted 2 lines
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.
Hi Jakub,
Quoted 10 lines · Jakub Kicinski
Quoted 1 line · 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)
Quoted 5 lines
Quoted 2 lines
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=
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Sun, 27 Sep 2026 21:50:12 -0700 you 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[...]
Here is the summary with links:
- [net] net: sparx5: make ports inherit the switch base mac address type
https://git.kernel.org/netdev/net/c/5642b1648d5c
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html