Skip to content

Commit 45bf79b

Browse files
liuhangbinkuba-moo
authored andcommitted
selftests: bonding: reduce garp_test/arp_validate test time
The purpose of grat_arp is testing commit 9949e2e ("bonding: fix send_peer_notif overflow"). As the send_peer_notif was defined to u8, to overflow it, we need to send_peer_notif = num_peer_notif * peer_notif_delay = num_grat_arp * peer_notify_delay / miimon > 255 (kernel) (kernel parameter) (user parameter) e.g. 30 (num_grat_arp) * 1000 (peer_notify_delay) / 100 (miimon) > 255. Which need 30s to complete sending garp messages. To save the testing time, the only way is reduce the miimon number. Something like 30 (num_grat_arp) * 100 (peer_notify_delay) / 10 (miimon) > 255. To save more time, the 50 num_grat_arp testing could be removed. The arp_validate_test also need to check the mii_status, which sleep too long. Use slowwait to save some time. For other connection checkings, make sure active slave changed first. Reviewed-by: Przemek Kitszel <[email protected]> Signed-off-by: Hangbin Liu <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 9150820 commit 45bf79b

File tree

1 file changed

+29
-9
lines changed

1 file changed

+29
-9
lines changed

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

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,15 +45,23 @@ skip_ns()
4545
}
4646

4747
active_slave=""
48+
active_slave_changed()
49+
{
50+
local old_active_slave=$1
51+
local new_active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" \
52+
".[].linkinfo.info_data.active_slave")
53+
test "$old_active_slave" != "$new_active_slave"
54+
}
55+
4856
check_active_slave()
4957
{
5058
local target_active_slave=$1
59+
slowwait 2 active_slave_changed $active_slave
5160
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
5261
test "$active_slave" = "$target_active_slave"
5362
check_err $? "Current active slave is $active_slave but not $target_active_slave"
5463
}
5564

56-
5765
# Test bonding prio option
5866
prio_test()
5967
{
@@ -84,13 +92,13 @@ prio_test()
8492

8593
# active slave should be the higher prio slave
8694
ip -n ${s_ns} link set $active_slave down
87-
bond_check_connection "fail over"
8895
check_active_slave eth2
96+
bond_check_connection "fail over"
8997

9098
# when only 1 slave is up
9199
ip -n ${s_ns} link set $active_slave down
92-
bond_check_connection "only 1 slave up"
93100
check_active_slave eth0
101+
bond_check_connection "only 1 slave up"
94102

95103
# when a higher prio slave change to up
96104
ip -n ${s_ns} link set eth2 up
@@ -140,8 +148,8 @@ prio_test()
140148
check_active_slave "eth1"
141149

142150
ip -n ${s_ns} link set $active_slave down
143-
bond_check_connection "change slave prio"
144151
check_active_slave "eth0"
152+
bond_check_connection "change slave prio"
145153
fi
146154
}
147155

@@ -199,6 +207,15 @@ prio()
199207
prio_ns "active-backup"
200208
}
201209

210+
wait_mii_up()
211+
{
212+
for i in $(seq 0 2); do
213+
mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
214+
[ ${mii_status} != "UP" ] && return 1
215+
done
216+
return 0
217+
}
218+
202219
arp_validate_test()
203220
{
204221
local param="$1"
@@ -211,7 +228,7 @@ arp_validate_test()
211228
[ $RET -ne 0 ] && log_test "arp_validate" "$retmsg"
212229

213230
# wait for a while to make sure the mii status stable
214-
sleep 5
231+
slowwait 5 wait_mii_up
215232
for i in $(seq 0 2); do
216233
mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
217234
if [ ${mii_status} != "UP" ]; then
@@ -276,10 +293,13 @@ garp_test()
276293
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
277294
ip -n ${s_ns} link set ${active_slave} down
278295

279-
exp_num=$(echo "${param}" | cut -f6 -d ' ')
280-
sleep $((exp_num + 2))
296+
# wait for active link change
297+
slowwait 2 active_slave_changed $active_slave
281298

299+
exp_num=$(echo "${param}" | cut -f6 -d ' ')
282300
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
301+
slowwait_for_counter $((exp_num + 5)) $exp_num \
302+
tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}"
283303

284304
# check result
285305
real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}")
@@ -296,8 +316,8 @@ garp_test()
296316
num_grat_arp()
297317
{
298318
local val
299-
for val in 10 20 30 50; do
300-
garp_test "mode active-backup miimon 100 num_grat_arp $val peer_notify_delay 1000"
319+
for val in 10 20 30; do
320+
garp_test "mode active-backup miimon 10 num_grat_arp $val peer_notify_delay 100"
301321
log_test "num_grat_arp" "active-backup miimon num_grat_arp $val"
302322
done
303323
}

0 commit comments

Comments
 (0)