diff mbox series

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

Message ID 20250328155522.3514-1-ffmancera@riseup.net (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series net: hsr: sync hw addr of slave2 according to slave1 hw addr on PRP | 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: 518 this patch: 518
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers warning 7 maintainers not CCed: edumazet@google.com pabeni@redhat.com sd@queasysnail.net horms@kernel.org kuba@kernel.org shannon.nelson@amd.com jacob.e.keller@intel.com
netdev/build_clang success Errors and warnings before: 0 this patch: 0
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: 0 this patch: 0
netdev/checkpatch warning WARNING: line length of 82 exceeds 80 columns WARNING: line length of 83 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Fernando F. Mancera March 28, 2025, 3:55 p.m. UTC
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.

Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
---
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.
---
 net/hsr/hsr_device.c | 2 ++
 net/hsr/hsr_main.c   | 9 +++++++++
 2 files changed, 11 insertions(+)

Comments

Fernando F. Mancera March 28, 2025, 4:05 p.m. UTC | #1
On 3/28/25 4:55 PM, Fernando Fernandez Mancera wrote:
> 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.
> 
> Signed-off-by: Fernando Fernandez Mancera <ffmancera@riseup.net>
> ---
> 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.
> ---
>   net/hsr/hsr_device.c | 2 ++
>   net/hsr/hsr_main.c   | 9 +++++++++
>   2 files changed, 11 insertions(+)
> 
> diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
> index 439cfb7ad5d1..f971eb321655 100644
> --- a/net/hsr/hsr_device.c
> +++ b/net/hsr/hsr_device.c
> @@ -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;
>   	}
> diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
> index d7ae32473c41..192893c3f2ec 100644
> --- a/net/hsr/hsr_main.c
> +++ b/net/hsr/hsr_main.c
> @@ -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() */

Ugh, I just noticed I missed to specify target tree net-next *facepalm*, 
sorry.
diff mbox series

Patch

diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index 439cfb7ad5d1..f971eb321655 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -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;
 	}
diff --git a/net/hsr/hsr_main.c b/net/hsr/hsr_main.c
index d7ae32473c41..192893c3f2ec 100644
--- a/net/hsr/hsr_main.c
+++ b/net/hsr/hsr_main.c
@@ -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() */