Skip to content

Commit d43eff0

Browse files
Jonathan Toppinskuba-moo
authored andcommitted
selftests: bonding: up/down delay w/ slave link flapping
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]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 64a8f8f commit d43eff0

File tree

5 files changed

+200
-2
lines changed

5 files changed

+200
-2
lines changed

tools/testing/selftests/drivers/net/bonding/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ TEST_PROGS := \
55
bond-arp-interval-causes-panic.sh \
66
bond-break-lacpdu-tx.sh \
77
bond-lladdr-target.sh \
8-
dev_addr_lists.sh
8+
dev_addr_lists.sh \
9+
mode-1-recovery-updelay.sh \
10+
mode-2-recovery-updelay.sh
911

1012
TEST_FILES := \
1113
lag_lib.sh \

tools/testing/selftests/drivers/net/bonding/lag_lib.sh

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#!/bin/bash
22
# SPDX-License-Identifier: GPL-2.0
33

4+
NAMESPACES=""
5+
46
# Test that a link aggregation device (bonding, team) removes the hardware
57
# addresses that it adds on its underlying devices.
68
test_LAG_cleanup()
@@ -59,3 +61,107 @@ test_LAG_cleanup()
5961

6062
log_test "$driver cleanup mode $mode"
6163
}
64+
65+
# Build a generic 2 node net namespace with 2 connections
66+
# between the namespaces
67+
#
68+
# +-----------+ +-----------+
69+
# | node1 | | node2 |
70+
# | | | |
71+
# | | | |
72+
# | eth0 +-------+ eth0 |
73+
# | | | |
74+
# | eth1 +-------+ eth1 |
75+
# | | | |
76+
# +-----------+ +-----------+
77+
lag_setup2x2()
78+
{
79+
local state=${1:-down}
80+
local namespaces="lag_node1 lag_node2"
81+
82+
# create namespaces
83+
for n in ${namespaces}; do
84+
ip netns add ${n}
85+
done
86+
87+
# wire up namespaces
88+
ip link add name lag1 type veth peer name lag1-end
89+
ip link set dev lag1 netns lag_node1 $state name eth0
90+
ip link set dev lag1-end netns lag_node2 $state name eth0
91+
92+
ip link add name lag1 type veth peer name lag1-end
93+
ip link set dev lag1 netns lag_node1 $state name eth1
94+
ip link set dev lag1-end netns lag_node2 $state name eth1
95+
96+
NAMESPACES="${namespaces}"
97+
}
98+
99+
# cleanup all lag related namespaces and remove the bonding module
100+
lag_cleanup()
101+
{
102+
for n in ${NAMESPACES}; do
103+
ip netns delete ${n} >/dev/null 2>&1 || true
104+
done
105+
modprobe -r bonding
106+
}
107+
108+
SWITCH="lag_node1"
109+
CLIENT="lag_node2"
110+
CLIENTIP="172.20.2.1"
111+
SWITCHIP="172.20.2.2"
112+
113+
lag_setup_network()
114+
{
115+
lag_setup2x2 "down"
116+
117+
# create switch
118+
ip netns exec ${SWITCH} ip link add br0 up type bridge
119+
ip netns exec ${SWITCH} ip link set eth0 master br0 up
120+
ip netns exec ${SWITCH} ip link set eth1 master br0 up
121+
ip netns exec ${SWITCH} ip addr add ${SWITCHIP}/24 dev br0
122+
}
123+
124+
lag_reset_network()
125+
{
126+
ip netns exec ${CLIENT} ip link del bond0
127+
ip netns exec ${SWITCH} ip link set eth0 up
128+
ip netns exec ${SWITCH} ip link set eth1 up
129+
}
130+
131+
create_bond()
132+
{
133+
# create client
134+
ip netns exec ${CLIENT} ip link set eth0 down
135+
ip netns exec ${CLIENT} ip link set eth1 down
136+
137+
ip netns exec ${CLIENT} ip link add bond0 type bond $@
138+
ip netns exec ${CLIENT} ip link set eth0 master bond0
139+
ip netns exec ${CLIENT} ip link set eth1 master bond0
140+
ip netns exec ${CLIENT} ip link set bond0 up
141+
ip netns exec ${CLIENT} ip addr add ${CLIENTIP}/24 dev bond0
142+
}
143+
144+
test_bond_recovery()
145+
{
146+
RET=0
147+
148+
create_bond $@
149+
150+
# verify connectivity
151+
ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 >/dev/null 2>&1
152+
check_err $? "No connectivity"
153+
154+
# force the links of the bond down
155+
ip netns exec ${SWITCH} ip link set eth0 down
156+
sleep 2
157+
ip netns exec ${SWITCH} ip link set eth0 up
158+
ip netns exec ${SWITCH} ip link set eth1 down
159+
160+
# re-verify connectivity
161+
ip netns exec ${CLIENT} ping ${SWITCHIP} -c 2 >/dev/null 2>&1
162+
163+
local rc=$?
164+
check_err $rc "Bond failed to recover"
165+
log_test "$1 ($2) bond recovery"
166+
lag_reset_network
167+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
# Regression Test:
5+
# When the bond is configured with down/updelay and the link state of
6+
# slave members flaps if there are no remaining members up the bond
7+
# should immediately select a member to bring up. (from bonding.txt
8+
# section 13.1 paragraph 4)
9+
#
10+
# +-------------+ +-----------+
11+
# | client | | switch |
12+
# | | | |
13+
# | +--------| link1 |-----+ |
14+
# | | +-------+ | |
15+
# | | | | | |
16+
# | | +-------+ | |
17+
# | | bond | link2 | Br0 | |
18+
# +-------------+ +-----------+
19+
# 172.20.2.1 172.20.2.2
20+
21+
22+
REQUIRE_MZ=no
23+
REQUIRE_JQ=no
24+
NUM_NETIFS=0
25+
lib_dir=$(dirname "$0")
26+
source "$lib_dir"/net_forwarding_lib.sh
27+
source "$lib_dir"/lag_lib.sh
28+
29+
cleanup()
30+
{
31+
lag_cleanup
32+
}
33+
34+
trap cleanup 0 1 2
35+
36+
lag_setup_network
37+
test_bond_recovery mode 1 miimon 100 updelay 0
38+
test_bond_recovery mode 1 miimon 100 updelay 200
39+
test_bond_recovery mode 1 miimon 100 updelay 500
40+
test_bond_recovery mode 1 miimon 100 updelay 1000
41+
test_bond_recovery mode 1 miimon 100 updelay 2000
42+
test_bond_recovery mode 1 miimon 100 updelay 5000
43+
test_bond_recovery mode 1 miimon 100 updelay 10000
44+
45+
exit "$EXIT_STATUS"
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/bin/sh
2+
# SPDX-License-Identifier: GPL-2.0
3+
4+
# Regression Test:
5+
# When the bond is configured with down/updelay and the link state of
6+
# slave members flaps if there are no remaining members up the bond
7+
# should immediately select a member to bring up. (from bonding.txt
8+
# section 13.1 paragraph 4)
9+
#
10+
# +-------------+ +-----------+
11+
# | client | | switch |
12+
# | | | |
13+
# | +--------| link1 |-----+ |
14+
# | | +-------+ | |
15+
# | | | | | |
16+
# | | +-------+ | |
17+
# | | bond | link2 | Br0 | |
18+
# +-------------+ +-----------+
19+
# 172.20.2.1 172.20.2.2
20+
21+
22+
REQUIRE_MZ=no
23+
REQUIRE_JQ=no
24+
NUM_NETIFS=0
25+
lib_dir=$(dirname "$0")
26+
source "$lib_dir"/net_forwarding_lib.sh
27+
source "$lib_dir"/lag_lib.sh
28+
29+
cleanup()
30+
{
31+
lag_cleanup
32+
}
33+
34+
trap cleanup 0 1 2
35+
36+
lag_setup_network
37+
test_bond_recovery mode 2 miimon 100 updelay 0
38+
test_bond_recovery mode 2 miimon 100 updelay 200
39+
test_bond_recovery mode 2 miimon 100 updelay 500
40+
test_bond_recovery mode 2 miimon 100 updelay 1000
41+
test_bond_recovery mode 2 miimon 100 updelay 2000
42+
test_bond_recovery mode 2 miimon 100 updelay 5000
43+
test_bond_recovery mode 2 miimon 100 updelay 10000
44+
45+
exit "$EXIT_STATUS"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
timeout=60
1+
timeout=120

0 commit comments

Comments
 (0)