Skip to content

Commit e95cc44

Browse files
liuhangbinkuba-moo
authored andcommitted
bonding: do failover when high prio link up
Currently, when a high prio link enslaved, or when current link down, the high prio port could be selected. But when high prio link up, the new active slave reselection is not triggered. Fix it by checking link's prio when getting up. Making the do_failover after looping all slaves as there may be multi high prio slaves up. Reported-by: Liang Li <liali@redhat.com> Fixes: 0a2ff7c ("Bonding: add per-port priority for failover re-selection") Signed-off-by: Hangbin Liu <liuhangbin@gmail.com> Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 3d0b738 commit e95cc44

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

drivers/net/bonding/bond_main.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,8 +2654,9 @@ static void bond_miimon_link_change(struct bonding *bond,
26542654

26552655
static void bond_miimon_commit(struct bonding *bond)
26562656
{
2657-
struct list_head *iter;
26582657
struct slave *slave, *primary;
2658+
bool do_failover = false;
2659+
struct list_head *iter;
26592660

26602661
bond_for_each_slave(bond, slave, iter) {
26612662
switch (slave->link_new_state) {
@@ -2699,8 +2700,9 @@ static void bond_miimon_commit(struct bonding *bond)
26992700

27002701
bond_miimon_link_change(bond, slave, BOND_LINK_UP);
27012702

2702-
if (!rcu_access_pointer(bond->curr_active_slave) || slave == primary)
2703-
goto do_failover;
2703+
if (!rcu_access_pointer(bond->curr_active_slave) || slave == primary ||
2704+
slave->prio > rcu_dereference(bond->curr_active_slave)->prio)
2705+
do_failover = true;
27042706

27052707
continue;
27062708

@@ -2721,7 +2723,7 @@ static void bond_miimon_commit(struct bonding *bond)
27212723
bond_miimon_link_change(bond, slave, BOND_LINK_DOWN);
27222724

27232725
if (slave == rcu_access_pointer(bond->curr_active_slave))
2724-
goto do_failover;
2726+
do_failover = true;
27252727

27262728
continue;
27272729

@@ -2732,8 +2734,9 @@ static void bond_miimon_commit(struct bonding *bond)
27322734

27332735
continue;
27342736
}
2737+
}
27352738

2736-
do_failover:
2739+
if (do_failover) {
27372740
block_netpoll_tx();
27382741
bond_select_active_slave(bond);
27392742
unblock_netpoll_tx();
@@ -3531,6 +3534,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)
35313534
*/
35323535
static void bond_ab_arp_commit(struct bonding *bond)
35333536
{
3537+
bool do_failover = false;
35343538
struct list_head *iter;
35353539
unsigned long last_tx;
35363540
struct slave *slave;
@@ -3560,8 +3564,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
35603564
slave_info(bond->dev, slave->dev, "link status definitely up\n");
35613565

35623566
if (!rtnl_dereference(bond->curr_active_slave) ||
3563-
slave == rtnl_dereference(bond->primary_slave))
3564-
goto do_failover;
3567+
slave == rtnl_dereference(bond->primary_slave) ||
3568+
slave->prio > rtnl_dereference(bond->curr_active_slave)->prio)
3569+
do_failover = true;
35653570

35663571
}
35673572

@@ -3580,7 +3585,7 @@ static void bond_ab_arp_commit(struct bonding *bond)
35803585

35813586
if (slave == rtnl_dereference(bond->curr_active_slave)) {
35823587
RCU_INIT_POINTER(bond->current_arp_slave, NULL);
3583-
goto do_failover;
3588+
do_failover = true;
35843589
}
35853590

35863591
continue;
@@ -3604,8 +3609,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
36043609
slave->link_new_state);
36053610
continue;
36063611
}
3612+
}
36073613

3608-
do_failover:
3614+
if (do_failover) {
36093615
block_netpoll_tx();
36103616
bond_select_active_slave(bond);
36113617
unblock_netpoll_tx();

0 commit comments

Comments
 (0)