Skip to content

Commit 4d6f142

Browse files
liuhangbinNipaLocal
authored andcommitted
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 50b86dd commit 4d6f142

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
@@ -1003,8 +1003,6 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
10031003

10041004
if (bond->dev->flags & IFF_UP)
10051005
bond_hw_addr_flush(bond->dev, old_active->dev);
1006-
1007-
bond_slave_ns_maddrs_add(bond, old_active);
10081006
}
10091007

10101008
if (new_active) {
@@ -1021,8 +1019,6 @@ static void bond_hw_addr_swap(struct bonding *bond, struct slave *new_active,
10211019
dev_mc_sync(new_active->dev, bond->dev);
10221020
netif_addr_unlock_bh(bond->dev);
10231021
}
1024-
1025-
bond_slave_ns_maddrs_del(bond, new_active);
10261022
}
10271023
}
10281024

@@ -2371,11 +2367,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev,
23712367
bond_compute_features(bond);
23722368
bond_set_carrier(bond);
23732369

2374-
/* Needs to be called before bond_select_active_slave(), which will
2375-
* remove the maddrs if the slave is selected as active slave.
2376-
*/
2377-
bond_slave_ns_maddrs_add(bond, new_slave);
2378-
23792370
if (bond_uses_primary(bond)) {
23802371
block_netpoll_tx();
23812372
bond_select_active_slave(bond);

include/net/bonding.h

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

391+
if (slave_state == BOND_STATE_ACTIVE)
392+
bond_slave_ns_maddrs_del(slave->bond, slave);
393+
391394
slave->backup = slave_state;
395+
396+
if (slave_state == BOND_STATE_BACKUP)
397+
bond_slave_ns_maddrs_add(slave->bond, slave);
398+
392399
if (notify) {
393400
bond_lower_state_changed(slave);
394401
bond_queue_slave_event(slave);

0 commit comments

Comments
 (0)