bonding: fix bond recovery in mode 2
Subsystems (4)
PATCH 1/2 selftests: bonding: up/down delay w/ slave link flapping
In reply to Jonathan ToppinsVerify when a bond is configured with {up,down}delay and the link state of slave members flaps if there are no remaining members up the bond should immediately select a member to bring up. (from bonding.txt section 13.1 paragraph 4)
--- .../selftests/drivers/net/bonding/Makefile | 4 +- .../selftests/drivers/net/bonding/lag_lib.sh | 107 ++++++++++++++++++ .../net/bonding/mode-1-recovery-updelay.sh | 45 ++++++++ .../net/bonding/mode-2-recovery-updelay.sh | 45 ++++++++ .../selftests/drivers/net/bonding/settings | 2 +- 5 files changed, 201 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh
tools/testing/selftests/drivers/net/bonding/Makefile +3 -1
@@ -5,7 +5,9 @@ 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 \ + mode-1-recovery-updelay.sh \ + mode-2-recovery-updelay.sh TEST_FILES := \ lag_lib.sh \
tools/testing/selftests/drivers/net/bonding/lag_lib.sh +107 -0
116 lines not on this page · raw message
tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh new file +45 -0
45 lines not on this page · raw message
tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh new file +45 -0
45 lines not on this page · raw message
tools/testing/selftests/drivers/net/bonding/settings +1 -1
@@ -1 +1 @@ -timeout=60 +timeout=120
Signature · 1 line
2.31.1
cover bonding: fix bond recovery in mode 2
When a bond is configured with a non-zero updelay and in mode 2 the bond never recovers after all slaves lose link. The first patch adds selftests that demonstrate the issue and the second patch fixes the issue by ignoring the updelay when there are no usable slaves.
Jonathan Toppins (2):
selftests: bonding: up/down delay w/ slave link flapping
bonding: fix link recovery in mode 2 when updelay is nonzero
drivers/net/bonding/bond_main.c | 11 +- .../selftests/drivers/net/bonding/Makefile | 4 +- .../selftests/drivers/net/bonding/lag_lib.sh | 107 ++++++++++++++++++ .../net/bonding/mode-1-recovery-updelay.sh | 45 ++++++++ .../net/bonding/mode-2-recovery-updelay.sh | 45 ++++++++ .../selftests/drivers/net/bonding/settings | 2 +- 6 files changed, 211 insertions(+), 3 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.sh
Signature · 1 line
2.31.1
PATCH 2/2 bonding: fix link recovery in mode 2 when updelay is nonzero
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
--- drivers/net/bonding/bond_main.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
drivers/net/bonding/bond_main.c +10 -1
@@ -2529,7 +2529,16 @@ static int bond_miimon_inspect(struct bonding *bond)struct slave *slave;bool ignore_updelay; - ignore_updelay = !rcu_dereference (bond->curr_active_slave); +if (BOND_MODE (bond) ==BOND_MODE_ACTIVEBACKUP ) { + ignore_updelay = !rcu_dereference (bond->curr_active_slave); + }else { +struct bond_up_slave *usable_slaves; + + usable_slaves =rcu_dereference (bond->usable_slaves); + +if (usable_slaves && usable_slaves->count ==0 ) + ignore_updelay = true; + }bond_for_each_slave_rcu (bond, slave, iter) {bond_propose_link_state (slave,BOND_LINK_NOCHANGE );
Signature · 1 line
2.31.1
Paolo Abeni
maintainerRe: [PATCH net-next 1/2] selftests: bonding: up/down delay w/ slave link flapping
In reply to Jonathan ToppinsQuoted 127 lines · Jonathan Toppins
Verify when a bond is configured with {up,down}delay and the link state of slave members flaps if there are no remaining members up the bond should immediately select a member to bring up. (from bonding.txt section 13.1 paragraph 4)
Suggested-by Liang Li <[email protected]>Signed-off-by Jonathan Toppins <[email protected]>--- .../selftests/drivers/net/bonding/Makefile | 4 +- .../selftests/drivers/net/bonding/lag_lib.sh | 107 ++++++++++++++++++ .../net/bonding/mode-1-recovery-updelay.sh | 45 ++++++++ .../net/bonding/mode-2-recovery-updelay.sh | 45 ++++++++ .../selftests/drivers/net/bonding/settings | 2 +- 5 files changed, 201 insertions(+), 2 deletions(-) create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-1-recovery-updelay.sh create mode 100755 tools/testing/selftests/drivers/net/bonding/mode-2-recovery-updelay.shtools/testing/selftests/drivers/net/bonding/Makefile +3
-1@@ -5,7 +5,9 @@ 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 \ + mode-1-recovery-updelay.sh \ + mode-2-recovery-updelay.sh TEST_FILES := \ lag_lib.sh \tools/testing/selftests/drivers/net/bonding/lag_lib.sh +80
-0@@ -1,6 +1,8 @@ #!/bin/bash # SPDX-License-Identifier: GPL-2.0 +NAMESPACES="" + # Test that a link aggregation device (bonding, team) removes the hardware # addresses that it adds on its underlying devices. test_LAG_cleanup()@@ -59,3 +61,108 @@ test_LAG_cleanup() log_test "$driver cleanup mode $mode" } + +# Build a generic 2 node net namespace with 2 connections +# between the namespaces +# +# +-----------+ +-----------+ +# | node1 | | node2 | +# | | | | +# | | | | +# | eth0 +-------+ eth0 | +# | | | | +# | eth1 +-------+ eth1 | +# | | | | +# +-----------+ +-----------+ +lag_setup2x2() +{ + local state=${1:-down} + local namespaces="lag_node1 lag_node2" + + # create namespaces + for n in ${namespaces}; do + ip netns add ${n} + done + + # wire up namespaces + ip link add name lag1 type veth peer name lag1-end + ip link set dev lag1 netns lag_node1 $state name eth0 + ip link set dev lag1-end netns lag_node2 $state name eth0 + + ip link add name lag1 type veth peer name lag1-end + ip link set dev lag1 netns lag_node1 $state name eth1 + ip link set dev lag1-end netns lag_node2 $state name eth1 + + NAMESPACES="${namespaces}" +} + +# cleanup all lag related namespaces and remove the bonding module +lag_cleanup() +{ + for n in ${NAMESPACES}; do + ip netns delete ${n} >/dev/null 2>&1 || true + done + modprobe -r bonding +} + +SWITCH="lag_node1" +CLIENT="lag_node2" +CLIENTIP="172.20.2.1" +SWITCHIP="172.20.2.2" + +lag_setup_network() +{ + lag_setup2x2 "down" + + # create switch + ip netns exec ${SWITCH} ip link add br0 up type bridge + ip netns exec ${SWITCH} ip link set eth0 master br0 up + ip netns exec ${SWITCH} ip link set eth1 master br0 up + ip netns exec ${SWITCH} ip addr add ${SWITCHIP}/24 dev br0 +} + +lag_reset_network() +{ + ip netns exec ${CLIENT} ip link del bond0 + ip netns exec ${SWITCH} ip link set eth0 up + ip netns exec ${SWITCH} ip link set eth1 up +} + +create_bond() +{ + # create client + ip netns exec ${CLIENT} ip link set eth0 down + ip netns exec ${CLIENT} ip link set eth1 down + + ip netns exec ${CLIENT} ip link add bond0 type bond $@ + ip netns exec ${CLIENT} ip link set eth0 master bond0 + ip netns exec ${CLIENT} ip link set eth1 master bond0 + ip netns exec ${CLIENT} ip link set bond0 up + ip netns exec ${CLIENT} ip addr add ${CLIENTIP}/24 dev bond0
tools/testing/selftests/drivers/net/bonding/lag_lib.sh test_LAG_cleanup() · line 151
Quoted 10 lines
tools/testing/selftests/drivers/net/bonding/lag_lib.sh +10
-0+} + +test_bond_recovery() +{ + RET=0 + + create_bond $@ + + # verify connectivity + ip netns exec ${CLIENT} ping ${SWITCHIP} -c 5 >/dev/null 2>&1
Minor nit: here and below you reduce the count number, to shorten significantly the tests runtime.
Quoted 6 lines
tools/testing/selftests/drivers/net/bonding/lag_lib.sh +6
-0+ check_err $? "No connectivity" + + # force the links of the bond down + ip netns exec ${SWITCH} ip link set eth0 down + sleep 2 + ip netns exec ${SWITCH} ip link set eth0 up
tools/testing/selftests/drivers/net/bonding/lag_lib.sh test_LAG_cleanup() · line 167
Quoted 10 lines
tools/testing/selftests/drivers/net/bonding/lag_lib.sh +10
-0+ ip netns exec ${SWITCH} ip link set eth1 down + + # re-verify connectivity + ip netns exec ${CLIENT} ping ${SWITCHIP} -c 5 >/dev/null 2>&1 + + local rc=$? + check_err $rc "Bond failed to recover" + log_test "$1 ($2) bond recovery" + lag_reset_network + return 0
Minor nit: the return statement is not needed here.
Cheers,
Paolo
Paolo Abeni
maintainerRe: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
In reply to Jonathan ToppinsHello,
Quoted 7 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Signed-off-by Jonathan Toppins <[email protected]>
Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
Thanks,
Paolo
Re: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
Quoted 9 lines · Paolo Abeni
Hello,
Quoted 6 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Quoted 7 lines
Quoted 1 line
Signed-off-by Jonathan Toppins <[email protected]>Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
I could not find a reasonable fixes tag for this, hence why I targeted the net-next tree.
-Jon
Paolo Abeni
maintainerRe: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
Quoted 12 lines · Jonathan Toppins
Quoted 11 lines · Paolo Abeni
Hello,
Quoted 7 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Signed-off-by Jonathan Toppins <[email protected]>
Quoted 8 lines
Quoted 5 lines
Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
I could not find a reasonable fixes tag for this, hence why I targeted the net-next tree.
When in doubt I think it's preferrable to point out a commit surely affected by the issue - even if that is possibly not the one introducing the issue - than no Fixes as all. The lack of tag will make more difficult the work for stable teams.
In this specific case I think that:
should be ok, WDYT? if you agree would you mind repost for -net?
Thanks,
Paolo
Re: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
Quoted 29 lines · Paolo Abeni
Quoted 12 lines · Jonathan Toppins
Quoted 11 lines · Paolo Abeni
Hello,
Quoted 7 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Signed-off-by Jonathan Toppins <[email protected]>Quoted 8 lines
Quoted 5 lines
Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
I could not find a reasonable fixes tag for this, hence why I targeted the net-next tree.
When in doubt I think it's preferrable to point out a commit surely affected by the issue - even if that is possibly not the one introducing the issue - than no Fixes as all. The lack of tag will make more difficult the work for stable teams.
In this specific case I think that:
Quoted 8 lines
Fixes 41f891004063 ("bonding: ignore updelay param when there is no active slave")should be ok, WDYT? if you agree would you mind repost for -net?
Thanks,
Paolo
Yes that looks like a good one. I will repost to -net a v2 that includes changes to reduce the number of icmp echos sent before failing the test.
Thanks,
-Jon
Re: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
Quoted 36 lines · Jonathan Toppins
Quoted 35 lines · Paolo Abeni
Quoted 12 lines · Jonathan Toppins
Quoted 11 lines · Paolo Abeni
Hello,
Quoted 7 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Signed-off-by Jonathan Toppins <[email protected]>Quoted 8 lines
Quoted 5 lines
Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
I could not find a reasonable fixes tag for this, hence why I targeted the net-next tree.
When in doubt I think it's preferrable to point out a commit surely affected by the issue - even if that is possibly not the one introducing the issue - than no Fixes as all. The lack of tag will make more difficult the work for stable teams.
In this specific case I think that:
Fixes 41f891004063 ("bonding: ignore updelay param when there is no active slave")should be ok, WDYT? if you agree would you mind repost for -net?
Thanks,
Quoted 8 lines
Quoted 2 lines
Paolo
Yes that looks like a good one. I will repost to -net a v2 that includes changes to reduce the number of icmp echos sent before failing the test.
Thanks,
-Jon
One minor nit - could you please change "mode 2" to "mode balance-xor" ?
It saves reviewers some grepping around the code to see what is mode 2.
Obviously one has to dig in the code to see how it's affected, but still
it is a bit more understandable. It'd be nice to add more as to why the link is not recovered, I get it after reading the code, but it would be nice to include a more detailed explanation in the commit message as well.
Thanks,
Nik
Re: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
Quoted 53 lines · Nikolay Aleksandrov
Quoted 36 lines · Jonathan Toppins
Quoted 35 lines · Paolo Abeni
Quoted 12 lines · Jonathan Toppins
Quoted 11 lines · Paolo Abeni
Hello,
Quoted 7 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Signed-off-by Jonathan Toppins <[email protected]>Quoted 8 lines
Quoted 5 lines
Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
I could not find a reasonable fixes tag for this, hence why I targeted the net-next tree.
When in doubt I think it's preferrable to point out a commit surely affected by the issue - even if that is possibly not the one introducing the issue - than no Fixes as all. The lack of tag will make more difficult the work for stable teams.
In this specific case I think that:
Fixes 41f891004063 ("bonding: ignore updelay param when there is no active slave")should be ok, WDYT? if you agree would you mind repost for -net?
Thanks,
Quoted 8 lines
Quoted 2 lines
Paolo
Yes that looks like a good one. I will repost to -net a v2 that includes changes to reduce the number of icmp echos sent before failing the test.
Thanks,
-JonOne minor nit - could you please change "mode 2" to "mode balance-xor" ?
It saves reviewers some grepping around the code to see what is mode 2.
Obviously one has to dig in the code to see how it's affected, but still
it is a bit more understandable. It'd be nice to add more as to why the link is not recovered, I get it after reading the code, but it would be nice to include a more detailed explanation in the commit message as well.
Quoted 3 lines
Thanks,
Nik
Ah, I just noticed I'm late to the party. :)
Nevermind my comments, no need for a v3.
Re: [PATCH net-next 2/2] bonding: fix link recovery in mode 2 when updelay is nonzero
Quoted 54 lines · Nikolay Aleksandrov
Quoted 53 lines · Nikolay Aleksandrov
Quoted 36 lines · Jonathan Toppins
Quoted 35 lines · Paolo Abeni
Quoted 12 lines · Jonathan Toppins
Quoted 11 lines · Paolo Abeni
Hello,
Quoted 7 lines · Jonathan Toppins
Before this change when a bond in mode 2 lost link, all of its slaves lost link, the bonding device would never recover even after the expiration of updelay. This change removes the updelay when the bond currently has no usable links. Conforming to bonding.txt section 13.1 paragraph 4.
Signed-off-by Jonathan Toppins <[email protected]>Quoted 8 lines
Quoted 5 lines
Why are you targeting net-next? This looks like something suitable to the -net tree to me. If, so could you please include a Fixes tag?
Note that we can add new self-tests even via the -net tree.
I could not find a reasonable fixes tag for this, hence why I targeted the net-next tree.
When in doubt I think it's preferrable to point out a commit surely affected by the issue - even if that is possibly not the one introducing the issue - than no Fixes as all. The lack of tag will make more difficult the work for stable teams.
In this specific case I think that:
Fixes 41f891004063 ("bonding: ignore updelay param when there is no active slave")should be ok, WDYT? if you agree would you mind repost for -net?
Thanks,
Quoted 8 lines
Quoted 2 lines
Paolo
Yes that looks like a good one. I will repost to -net a v2 that includes changes to reduce the number of icmp echos sent before failing the test.
Thanks,
-JonOne minor nit - could you please change "mode 2" to "mode balance-xor" ?
It saves reviewers some grepping around the code to see what is mode 2.
Obviously one has to dig in the code to see how it's affected, but still
it is a bit more understandable. It'd be nice to add more as to why the link is not recovered, I get it after reading the code, but it would be nice to include a more detailed explanation in the commit message as well.
Quoted 7 lines
Quoted 3 lines
Thanks,
NikAh, I just noticed I'm late to the party. :)
Nevermind my comments, no need for a v3.
If there are other issues with v2. I will gladly include these comments in a v3.
Thanks,
-Jon