Skip to content

Commit 8e112d9

Browse files
liuhangbinNipaLocal
authored and
NipaLocal
committed
bonding: fix multicast MAC address synchronization
There is a corner case where the NS (Neighbor Solicitation) target is set to an invalid or unreachable address. In such cases, all the slave links are marked as down and set to backup. This causes the bond to add multicast MAC addresses to all slaves. However, bond_ab_arp_probe() later tries to activate a carrier on slave and sets it as active. If we subsequently change or clear the NS targets, the call to bond_slave_ns_maddrs_del() on this interface will fail because it is still marked active, and the multicast MAC address will remain. To fix this issue, move the NS multicast address add/remove logic into bond_set_slave_state() to ensure multicast MAC addresses are updated synchronously whenever the slave state changes. Note: The call to bond_slave_ns_maddrs_del() in __bond_release_one() is kept, as it is still required to clean up multicast MAC addresses when a slave is removed. Fixes: 8eb3616 ("bonding: add ns target multicast address to slave device") Reported-by: Liang Li <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Signed-off-by: NipaLocal <nipa@local>
1 parent ce41c8b commit 8e112d9

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,8 +1001,6 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
10011001

10021002
if (bond->dev->flags & IFF_UP)
10031003
bond_hw_addr_flush(bond->dev, old_active->dev);
1004-
1005-
bond_slave_ns_maddrs_add(bond, old_active);
10061004
}
10071005

10081006
if (new_active) {
@@ -1019,8 +1017,6 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
10191017
dev_mc_sync(new_active->dev, bond->dev);
10201018
netif_addr_unlock_bh(bond->dev);
10211019
}
1022-
1023-
bond_slave_ns_maddrs_del(bond, new_active);
10241020
}
10251021
}
10261022

@@ -2356,11 +2352,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
23562352
bond_compute_features(bond);
23572353
bond_set_carrier(bond);
23582354

2359-
/* Needs to be called before bond_select_active_slave(), which will
2360-
* remove the maddrs if the slave is selected as active slave.
2361-
*/
2362-
bond_slave_ns_maddrs_add(bond, new_slave);
2363-
23642355
if (bond_uses_primary(bond)) {
23652356
block_netpoll_tx();
23662357
bond_select_active_slave(bond);

include/net/bonding.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,14 @@ static inline void bond_set_slave_state(struct slave *slave,
385385
if (slave->backup == slave_state)
386386
return;
387387

388+
if (slave_state == BOND_STATE_ACTIVE)
389+
bond_slave_ns_maddrs_del(slave->bond, slave);
390+
388391
slave->backup = slave_state;
392+
393+
if (slave_state == BOND_STATE_BACKUP)
394+
bond_slave_ns_maddrs_add(slave->bond, slave);
395+
389396
if (notify) {
390397
bond_lower_state_changed(slave);
391398
bond_queue_slave_event(slave);

0 commit comments

Comments
 (0)