Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCHv2 net 1/2] bonding: set random address only when slaves already exist
@ 2025-09-10  2:43 Hangbin Liu
  2025-09-10  2:43 ` [PATCHv2 net 2/2] selftests: bonding: add fail_over_mac testing Hangbin Liu
  2025-09-16  1:00 ` [PATCHv2 net 1/2] bonding: set random address only when slaves already exist patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Hangbin Liu @ 2025-09-10  2:43 UTC (permalink / raw)
  To: netdev
  Cc: Jay Vosburgh, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Simon Horman, Shuah Khan,
	linux-kselftest, Hangbin Liu, Qiuling Ren

After commit 5c3bf6cba791 ("bonding: assign random address if device
address is same as bond"), bonding will erroneously randomize the MAC
address of the first interface added to the bond if fail_over_mac =
follow.

Correct this by additionally testing for the bond being empty before
randomizing the MAC.

Fixes: 5c3bf6cba791 ("bonding: assign random address if device address is same as bond")
Reported-by: Qiuling Ren <qren@redhat.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 drivers/net/bonding/bond_main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 257333c88710..8832bc9f107b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -2132,6 +2132,7 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
 		memcpy(ss.__data, bond_dev->dev_addr, bond_dev->addr_len);
 	} else if (bond->params.fail_over_mac == BOND_FOM_FOLLOW &&
 		   BOND_MODE(bond) == BOND_MODE_ACTIVEBACKUP &&
+		   bond_has_slaves(bond) &&
 		   memcmp(slave_dev->dev_addr, bond_dev->dev_addr, bond_dev->addr_len) == 0) {
 		/* Set slave to random address to avoid duplicate mac
 		 * address in later fail over.
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-09-16  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-10  2:43 [PATCHv2 net 1/2] bonding: set random address only when slaves already exist Hangbin Liu
2025-09-10  2:43 ` [PATCHv2 net 2/2] selftests: bonding: add fail_over_mac testing Hangbin Liu
2025-09-16  1:00 ` [PATCHv2 net 1/2] bonding: set random address only when slaves already exist patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox