Bonding: fix high prio not effect issue
Subsystems (4)
cover Bonding: fix high prio not effect issue
When a high prio link up, if there has current link, it will not do failover as we missed the check in link up event. Fix it in this patchset and add a prio option test case.
v2:
1. use rcu_access_pointer() instead of rtnl_dereference(). 2: make do_failover after looping all slaves
Hangbin Liu (2):
bonding: add missed __rcu annotation for curr_active_slave
bonding: do failover when high prio link up
Liang Li (1):
selftests: bonding: add bonding prio option test
drivers/net/bonding/bond_main.c | 24 +- .../selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/option_prio.sh | 245 ++++++++++++++++++ 3 files changed, 262 insertions(+), 10 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh
Signature · 1 line
2.38.1
PATCH v2 1/3 bonding: add missed __rcu annotation for curr_active_slave
There is one direct accesses to bond->curr_active_slave in bond_miimon_commit(). Protected it by rcu_access_pointer() since the later of this function also use this one.
---
v2: use rcu_access_pointer() instead of rtnl_dereference().
--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +1 -1
@@ -2689,7 +2689,7 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP ); -if (!bond->curr_active_slave || slave == primary) +if (!rcu_access_pointer (bond->curr_active_slave) || slave == primary) goto do_failover;continue ;
Signature · 1 line
2.38.1
PATCH v2 2/3 bonding: do failover when high prio link up
In reply to Hangbin LiuCurrently, 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.
---
v2: make do_failover after looping all slaves
--- drivers/net/bonding/bond_main.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-)
drivers/net/bonding/bond_main.c +15 -9
@@ -2644,8 +2644,9 @@ static void bond_miimon_link_change(struct bonding *bond,static void bond_miimon_commit (struct bonding *bond) { -struct list_head *iter;struct slave *slave, *primary; +bool do_failover = false; +struct list_head *iter;bond_for_each_slave (bond, slave, iter) {switch (slave->link_new_state) {
@@ -2689,8 +2690,9 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP ); -if (!rcu_access_pointer (bond->curr_active_slave) || slave == primary) - goto do_failover; +if (!rcu_access_pointer (bond->curr_active_slave) || slave == primary || + slave->prio >rcu_dereference (bond->curr_active_slave)->prio) + do_failover = true;continue ;
@@ -2711,7 +2713,7 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_DOWN );if (slave ==rcu_access_pointer (bond->curr_active_slave)) - goto do_failover; + do_failover = true;continue ;
@@ -2722,8 +2724,9 @@ static void bond_miimon_commit(struct bonding *bond)continue ; } + } -do_failover: +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
@@ -3521,6 +3524,7 @@ static int bond_ab_arp_inspect(struct bonding *bond)*/ static void bond_ab_arp_commit (struct bonding *bond) { +bool do_failover = false;struct list_head *iter;unsigned long last_tx;struct slave *slave;
@@ -3550,8 +3554,9 @@ static void bond_ab_arp_commit(struct bonding *bond)slave_info (bond->dev, slave->dev,"link status definitely up\n" );if (!rtnl_dereference (bond->curr_active_slave) || - slave ==rtnl_dereference (bond->primary_slave)) - goto do_failover; + slave ==rtnl_dereference (bond->primary_slave) || + slave->prio >rtnl_dereference (bond->curr_active_slave)->prio) + do_failover = true; }
@@ -3570,7 +3575,7 @@ static void bond_ab_arp_commit(struct bonding *bond)if (slave ==rtnl_dereference (bond->curr_active_slave)) {RCU_INIT_POINTER (bond->current_arp_slave,NULL ); - goto do_failover; + do_failover = true; }continue ;
@@ -3594,8 +3599,9 @@ static void bond_ab_arp_commit(struct bonding *bond) slave->link_new_state);continue ; } + } -do_failover: +if (do_failover) {block_netpoll_tx ();bond_select_active_slave (bond);unblock_netpoll_tx ();
Signature · 1 line
2.38.1
PATCH v2 3/3 selftests: bonding: add bonding prio option test
In reply to Hangbin LiuFrom: Liang Li <[email protected]>
Add a test for bonding prio option. Here is the test result:
]# ./option_prio.sh
TEST: prio_test (Test bonding option 'prio' with mode=1 monitor=arp_ip_target and primary_reselect=0) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=1 monitor=arp_ip_target and primary_reselect=1) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=1 monitor=arp_ip_target and primary_reselect=2) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=1 monitor=miimon and primary_reselect=0) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=1 monitor=miimon and primary_reselect=1) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=1 monitor=miimon and primary_reselect=2) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=5 monitor=miimon and primary_reselect=0) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=5 monitor=miimon and primary_reselect=1) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=5 monitor=miimon and primary_reselect=2) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=6 monitor=miimon and primary_reselect=0) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=6 monitor=miimon and primary_reselect=1) [ OK ]
TEST: prio_test (Test bonding option 'prio' with mode=6 monitor=miimon and primary_reselect=2) [ OK ]
--- .../selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/option_prio.sh | 245 ++++++++++++++++++ 2 files changed, 247 insertions(+), 1 deletion(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh
tools/testing/selftests/drivers/net/bonding/Makefile +2 -1
@@ -5,7 +5,8 @@ TEST_PROGS := \ bond-arp-interval-causes-panic.sh \ bond-break-lacpdu-tx.sh \ bond-lladdr-target.sh \ - dev_addr_lists.sh + dev_addr_lists.sh \ + option_prio.sh TEST_FILES := \ lag_lib.sh \
tools/testing/selftests/drivers/net/bonding/option_prio.sh new file +245 -0
245 lines not on this page · raw message
Signature · 1 line
2.38.1
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Quoted 9 lines · On Mon, 12 Dec 2022 11:56:44 +0800 you wrote:
When a high prio link up, if there has current link, it will not do failover as we missed the check in link up event. Fix it in this patchset and add a prio option test case.
v2:
1. usercu_access_pointer()instead ofrtnl_dereference(). 2: makedo_failoverafter looping all slaves[...]
Here is the summary with links:
- [PATCHv2,net,1/3] bonding: add missed __rcu annotation for curr_active_slave
https://git.kernel.org/netdev/net/c/3d0b738fc5ad - [PATCHv2,net,2/3] bonding: do failover when high prio link up https://git.kernel.org/netdev/net/c/e95cc44763a4
- [PATCHv2,net,3/3] selftests: bonding: add bonding prio option test (no matching commit)
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html