selftests/bpf: Fix flaky fib_lookup test
authorMartin KaFai Lau <martin.lau@kernel.org>
Thu, 9 Mar 2023 06:02:44 +0000 (22:02 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 9 Mar 2023 19:37:55 +0000 (20:37 +0100)
commita6865576317f6249f3f83cf4c10ab56e627ee153
treefbd811d9fa5d852373c55f181b8de71c994ee1ab
parent23e403b326786c05f84515760886c2aedec84964
selftests/bpf: Fix flaky fib_lookup test

There is a report that fib_lookup test is flaky when running in parallel.
A symptom of slowness or delay. An example:

Testing IPv6 stale neigh
set_lookup_params:PASS:inet_pton(IPV6_IFACE_ADDR) 0 nsec
test_fib_lookup:PASS:bpf_prog_test_run_opts 0 nsec
test_fib_lookup:FAIL:fib_lookup_ret unexpected fib_lookup_ret: actual 0 != expected 7
test_fib_lookup:FAIL:dmac not match unexpected dmac not match: actual 1 != expected 0
dmac expected 11:11:11:11:11:11 actual 00:00:00:00:00:00

[ Note that the "fib_lookup_ret unexpected fib_lookup_ret actual 0 ..."
  is reversed in terms of expected and actual value. Fixing in this
  patch also. ]

One possibility is the testing stale neigh entry was marked dead by the
gc (in neigh_periodic_work). The default gc_stale_time sysctl is 60s.
This patch increases it to 15 mins.

It also:

- fixes the reversed arg (actual vs expected) in one of the
  ASSERT_EQ test
- removes the nodad command arg when adding v4 neigh entry which
  currently has a warning.

Fixes: 168de0233586 ("selftests/bpf: Add bpf_fib_lookup test")
Reported-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230309060244.3242491-1-martin.lau@linux.dev
tools/testing/selftests/bpf/prog_tests/fib_lookup.c