Skip to content

Commit 6ab2c00

Browse files
author
Hangbin Liu
committed
bonding: do failover when high prio link up
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2092194 Upstream Status: net.git commit e95cc44 commit e95cc44 Author: Hangbin Liu <liuhangbin@gmail.com> Date: Mon Dec 12 11:56:46 2022 +0800 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> Signed-off-by: Hangbin Liu <haliu@redhat.com>
1 parent 56eb9e4 commit 6ab2c00

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
@@ -2653,8 +2653,9 @@ static void bond_miimon_link_change(struct bonding *bond,
26532653

26542654
static void bond_miimon_commit(struct bonding *bond)
26552655
{
2656-
struct list_head *iter;
26572656
struct slave *slave, *primary;
2657+
bool do_failover = false;
2658+
struct list_head *iter;
26582659

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

26992700
bond_miimon_link_change(bond, slave, BOND_LINK_UP);
27002701

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

27042706
continue;
27052707

@@ -2720,7 +2722,7 @@ static void bond_miimon_commit(struct bonding *bond)
27202722
bond_miimon_link_change(bond, slave, BOND_LINK_DOWN);
27212723

27222724
if (slave == rcu_access_pointer(bond->curr_active_slave))
2723-
goto do_failover;
2725+
do_failover = true;
27242726

27252727
continue;
27262728

@@ -2731,8 +2733,9 @@ static void bond_miimon_commit(struct bonding *bond)
27312733

27322734
continue;
27332735
}
2736+
}
27342737

2735-
do_failover:
2738+
if (do_failover) {
27362739
block_netpoll_tx();
27372740
bond_select_active_slave(bond);
27382741
unblock_netpoll_tx();
@@ -3530,6 +3533,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)
35303533
*/
35313534
static void bond_ab_arp_commit(struct bonding *bond)
35323535
{
3536+
bool do_failover = false;
35333537
struct list_head *iter;
35343538
unsigned long last_tx;
35353539
struct slave *slave;
@@ -3559,8 +3563,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
35593563
slave_info(bond->dev, slave->dev, "link status definitely up\n");
35603564

35613565
if (!rtnl_dereference(bond->curr_active_slave) ||
3562-
slave == rtnl_dereference(bond->primary_slave))
3563-
goto do_failover;
3566+
slave == rtnl_dereference(bond->primary_slave) ||
3567+
slave->prio > rtnl_dereference(bond->curr_active_slave)->prio)
3568+
do_failover = true;
35643569

35653570
}
35663571

@@ -3579,7 +3584,7 @@ static void bond_ab_arp_commit(struct bonding *bond)
35793584

35803585
if (slave == rtnl_dereference(bond->curr_active_slave)) {
35813586
RCU_INIT_POINTER(bond->current_arp_slave, NULL);
3582-
goto do_failover;
3587+
do_failover = true;
35833588
}
35843589

35853590
continue;
@@ -3603,8 +3608,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
36033608
slave->link_new_state);
36043609
continue;
36053610
}
3611+
}
36063612

3607-
do_failover:
3613+
if (do_failover) {
36083614
block_netpoll_tx();
36093615
bond_select_active_slave(bond);
36103616
unblock_netpoll_tx();

0 commit comments

Comments
 (0)