Skip to contentSkip to conversation

net: hsr: sync hw addr of slave2 according to slave1 hw addr on PRP

PATCH Superseded Fernando Fernandez Mancera 2 participants 3 messages Mar 28, 2025 – Apr 1, 2025

Subsystems (3)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 net: hsr: sync hw addr of slave2 according to slave1 hw addr on PRP

In order to work properly PRP requires slave1 and slave2 to share the same MAC address. To ease the configuration process on userspace tools, sync the slave2 MAC address with slave1.

---
NOTE: I am not sure the call_netdevice_notifiers() are needed here. I am wondering, if this change makes sense in HSR too. Feedback is welcome.
v2: specified the target tree

---
 net/hsr/hsr_device.c | 2 ++
 net/hsr/hsr_main.c   | 9 +++++++++
 2 files changed, 11 insertions(+)
net/hsr/hsr_device.c +2 -0
index 439cfb7ad5d1..f971eb321655 100644
@@ -706,6 +706,8 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
 		 */
 		hsr->net_id = PRP_LAN_ID << 1;
 		hsr->proto_ops = &prp_ops;
+		eth_hw_addr_set(slave[1], slave[0]->dev_addr);
+		call_netdevice_notifiers(NETDEV_CHANGEADDR, slave[1]);
 	} else {
 		hsr->proto_ops = &hsr_ops;
 	}
net/hsr/hsr_main.c +9 -0
index d7ae32473c41..192893c3f2ec 100644
@@ -78,6 +78,15 @@ static int hsr_netdev_notify(struct notifier_block *nb, unsigned long event,
 			eth_hw_addr_set(master->dev, dev->dev_addr);
 			call_netdevice_notifiers(NETDEV_CHANGEADDR,
 						 master->dev);
+
+			if (hsr->prot_version == PRP_V1) {
+				port = hsr_port_get_hsr(hsr, HSR_PT_SLAVE_B);
+				if (port) {
+					eth_hw_addr_set(port->dev, dev->dev_addr);
+					call_netdevice_notifiers(NETDEV_CHANGEADDR,
+								 port->dev);
+				}
+			}
 		}
 
 		/* Make sure we recognize frames from ourselves in hsr_rcv() */
Signature · 1 line
2.49.0
maintainer
#1 lore raw
Quoted 10 lines · Fernando Fernandez Mancera

In order to work properly PRP requires slave1 and slave2 to share the same MAC address. To ease the configuration process on userspace tools, sync the slave2 MAC address with slave1.

---
NOTE: I am not sure the call_netdevice_notifiers() are needed here. I am wondering, if this change makes sense in HSR too. Feedback is welcome.
v2: specified the target tree

Please respect the 24h grace period before reposting:

https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/process/maintainer-netdev.rst#L15

Also please note that net-next is currently closed for new features due to the merge window. Please resent after Apr 7th.

Quoted 10 lines
---
 net/hsr/hsr_device.c | 2 ++
 net/hsr/hsr_main.c   | 9 +++++++++
 2 files changed, 11 insertions(+)
net/hsr/hsr_device.c +0 -0
index 439cfb7ad5d1..f971eb321655 100644

net/hsr/hsr_device.c int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], · line 709

Quoted 4 lines
net/hsr/hsr_device.c +1 -0
@@ -706,6 +706,8 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
 		 */
 		hsr->net_id = PRP_LAN_ID << 1;
 		hsr->proto_ops = &prp_ops;
+		eth_hw_addr_set(slave[1], slave[0]->dev_addr);

I'm unsure about this. It will have 'destructive' effect on slave[1], i.e. the original mac address will be permanently chaneged and will be up to the user-space restore it when/if removing from hsr.

I think it would be better to additionally store the original mac address at hsr creation time and restore it at link removal time.

Thanks,

Paolo

#2 lore raw
Quoted 38 lines · Paolo Abeni
Quoted 10 lines · Fernando Fernandez Mancera

In order to work properly PRP requires slave1 and slave2 to share the same MAC address. To ease the configuration process on userspace tools, sync the slave2 MAC address with slave1.

---
NOTE: I am not sure the call_netdevice_notifiers() are needed here. I am wondering, if this change makes sense in HSR too. Feedback is welcome.
v2: specified the target tree

Please respect the 24h grace period before reposting:

https://elixir.bootlin.com/linux/v6.14-rc6/source/Documentation/process/maintainer-netdev.rst#L15

Also please note that net-next is currently closed for new features due to the merge window. Please resent after Apr 7th.

Quoted 10 lines
---
  net/hsr/hsr_device.c | 2 ++
  net/hsr/hsr_main.c   | 9 +++++++++
  2 files changed, 11 insertions(+)
net/hsr/hsr_device.c +0 -0
index 439cfb7ad5d1..f971eb321655 100644

net/hsr/hsr_device.c int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2], · line 709

Quoted 4 lines
net/hsr/hsr_device.c +1 -0
@@ -706,6 +706,8 @@ int hsr_dev_finalize(struct net_device *hsr_dev, struct net_device *slave[2],
  		 */
  		hsr->net_id = PRP_LAN_ID << 1;
  		hsr->proto_ops = &prp_ops;
+		eth_hw_addr_set(slave[1], slave[0]->dev_addr);

I'm unsure about this. It will have 'destructive' effect on slave[1], i.e. the original mac address will be permanently chaneged and will be up to the user-space restore it when/if removing from hsr.

Quoted 3 lines

I think it would be better to additionally store the original mac address at hsr creation time and restore it at link removal time.

Yes, probably it makes more sense to restore the original MAC address at link removal. Thanks for the suggestion Paolo!

Quoted 5 lines

Thanks,

Paolo