bonding: fix curr_active_slave/carrier with loadbalance arp monitoring
Subsystems (3)
PATCH 1/1 bonding: fix curr_active_slave/carrier with loadbalance arp monitoring
Since commit 6fde8f037e60 ("bonding: fix locking in bond_loadbalance_arp_mon()") we can have a stale bond carrier state and stale curr_active_slave when using arp monitoring in loadbalance modes. The reason is that in bond_loadbalance_arp_mon() we can't have do_failover == true but slave_state_changed == false, whenever do_failover is true then slave_state_changed is also true. Then the following piece from bond_loadbalance_arp_mon():
if (slave_state_changed) {
bond_slave_state_change(bond);
if (BOND_MODE(bond) == BOND_MODE_XOR)
bond_update_slave_arr(bond, NULL);
} else if (do_failover) {
block_netpoll_tx();
bond_select_active_slave(bond);
unblock_netpoll_tx();
}will execute only the first branch, always and regardless of do_failover. Since these two events aren't related in such way, we need to decouple and consider them separately.
For example this issue could lead to the following result:
Bonding Mode: load balancing (round-robin)
*MII Status: down*
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 100
ARP IP target/s (n.n.n.n form): 192.168.9.2
Slave Interface: ens12
*MII Status: up*
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:0f:53:01:42:2c
Slave queue ID: 0
Slave Interface: eth1
*MII Status: up*
Speed: Unknown
Duplex: Unknown
Link Failure Count: 70
Permanent HW addr: 52:54:00:2f:0f:8e
Slave queue ID: 0
Since some interfaces are up, then the status of the bond should also be up, but it will never change unless something invokes bond_set_carrier() (i.e. enslave, bond_select_active_slave etc). Now, if I force the calling of bond_select_active_slave via for example changing primary_reselect (it can change in any mode), then the MII status goes to "up" because it calls bond_select_active_slave() which should've been done from bond_loadbalance_arp_mon() itself.
---
Note: I left the parent if() the same even though we can shorten it. I think
it's better this way since it shows that any of the two events can cause it to enter even though currently we can't have do_failover without slave_state_changed, that may also change in the future.
drivers/net/bonding/bond_main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +2 -1
@@ -2471,7 +2471,8 @@ static void bond_loadbalance_arp_mon(struct work_struct *work)bond_slave_state_change (bond);if (BOND_MODE (bond) ==BOND_MODE_XOR )bond_update_slave_arr (bond,NULL ); - }else if (do_failover) { + } +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
Signature · 1 line
1.9.3
Quoted 7 lines · Nikolay Aleksandrov
Since commit
6fde8f037e60("bonding: fix locking inbond_loadbalance_arp_mon()") we can have a stale bond carrier state and stalecurr_active_slavewhen using arp monitoring in loadbalance modes. The reason is that inbond_loadbalance_arp_mon()we can't havedo_failover== true butslave_state_changed== false, wheneverdo_failoveris true thenslave_state_changedis also true. Then the following piece frombond_loadbalance_arp_mon():
Quoted 5 lines
if (slave_state_changed) {
bond_slave_state_change(bond);
if (BOND_MODE(bond) == BOND_MODE_XOR)
bond_update_slave_arr(bond, NULL);
} else if (do_failover) {Ouch, must have been a big PITA to track :).
Quoted 42 lines
block_netpoll_tx(); bond_select_active_slave(bond); unblock_netpoll_tx(); }will execute only the first branch, always and regardless of
do_failover. Since these two events aren't related in such way, we need to decouple and consider them separately.For example this issue could lead to the following result:
Bonding Mode: load balancing (round-robin)
*MII Status: down*
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 100
ARP IP target/s (n.n.n.n form): 192.168.9.2Slave Interface: ens12
*MII Status: up*
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:0f:53:01:42:2c
Slave queue ID: 0Slave Interface: eth1
*MII Status: up*
Speed: Unknown
Duplex: Unknown
Link Failure Count: 70
Permanent HW addr: 52:54:00:2f:0f:8e
Slave queue ID: 0Since some interfaces are up, then the status of the bond should also be up, but it will never change unless something invokes
bond_set_carrier()(i.e. enslave,bond_select_active_slaveetc). Now, if I force the calling ofbond_select_active_slavevia for example changingprimary_reselect(it can change in any mode), then the MII status goes to "up" because it callsbond_select_active_slave()which should've been done frombond_loadbalance_arp_mon()itself.
Quoted 1 line
CC Veaceslav Falico <[email protected]>
Quoted 32 lines
CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>CC Ding Tianhong <[email protected]>Fixes 6fde8f037e60 ("bonding: fix locking in bond_loadbalance_arp_mon()")Signed-off-by Nikolay Aleksandrov <[email protected]>---
Note: I left the parentif()the same even though we can shorten it. I think
it's better this way since it shows that any of the two events can cause it to enter even though currently we can't havedo_failoverwithoutslave_state_changed, that may also change in the future.
drivers/net/bonding/bond_main.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/bonding/bond_main.c +2
-1@@ -2471,7 +2471,8 @@ static void bond_loadbalance_arp_mon(struct work_struct *work)bond_slave_state_change (bond);if (BOND_MODE (bond) ==BOND_MODE_XOR )bond_update_slave_arr (bond,NULL ); - }else if (do_failover) { + } +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();Signature · 1 line
1.9.3
Andy Gospodarek
Acked-byQuoted 14 lines · Veaceslav Falico
Quoted 7 lines · Nikolay Aleksandrov
Since commit
6fde8f037e60("bonding: fix locking inbond_loadbalance_arp_mon()") we can have a stale bond carrier state and stalecurr_active_slavewhen using arp monitoring in loadbalance modes. The reason is that inbond_loadbalance_arp_mon()we can't havedo_failover== true butslave_state_changed== false, wheneverdo_failoveris true thenslave_state_changedis also true. Then the following piece frombond_loadbalance_arp_mon():Quoted 5 lines
if (slave_state_changed) { bond_slave_state_change(bond); if (BOND_MODE(bond) == BOND_MODE_XOR) bond_update_slave_arr(bond, NULL); } else if (do_failover) {
Quoted 1 line
Ouch, must have been a big PITA to track :).
Agreed!
Quoted 43 lines
Quoted 43 lines
block_netpoll_tx(); bond_select_active_slave(bond); unblock_netpoll_tx(); }will execute only the first branch, always and regardless of
do_failover. Since these two events aren't related in such way, we need to decouple and consider them separately.For example this issue could lead to the following result:
Bonding Mode: load balancing (round-robin)
*MII Status: down*
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 100
ARP IP target/s (n.n.n.n form): 192.168.9.2Slave Interface: ens12
*MII Status: up*
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:0f:53:01:42:2c
Slave queue ID: 0Slave Interface: eth1
*MII Status: up*
Speed: Unknown
Duplex: Unknown
Link Failure Count: 70
Permanent HW addr: 52:54:00:2f:0f:8e
Slave queue ID: 0Since some interfaces are up, then the status of the bond should also be up, but it will never change unless something invokes
bond_set_carrier()(i.e. enslave,bond_select_active_slaveetc). Now, if I force the calling ofbond_select_active_slavevia for example changingprimary_reselect(it can change in any mode), then the MII status goes to "up" because it callsbond_select_active_slave()which should've been done frombond_loadbalance_arp_mon()itself.
Quoted 3 lines
Quoted 1 line
CC Veaceslav Falico <[email protected]>Acked-by Veaceslav Falico <[email protected]>
Quoted 37 lines
Quoted 33 lines
CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>CC Ding Tianhong <[email protected]>Fixes 6fde8f037e60 ("bonding: fix locking in bond_loadbalance_arp_mon()")Signed-off-by Nikolay Aleksandrov <[email protected]>---
Note: I left the parentif()the same even though we can shorten it. I think
it's better this way since it shows that any of the two events can cause it to enter even though currently we can't havedo_failoverwithoutslave_state_changed, that may also change in the future.
drivers/net/bonding/bond_main.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/bonding/bond_main.c +2
-1@@ -2471,7 +2471,8 @@ static void bond_loadbalance_arp_mon(struct work_struct *work)bond_slave_state_change (bond);if (BOND_MODE (bond) ==BOND_MODE_XOR )bond_update_slave_arr (bond,NULL ); - }else if (do_failover) { + } +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();Signature · 1 line
1.9.3--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Ding Tianhong
Acked-byQuoted 62 lines · Andy Gospodarek
Quoted 14 lines · Veaceslav Falico
Quoted 7 lines · Nikolay Aleksandrov
Since commit
6fde8f037e60("bonding: fix locking inbond_loadbalance_arp_mon()") we can have a stale bond carrier state and stalecurr_active_slavewhen using arp monitoring in loadbalance modes. The reason is that inbond_loadbalance_arp_mon()we can't havedo_failover== true butslave_state_changed== false, wheneverdo_failoveris true thenslave_state_changedis also true. Then the following piece frombond_loadbalance_arp_mon():Quoted 5 lines
if (slave_state_changed) { bond_slave_state_change(bond); if (BOND_MODE(bond) == BOND_MODE_XOR) bond_update_slave_arr(bond, NULL); } else if (do_failover) {Quoted 1 line
Ouch, must have been a big PITA to track :).
Agreed!
Quoted 43 lines
Quoted 43 lines
block_netpoll_tx(); bond_select_active_slave(bond); unblock_netpoll_tx(); }will execute only the first branch, always and regardless of
do_failover. Since these two events aren't related in such way, we need to decouple and consider them separately.For example this issue could lead to the following result:
Bonding Mode: load balancing (round-robin)
*MII Status: down*
MII Polling Interval (ms): 0
Up Delay (ms): 0
Down Delay (ms): 0
ARP Polling Interval (ms): 100
ARP IP target/s (n.n.n.n form): 192.168.9.2Slave Interface: ens12
*MII Status: up*
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: 00:0f:53:01:42:2c
Slave queue ID: 0Slave Interface: eth1
*MII Status: up*
Speed: Unknown
Duplex: Unknown
Link Failure Count: 70
Permanent HW addr: 52:54:00:2f:0f:8e
Slave queue ID: 0Since some interfaces are up, then the status of the bond should also be up, but it will never change unless something invokes
bond_set_carrier()(i.e. enslave,bond_select_active_slaveetc). Now, if I force the calling ofbond_select_active_slavevia for example changingprimary_reselect(it can change in any mode), then the MII status goes to "up" because it callsbond_select_active_slave()which should've been done frombond_loadbalance_arp_mon()itself.
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
CC Veaceslav Falico <[email protected]>Acked-by Veaceslav Falico <[email protected]>Acked-by Andy Gospodarek <[email protected]>
Quoted 40 lines
Quoted 29 lines
Quoted 29 lines
CC Jay Vosburgh <[email protected]>CC Andy Gospodarek <[email protected]>CC Ding Tianhong <[email protected]>Fixes 6fde8f037e60 ("bonding: fix locking in bond_loadbalance_arp_mon()")Signed-off-by Nikolay Aleksandrov <[email protected]>---
Note: I left the parentif()the same even though we can shorten it. I think
it's better this way since it shows that any of the two events can cause it to enter even though currently we can't havedo_failoverwithoutslave_state_changed, that may also change in the future.
drivers/net/bonding/bond_main.c| 3 ++-1 file changed, 2 insertions(+), 1 deletion(-)drivers/net/bonding/bond_main.c +2
-1@@ -2471,7 +2471,8 @@ static void bond_loadbalance_arp_mon(struct work_struct *work)bond_slave_state_change (bond);if (BOND_MODE (bond) ==BOND_MODE_XOR )bond_update_slave_arr (bond,NULL ); - }else if (do_failover) { + } +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);Quoted 8 lines
Quoted 4 lines
drivers/net/bonding/bond_main.c +0
-0unblock_netpoll_tx ();Signature · 1 line
1.9.3--
To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html.
From: Andy Gospodarek <[email protected]>
Date: Tue, 18 Nov 2014 10:28:47 -0500
Quoted 18 lines · Veaceslav Falico
Quoted 14 lines · Nikolay Aleksandrov
Quoted 7 lines
Since commit
6fde8f037e60("bonding: fix locking inbond_loadbalance_arp_mon()") we can have a stale bond carrier state and stalecurr_active_slavewhen using arp monitoring in loadbalance modes. The reason is that inbond_loadbalance_arp_mon()we can't havedo_failover== true butslave_state_changed== false, wheneverdo_failoveris true thenslave_state_changedis also true. Then the following piece frombond_loadbalance_arp_mon():Quoted 5 lines
if (slave_state_changed) { bond_slave_state_change(bond); if (BOND_MODE(bond) == BOND_MODE_XOR) bond_update_slave_arr(bond, NULL); } else if (do_failover) {Quoted 1 line
Ouch, must have been a big PITA to track :).
Agreed!
...
Quoted 3 lines
Quoted 1 line
Acked-by Veaceslav Falico <[email protected]>Acked-by Andy Gospodarek <[email protected]>
Applied, and queued up for -stable, thanks everyone!