Commit 45bf79bc authored by Hangbin Liu's avatar Hangbin Liu Committed by Jakub Kicinski

selftests: bonding: reduce garp_test/arp_validate test time

The purpose of grat_arp is testing commit 9949e2ef ("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: default avatarPrzemek Kitszel <przemyslaw.kitszel@intel.com>
Signed-off-by: default avatarHangbin Liu <liuhangbin@gmail.com>
Link: https://lore.kernel.org/r/20240205130048.282087-4-liuhangbin@gmail.comSigned-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 9150820c
...@@ -45,15 +45,23 @@ skip_ns() ...@@ -45,15 +45,23 @@ skip_ns()
} }
active_slave="" active_slave=""
active_slave_changed()
{
local old_active_slave=$1
local new_active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" \
".[].linkinfo.info_data.active_slave")
test "$old_active_slave" != "$new_active_slave"
}
check_active_slave() check_active_slave()
{ {
local target_active_slave=$1 local target_active_slave=$1
slowwait 2 active_slave_changed $active_slave
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
test "$active_slave" = "$target_active_slave" test "$active_slave" = "$target_active_slave"
check_err $? "Current active slave is $active_slave but not $target_active_slave" check_err $? "Current active slave is $active_slave but not $target_active_slave"
} }
# Test bonding prio option # Test bonding prio option
prio_test() prio_test()
{ {
...@@ -84,13 +92,13 @@ prio_test() ...@@ -84,13 +92,13 @@ prio_test()
# active slave should be the higher prio slave # active slave should be the higher prio slave
ip -n ${s_ns} link set $active_slave down ip -n ${s_ns} link set $active_slave down
bond_check_connection "fail over"
check_active_slave eth2 check_active_slave eth2
bond_check_connection "fail over"
# when only 1 slave is up # when only 1 slave is up
ip -n ${s_ns} link set $active_slave down ip -n ${s_ns} link set $active_slave down
bond_check_connection "only 1 slave up"
check_active_slave eth0 check_active_slave eth0
bond_check_connection "only 1 slave up"
# when a higher prio slave change to up # when a higher prio slave change to up
ip -n ${s_ns} link set eth2 up ip -n ${s_ns} link set eth2 up
...@@ -140,8 +148,8 @@ prio_test() ...@@ -140,8 +148,8 @@ prio_test()
check_active_slave "eth1" check_active_slave "eth1"
ip -n ${s_ns} link set $active_slave down ip -n ${s_ns} link set $active_slave down
bond_check_connection "change slave prio"
check_active_slave "eth0" check_active_slave "eth0"
bond_check_connection "change slave prio"
fi fi
} }
...@@ -199,6 +207,15 @@ prio() ...@@ -199,6 +207,15 @@ prio()
prio_ns "active-backup" prio_ns "active-backup"
} }
wait_mii_up()
{
for i in $(seq 0 2); do
mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
[ ${mii_status} != "UP" ] && return 1
done
return 0
}
arp_validate_test() arp_validate_test()
{ {
local param="$1" local param="$1"
...@@ -211,7 +228,7 @@ arp_validate_test() ...@@ -211,7 +228,7 @@ arp_validate_test()
[ $RET -ne 0 ] && log_test "arp_validate" "$retmsg" [ $RET -ne 0 ] && log_test "arp_validate" "$retmsg"
# wait for a while to make sure the mii status stable # wait for a while to make sure the mii status stable
sleep 5 slowwait 5 wait_mii_up
for i in $(seq 0 2); do for i in $(seq 0 2); do
mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status") mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status")
if [ ${mii_status} != "UP" ]; then if [ ${mii_status} != "UP" ]; then
...@@ -276,10 +293,13 @@ garp_test() ...@@ -276,10 +293,13 @@ garp_test()
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
ip -n ${s_ns} link set ${active_slave} down ip -n ${s_ns} link set ${active_slave} down
exp_num=$(echo "${param}" | cut -f6 -d ' ') # wait for active link change
sleep $((exp_num + 2)) slowwait 2 active_slave_changed $active_slave
exp_num=$(echo "${param}" | cut -f6 -d ' ')
active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave")
slowwait_for_counter $((exp_num + 5)) $exp_num \
tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}"
# check result # check result
real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}") real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}")
...@@ -296,8 +316,8 @@ garp_test() ...@@ -296,8 +316,8 @@ garp_test()
num_grat_arp() num_grat_arp()
{ {
local val local val
for val in 10 20 30 50; do for val in 10 20 30; do
garp_test "mode active-backup miimon 100 num_grat_arp $val peer_notify_delay 1000" garp_test "mode active-backup miimon 10 num_grat_arp $val peer_notify_delay 100"
log_test "num_grat_arp" "active-backup miimon num_grat_arp $val" log_test "num_grat_arp" "active-backup miimon num_grat_arp $val"
done done
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment