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.
Hangbin Liu (2):
bonding: access curr_active_slave with rtnl_dereference
bonding: do failover when high prio link up
Liang Li (1):
selftests: bonding: add bonding prio option test
drivers/net/bonding/bond_main.c | 6 +- .../selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/option_prio.sh | 246 ++++++++++++++++++ 3 files changed, 252 insertions(+), 3 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/option_prio.sh
Signature · 1 line
2.38.1
PATCH 1/3 bonding: access curr_active_slave with rtnl_dereference
Looks commit 4740d6382790 ("bonding: add proper __rcu annotation for curr_active_slave") missed rtnl_dereference for curr_active_slave in bond_miimon_commit().
--- 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 (!rtnl_dereference (bond->curr_active_slave) || slave == primary) goto do_failover;continue ;
Signature · 1 line
2.38.1
Re: [PATCH net 1/3] bonding: access curr_active_slave with rtnl_dereference
Quoted 6 lines · Hangbin Liu
Looks commit
4740d6382790("bonding: add proper__rcuannotation forcurr_active_slave") missedrtnl_dereferenceforcurr_active_slaveinbond_miimon_commit().Fixes 4740d6382790 ("bonding: add proper __rcu annotation for curr_active_slave")Signed-off-by Hangbin Liu <[email protected]>
Re: [PATCH net 1/3] bonding: access curr_active_slave with rtnl_dereference
In reply to Hangbin LiuQuoted 18 lines · Hangbin Liu
Looks commit
4740d6382790("bonding: add proper__rcuannotation forcurr_active_slave") missedrtnl_dereferenceforcurr_active_slaveinbond_miimon_commit().Fixes 4740d6382790 ("bonding: add proper __rcu annotation for curr_active_slave")Signed-off-by Hangbin Liu <[email protected]>--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/bonding/bond_main.c +0
-0
drivers/net/bonding/bond_main.c static void bond_miimon_commit(struct bonding *bond) · line 2692
Quoted 5 lines
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 (!rtnl_dereference (bond->curr_active_slave) || slave == primary)
We do not dereference the pointer here.
If this is fixing a sparse issue, then use the correct RCU helper for this.
( rcu_access_pointer())
Re: [PATCH net 1/3] bonding: access curr_active_slave with rtnl_dereference
Quoted 22 lines · Eric Dumazet
Quoted 21 lines · Hangbin Liu
Looks commit
4740d6382790("bonding: add proper__rcuannotation forcurr_active_slave") missedrtnl_dereferenceforcurr_active_slaveinbond_miimon_commit().Fixes 4740d6382790 ("bonding: add proper __rcu annotation for curr_active_slave")Signed-off-by Hangbin Liu <[email protected]>--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/bonding/bond_main.c +0
-0@@ -2689,7 +2689,7 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP );
Quoted 8 lines
drivers/net/bonding/bond_main.c static void bond_miimon_commit(struct bonding *bond) · line 2692
Quoted 2 lines
drivers/net/bonding/bond_main.c +1
-1-if (!bond->curr_active_slave || slave == primary) +if (!rtnl_dereference (bond->curr_active_slave) || slave == primary)We do not dereference the pointer here.
If this is fixing a sparse issue, then use the correct RCU helper for this.
(
rcu_access_pointer())
Hmm... I saw in 4740d6382790 ("bonding: add proper __rcu annotation for
curr_active_slave") there are also some dereference like that. Should I also
fix them at the same time? e.g.
@@ -2607,8 +2612,8 @@ static void bond_ab_arp_commit(struct bonding *bond)
case BOND_LINK_UP:
trans_start = dev_trans_start(slave->dev);- if (bond->curr_active_slave != slave ||
- (!bond->curr_active_slave &&
+ if (rtnl_dereference(bond->curr_active_slave) != slave ||
+ (!rtnl_dereference(bond->curr_active_slave) &&
Thanks
Hangbin
Re: [PATCH net 1/3] bonding: access curr_active_slave with rtnl_dereference
Quoted 29 lines · Hangbin Liu
Quoted 27 lines · Eric Dumazet
Quoted 18 lines · Hangbin Liu
Looks commit
4740d6382790("bonding: add proper__rcuannotation forcurr_active_slave") missedrtnl_dereferenceforcurr_active_slaveinbond_miimon_commit().Fixes 4740d6382790 ("bonding: add proper __rcu annotation for curr_active_slave")Signed-off-by Hangbin Liu <[email protected]>--- drivers/net/bonding/bond_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/net/bonding/bond_main.c +0
-0drivers/net/bonding/bond_main.c static void bond_miimon_commit(struct bonding *bond) · line 2692
Quoted 5 lines
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 (!rtnl_dereference (bond->curr_active_slave) || slave == primary)We do not dereference the pointer here.
Quoted 7 lines
Quoted 3 lines
If this is fixing a sparse issue, then use the correct RCU helper for this.
(
rcu_access_pointer())Hmm... I saw in
4740d6382790("bonding: add proper__rcuannotation for
curr_active_slave") there are also some dereference like that. Should I also
fix them at the same time? e.g.
There is no 'fix' really. I do not see any reason to change this part.
It is merely a matter of repeating or not the fact that RTNL (or another lock) is held.
Review static void bond_ab_arp_commit(struct bonding *bond) · line 2617
Quoted 10 lines
(quoted diff) +2
-2@@ -2607,8 +2612,8 @@ static void bond_ab_arp_commit(struct bonding *bond) case BOND_LINK_UP: trans_start = dev_trans_start(slave->dev); - if (bond->curr_active_slave != slave || - (!bond->curr_active_slave && + if (rtnl_dereference(bond->curr_active_slave) != slave || + (!rtnl_dereference(bond->curr_active_slave) &&
At the time of commit 4740d6382790 we wanted to make sure the bond->curr_slave_lock
was taken, because it was the assertion at that time.
Then later, bond_deref_active_protected() has been removed, because curr_slave_lock has been removed.
$ git log --oneline --reverse b25bd2515ea32cf5ddd5fd5a2a93b8c9dd875e4f..8c0bc550288d81e9ad8a2ed9136a72140b9ef507 86e749866d7c6b0ee1f9377cf7142f2690596a05 bonding: 3ad: clean up curr_slave_lock usage 62c5f5185397f4bd8e5defe6fcb86420deeb2b38 bonding: alb: remove curr_slave_lock 1c72cfdc96e63bf975cab514c4ca4d8a661ba0e6 bonding: clean curr_slave_lock use b743562819bd97cc7c282e870896bae8016b64b5 bonding: convert curr_slave_lock to a spinlock and rename it 4bab16d7c97498e91564231b922d49f52efaf7d4 bonding: alb: convert to bond->mode_lock e470259fa1bd7ce5a375b16c5ec97cc0e83b058d bonding: 3ad: convert to bond->mode_lock 8c0bc550288d81e9ad8a2ed9136a72140b9ef507 bonding: adjust locking comments
Now, you post a patch for bond_miimon_commit() which already has :
if (slave == rcu_access_pointer(bond->curr_active_slave))
goto do_failover;
So really it is a matter of consistency in _this_ function, which is run under RTNL for sure.
It is also a patch for net-next tree, because it fixes no bug.
I would not add a Fixes: tag to avoid dealing with useless backports.
Re: [PATCH net 1/3] bonding: access curr_active_slave with rtnl_dereference
Quoted 7 lines · Eric Dumazet
Now, you post a patch for
bond_miimon_commit()which already has :if (slave ==
rcu_access_pointer(bond->curr_active_slave))goto do_failover;So really it is a matter of consistency in _this_ function, which is run under RTNL for sure.
Ah, thanks for the explanation.
Quoted 3 lines
It is also a patch for net-next tree, because it fixes no bug.
I would not add a Fixes: tag to avoid dealing with useless backports.
OK, I will do as your suggest.
Cheers
Hangbin
PATCH 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.
--- drivers/net/bonding/bond_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/bonding/bond_main.c +4 -2
@@ -2689,7 +2689,8 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP ); -if (!rtnl_dereference (bond->curr_active_slave) || slave == primary) +if (!rtnl_dereference (bond->curr_active_slave) || slave == primary || + slave->prio >rtnl_dereference (bond->curr_active_slave)->prio) goto do_failover;continue ;
@@ -3550,7 +3551,8 @@ 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)) + slave ==rtnl_dereference (bond->primary_slave) || + slave->prio >rtnl_dereference (bond->curr_active_slave)->prio) goto do_failover; }
Signature · 1 line
2.38.1
Re: [PATCH net 2/3] bonding: do failover when high prio link up
Quoted 17 lines · Hangbin Liu
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.
Reported-by Liang Li <[email protected]>Fixes 0a2ff7cc8ad4 ("Bonding: add per-port priority for failover re-selection")Signed-off-by Hangbin Liu <[email protected]>---
drivers/net/bonding/bond_main.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +0
-0
drivers/net/bonding/bond_main.c static void bond_miimon_commit(struct bonding *bond) · line 2694
Quoted 7 lines
drivers/net/bonding/bond_main.c +2
-1@@ -2689,7 +2689,8 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP ); -if (!rtnl_dereference (bond->curr_active_slave) || slave == primary) +if (!rtnl_dereference (bond->curr_active_slave) || slave == primary || + slave->prio >rtnl_dereference (bond->curr_active_slave)->prio) goto do_failover;
I am not really familiar with this prio logic, seems to be new. Anyway, what if one of the next slaves has higher prio than this slave and the current active ? I see that the loop over all the slaves continues even after the failover,
but why would you do all these failovers until you settle on the highest
prio one ?
shouldn't you do something similar to bond_choose_primary_or_current() outside the loop, once you've updated all the slaves link states
Please let me know if I am wandering in the wrong directions Anyway, LGTM:
Re: [PATCH net 2/3] bonding: do failover when high prio link up
Quoted 21 lines · Saeed Mahameed
Quoted 20 lines · Hangbin Liu
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.
Reported-by Liang Li <[email protected]>Fixes 0a2ff7cc8ad4 ("Bonding: add per-port priority for failover re-selection")Signed-off-by Hangbin Liu <[email protected]>---
drivers/net/bonding/bond_main.c| 6 ++++--1 file changed, 4 insertions(+), 2 deletions(-)drivers/net/bonding/bond_main.c +0
-0@@ -2689,7 +2689,8 @@ static void bond_miimon_commit(struct bonding *bond)bond_miimon_link_change (bond, slave,BOND_LINK_UP );
Quoted 11 lines
drivers/net/bonding/bond_main.c static void bond_miimon_commit(struct bonding *bond) · line 2694
Quoted 4 lines
drivers/net/bonding/bond_main.c +2
-1-if (!rtnl_dereference (bond->curr_active_slave) || slave == primary) +if (!rtnl_dereference (bond->curr_active_slave) || slave == primary || + slave->prio >rtnl_dereference (bond->curr_active_slave)->prio) goto do_failover;I am not really familiar with this prio logic, seems to be new. Anyway, what if one of the next slaves has higher prio than this slave and the current active ? I see that the loop over all the slaves continues even after the failover,
but why would you do all these failovers until you settle on the highest prio one ?
Thanks, this makes sense to me. I will fix it.
Hangbin
Quoted 15 lines
shouldn't you do something similar to
bond_choose_primary_or_current()outside the loop, once you've updated all the slaves link statesPlease let me know if I am wandering in the wrong directions Anyway, LGTM:
Reviewed-by Saeed Mahameed <[email protected]>
PATCH 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 | 246 ++++++++++++++++++ 2 files changed, 248 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 +246 -0
246 lines not on this page · raw message
Signature · 1 line
2.38.1
Quoted 10 lines · Hangbin Liu
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.
Hangbin Liu (2):
bonding: accesscurr_active_slavewithrtnl_dereference
bonding: do failover when high prio link upLiang Li (1):
selftests: bonding: add bonding prio option test
For the series:
The only comment I have is that since prio is a signed value, it
would be nice if the selftest tested negative prio values.
-J
Quoted 9 lines
drivers/net/bonding/bond_main.c | 6 +- .../selftests/drivers/net/bonding/Makefile | 3 +- .../drivers/net/bonding/option_prio.sh | 246 ++++++++++++++++++ 3 files changed, 252 insertions(+), 3 deletions(-)create mode 100755
tools/testing/selftests/drivers/net/bonding/option_prio.shSignature · 1 line
2.38.1
---
-Jay Vosburgh, [email protected]