Commit e95cc447 authored by Hangbin Liu's avatar Hangbin Liu Committed by Jakub Kicinski

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: default avatarLiang Li <liali@redhat.com>
Fixes: 0a2ff7cc ("Bonding: add per-port priority for failover re-selection")
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 3d0b738f
...@@ -2654,8 +2654,9 @@ static void bond_miimon_link_change(struct bonding *bond, ...@@ -2654,8 +2654,9 @@ static void bond_miimon_link_change(struct bonding *bond,
static void bond_miimon_commit(struct bonding *bond) static void bond_miimon_commit(struct bonding *bond)
{ {
struct list_head *iter;
struct slave *slave, *primary; struct slave *slave, *primary;
bool do_failover = false;
struct list_head *iter;
bond_for_each_slave(bond, slave, iter) { bond_for_each_slave(bond, slave, iter) {
switch (slave->link_new_state) { switch (slave->link_new_state) {
...@@ -2699,8 +2700,9 @@ static void bond_miimon_commit(struct bonding *bond) ...@@ -2699,8 +2700,9 @@ static void bond_miimon_commit(struct bonding *bond)
bond_miimon_link_change(bond, slave, BOND_LINK_UP); bond_miimon_link_change(bond, slave, BOND_LINK_UP);
if (!rcu_access_pointer(bond->curr_active_slave) || slave == primary) if (!rcu_access_pointer(bond->curr_active_slave) || slave == primary ||
goto do_failover; slave->prio > rcu_dereference(bond->curr_active_slave)->prio)
do_failover = true;
continue; continue;
...@@ -2721,7 +2723,7 @@ static void bond_miimon_commit(struct bonding *bond) ...@@ -2721,7 +2723,7 @@ static void bond_miimon_commit(struct bonding *bond)
bond_miimon_link_change(bond, slave, BOND_LINK_DOWN); bond_miimon_link_change(bond, slave, BOND_LINK_DOWN);
if (slave == rcu_access_pointer(bond->curr_active_slave)) if (slave == rcu_access_pointer(bond->curr_active_slave))
goto do_failover; do_failover = true;
continue; continue;
...@@ -2732,8 +2734,9 @@ static void bond_miimon_commit(struct bonding *bond) ...@@ -2732,8 +2734,9 @@ static void bond_miimon_commit(struct bonding *bond)
continue; continue;
} }
}
do_failover: if (do_failover) {
block_netpoll_tx(); block_netpoll_tx();
bond_select_active_slave(bond); bond_select_active_slave(bond);
unblock_netpoll_tx(); unblock_netpoll_tx();
...@@ -3531,6 +3534,7 @@ static int bond_ab_arp_inspect(struct bonding *bond) ...@@ -3531,6 +3534,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)
*/ */
static void bond_ab_arp_commit(struct bonding *bond) static void bond_ab_arp_commit(struct bonding *bond)
{ {
bool do_failover = false;
struct list_head *iter; struct list_head *iter;
unsigned long last_tx; unsigned long last_tx;
struct slave *slave; struct slave *slave;
...@@ -3560,8 +3564,9 @@ static void bond_ab_arp_commit(struct bonding *bond) ...@@ -3560,8 +3564,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
slave_info(bond->dev, slave->dev, "link status definitely up\n"); slave_info(bond->dev, slave->dev, "link status definitely up\n");
if (!rtnl_dereference(bond->curr_active_slave) || if (!rtnl_dereference(bond->curr_active_slave) ||
slave == rtnl_dereference(bond->primary_slave)) slave == rtnl_dereference(bond->primary_slave) ||
goto do_failover; slave->prio > rtnl_dereference(bond->curr_active_slave)->prio)
do_failover = true;
} }
...@@ -3580,7 +3585,7 @@ static void bond_ab_arp_commit(struct bonding *bond) ...@@ -3580,7 +3585,7 @@ static void bond_ab_arp_commit(struct bonding *bond)
if (slave == rtnl_dereference(bond->curr_active_slave)) { if (slave == rtnl_dereference(bond->curr_active_slave)) {
RCU_INIT_POINTER(bond->current_arp_slave, NULL); RCU_INIT_POINTER(bond->current_arp_slave, NULL);
goto do_failover; do_failover = true;
} }
continue; continue;
...@@ -3604,8 +3609,9 @@ static void bond_ab_arp_commit(struct bonding *bond) ...@@ -3604,8 +3609,9 @@ static void bond_ab_arp_commit(struct bonding *bond)
slave->link_new_state); slave->link_new_state);
continue; continue;
} }
}
do_failover: if (do_failover) {
block_netpoll_tx(); block_netpoll_tx();
bond_select_active_slave(bond); bond_select_active_slave(bond);
unblock_netpoll_tx(); unblock_netpoll_tx();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment