summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtools/testing/selftests/net/test_neigh.sh27
1 files changed, 21 insertions, 6 deletions
diff --git a/tools/testing/selftests/net/test_neigh.sh b/tools/testing/selftests/net/test_neigh.sh
index 7c594bf6ead0..447423713266 100755
--- a/tools/testing/selftests/net/test_neigh.sh
+++ b/tools/testing/selftests/net/test_neigh.sh
@@ -63,6 +63,15 @@ exit_cleanup_all()
exit "${EXIT_STATUS}"
}
+get_periodic_gc_runs()
+{
+ local ns=$1
+ local tbl_name=$2
+
+ ip -n "$ns" -j -s ntable show name "$tbl_name" | \
+ jq '.[] | select(has("periodic_gc_runs")) | .["periodic_gc_runs"]'
+}
+
################################################################################
# Tests
@@ -282,24 +291,30 @@ extern_valid_common()
local periodic_gc_runs_t0
local periodic_gc_runs_t1
local orig_base_reachable
+ local base_reachable=10000
local orig_gc_stale
+ local timeout
run_cmd "ip -n $ns1 neigh flush dev veth0"
orig_thresh1=$(ip -j ntable show name "$tbl_name" | jq '.[] | select(has("thresh1")) | .["thresh1"]')
orig_base_reachable=$(ip -j ntable show name "$tbl_name" | jq '.[] | select(has("thresh1")) | .["base_reachable"]')
- run_cmd "ip ntable change name $tbl_name thresh1 10 base_reachable 10000"
+ run_cmd "ip ntable change name $tbl_name thresh1 10 base_reachable $base_reachable"
orig_gc_stale=$(ip -n "$ns1" -j ntable show name "$tbl_name" dev veth0 | jq '.[]["gc_stale"]')
run_cmd "ip -n $ns1 ntable change name $tbl_name dev veth0 gc_stale 1000"
run_cmd "ip -n $ns1 neigh add $ip_addr lladdr $mac nud stale dev veth0 extern_valid"
run_cmd "ip -n $ns1 neigh add ${subnet}3 lladdr $mac nud stale dev veth0"
- # Wait orig_base_reachable/2 for the new interval to take effect.
- run_cmd "sleep $(((orig_base_reachable / 1000) / 2 + 2))"
+ # Wait up to neigh_set_reach_time(BASE_REACHABLE_TIME) (~45s) + 5s
+ # for the new interval to take effect, see neigh_table_init().
+ timeout=$(((orig_base_reachable / 1000) * 3 / 2 + 5))
+ slowwait_for_counter "$timeout" 1 get_periodic_gc_runs "$ns1" "$tbl_name" >/dev/null
for i in {1..20}; do
run_cmd "ip -n $ns1 neigh add ${subnet}$((i + 4)) nud none dev veth0"
done
- periodic_gc_runs_t0=$(ip -j -s ntable show name "$tbl_name" | jq '.[] | select(has("periodic_gc_runs")) | .["periodic_gc_runs"]')
- run_cmd "sleep 10"
- periodic_gc_runs_t1=$(ip -j -s ntable show name "$tbl_name" | jq '.[] | select(has("periodic_gc_runs")) | .["periodic_gc_runs"]')
+ periodic_gc_runs_t0=$(get_periodic_gc_runs "$ns1" "$tbl_name")
+ # Wait up to BASE_REACHABLE_TIME / 2 + 5s, see neigh_periodic_work().
+ timeout=$(((base_reachable / 1000) / 2 + 5))
+ slowwait_for_counter "$timeout" 1 get_periodic_gc_runs "$ns1" "$tbl_name" >/dev/null
+ periodic_gc_runs_t1=$(get_periodic_gc_runs "$ns1" "$tbl_name")
[[ $periodic_gc_runs_t1 -ne $periodic_gc_runs_t0 ]]
check_err $? "Periodic garbage collection did not run"
run_cmd "ip -n $ns1 neigh get $ip_addr dev veth0 | grep \"extern_valid\""