test_neigh.sh configures the following attributes in the root netns, but now these can be set per netns. * NDTA_THRESH1 / NDTA_THRESH2 / NDTA_THRESH3 * NDTA_GC_INTERVAL Let's specify netns for "ip ntable". Signed-off-by: Kuniyuki Iwashima --- v3: Remove stale comments --- tools/testing/selftests/net/test_neigh.sh | 41 ++++++++++++----------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/tools/testing/selftests/net/test_neigh.sh b/tools/testing/selftests/net/test_neigh.sh index 447423713266..e70e31edf633 100755 --- a/tools/testing/selftests/net/test_neigh.sh +++ b/tools/testing/selftests/net/test_neigh.sh @@ -240,9 +240,6 @@ extern_valid_common() # Check that an "extern_valid" entry survives a forced garbage # collection. Add an entry, wait 5 seconds and add more entries than # "thresh3" so that forced garbage collection will run. - # - # Note that the garbage collection thresholds are global resources and - # that changes in the initial namespace affect all the namespaces. local forced_gc_runs_t0 local forced_gc_runs_t1 local orig_thresh1 @@ -250,18 +247,23 @@ extern_valid_common() local orig_thresh3 run_cmd "ip -n $ns1 neigh flush dev veth0" - orig_thresh1=$(ip -j ntable show name "$tbl_name" | jq '.[] | select(has("thresh1")) | .["thresh1"]') - orig_thresh2=$(ip -j ntable show name "$tbl_name" | jq '.[] | select(has("thresh2")) | .["thresh2"]') - orig_thresh3=$(ip -j ntable show name "$tbl_name" | jq '.[] | select(has("thresh3")) | .["thresh3"]') - run_cmd "ip ntable change name $tbl_name thresh3 10 thresh2 9 thresh1 8" + orig_thresh1=$(ip -n "$ns1" -j ntable show name "$tbl_name" | \ + jq '.[] | select(has("thresh1")) | .["thresh1"]') + orig_thresh2=$(ip -n "$ns1" -j ntable show name "$tbl_name" | \ + jq '.[] | select(has("thresh2")) | .["thresh2"]') + orig_thresh3=$(ip -n "$ns1" -j ntable show name "$tbl_name" | \ + jq '.[] | select(has("thresh3")) | .["thresh3"]') + run_cmd "ip -n $ns1 ntable change name $tbl_name thresh3 10 thresh2 9 thresh1 8" 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" run_cmd "sleep 5" - forced_gc_runs_t0=$(ip -j -s ntable show name "$tbl_name" | jq '.[] | select(has("forced_gc_runs")) | .["forced_gc_runs"]') + forced_gc_runs_t0=$(ip -n "$ns1" -j -s ntable show name "$tbl_name" | \ + jq '.[] | select(has("forced_gc_runs")) | .["forced_gc_runs"]') for i in {1..20}; do run_cmd "ip -n $ns1 neigh add ${subnet}$((i + 4)) nud none dev veth0" done - forced_gc_runs_t1=$(ip -j -s ntable show name "$tbl_name" | jq '.[] | select(has("forced_gc_runs")) | .["forced_gc_runs"]') + forced_gc_runs_t1=$(ip -n "$ns1" -j -s ntable show name "$tbl_name" | \ + jq '.[] | select(has("forced_gc_runs")) | .["forced_gc_runs"]') if [[ $forced_gc_runs_t1 -eq $forced_gc_runs_t0 ]]; then check_err 1 "Forced garbage collection did not run" fi @@ -272,7 +274,8 @@ extern_valid_common() log_test "$af_str \"extern_valid\" flag: Forced garbage collection" - run_cmd "ip ntable change name $tbl_name thresh3 $orig_thresh3 thresh2 $orig_thresh2 thresh1 $orig_thresh1" + run_cmd "ip -n $ns1 ntable change name $tbl_name \ + thresh3 $orig_thresh3 thresh2 $orig_thresh2 thresh1 $orig_thresh1" RET=0 @@ -284,10 +287,6 @@ extern_valid_common() # collection. Add an "extern_valid" entry, add more than "thresh1" # regular entries, wait "base_reachable" (longer than "gc_stale") # seconds and check that the "extern_valid" entry was not deleted. - # - # Note that the garbage collection thresholds and "base_reachable" are - # global resources and that changes in the initial namespace affect all - # the namespaces. local periodic_gc_runs_t0 local periodic_gc_runs_t1 local orig_base_reachable @@ -296,10 +295,13 @@ extern_valid_common() 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 $base_reachable" - orig_gc_stale=$(ip -n "$ns1" -j ntable show name "$tbl_name" dev veth0 | jq '.[]["gc_stale"]') + orig_thresh1=$(ip -n "$ns1" -j ntable show name "$tbl_name" | \ + jq '.[] | select(has("thresh1")) | .["thresh1"]') + orig_base_reachable=$(ip -n "$ns1" -j ntable show name "$tbl_name" | \ + jq '.[] | select(has("thresh1")) | .["base_reachable"]') + run_cmd "ip -n $ns1 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" @@ -325,7 +327,8 @@ extern_valid_common() log_test "$af_str \"extern_valid\" flag: Periodic garbage collection" run_cmd "ip -n $ns1 ntable change name $tbl_name dev veth0 gc_stale $orig_gc_stale" - run_cmd "ip ntable change name $tbl_name thresh1 $orig_thresh1 base_reachable $orig_base_reachable" + run_cmd "ip -n $ns1 ntable change name $tbl_name \ + thresh1 $orig_thresh1 base_reachable $orig_base_reachable" } extern_valid_ipv4() -- 2.55.0.691.gc56d675ccc-goog