Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests: bonding: reduce garp_test/arp_validate test time

The purpose of grat_arp is testing commit 9949e2efb54e ("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 <przemyslaw.kitszel@intel.com>
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Link: https://lore.kernel.org/r/20240205130048.282087-4-liuhangbin@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Hangbin Liu and committed by
Jakub Kicinski
45bf79bc 9150820c

+29 -9
+29 -9
tools/testing/selftests/drivers/net/bonding/bond_options.sh
··· 45 45 } 46 46 47 47 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 + 48 56 check_active_slave() 49 57 { 50 58 local target_active_slave=$1 59 + slowwait 2 active_slave_changed $active_slave 51 60 active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") 52 61 test "$active_slave" = "$target_active_slave" 53 62 check_err $? "Current active slave is $active_slave but not $target_active_slave" 54 63 } 55 - 56 64 57 65 # Test bonding prio option 58 66 prio_test() ··· 92 84 93 85 # active slave should be the higher prio slave 94 86 ip -n ${s_ns} link set $active_slave down 95 - bond_check_connection "fail over" 96 87 check_active_slave eth2 88 + bond_check_connection "fail over" 97 89 98 90 # when only 1 slave is up 99 91 ip -n ${s_ns} link set $active_slave down 100 - bond_check_connection "only 1 slave up" 101 92 check_active_slave eth0 93 + bond_check_connection "only 1 slave up" 102 94 103 95 # when a higher prio slave change to up 104 96 ip -n ${s_ns} link set eth2 up ··· 148 140 check_active_slave "eth1" 149 141 150 142 ip -n ${s_ns} link set $active_slave down 151 - bond_check_connection "change slave prio" 152 143 check_active_slave "eth0" 144 + bond_check_connection "change slave prio" 153 145 fi 154 146 } 155 147 ··· 207 199 prio_ns "active-backup" 208 200 } 209 201 202 + wait_mii_up() 203 + { 204 + for i in $(seq 0 2); do 205 + mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status") 206 + [ ${mii_status} != "UP" ] && return 1 207 + done 208 + return 0 209 + } 210 + 210 211 arp_validate_test() 211 212 { 212 213 local param="$1" ··· 228 211 [ $RET -ne 0 ] && log_test "arp_validate" "$retmsg" 229 212 230 213 # wait for a while to make sure the mii status stable 231 - sleep 5 214 + slowwait 5 wait_mii_up 232 215 for i in $(seq 0 2); do 233 216 mii_status=$(cmd_jq "ip -n ${s_ns} -j -d link show eth$i" ".[].linkinfo.info_slave_data.mii_status") 234 217 if [ ${mii_status} != "UP" ]; then ··· 293 276 active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") 294 277 ip -n ${s_ns} link set ${active_slave} down 295 278 296 - exp_num=$(echo "${param}" | cut -f6 -d ' ') 297 - sleep $((exp_num + 2)) 279 + # wait for active link change 280 + slowwait 2 active_slave_changed $active_slave 298 281 282 + exp_num=$(echo "${param}" | cut -f6 -d ' ') 299 283 active_slave=$(cmd_jq "ip -n ${s_ns} -d -j link show bond0" ".[].linkinfo.info_data.active_slave") 284 + slowwait_for_counter $((exp_num + 5)) $exp_num \ 285 + tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}" 300 286 301 287 # check result 302 288 real_num=$(tc_rule_handle_stats_get "dev s${active_slave#eth} ingress" 101 ".packets" "-n ${g_ns}") ··· 316 296 num_grat_arp() 317 297 { 318 298 local val 319 - for val in 10 20 30 50; do 320 - garp_test "mode active-backup miimon 100 num_grat_arp $val peer_notify_delay 1000" 299 + for val in 10 20 30; do 300 + garp_test "mode active-backup miimon 10 num_grat_arp $val peer_notify_delay 100" 321 301 log_test "num_grat_arp" "active-backup miimon num_grat_arp $val" 322 302 done 323 303 }