]> git.baikalelectronics.ru Git - kernel.git/commit
tools/bpf: fix batch-mode test failure of test_xdp_redirect.sh
authorYonghong Song <yhs@fb.com>
Tue, 6 Feb 2018 00:25:24 +0000 (16:25 -0800)
committerDaniel Borkmann <daniel@iogearbox.net>
Tue, 6 Feb 2018 10:34:42 +0000 (11:34 +0100)
commitf542f5dbba200a7dcbc7f06d494c19b14a3a6248
tree1cc7d1314079e5f25b16d25d6f272b68202ea422
parent82767488c1874f47971dcf8cead12c4ad3d69d61
tools/bpf: fix batch-mode test failure of test_xdp_redirect.sh

The tests at tools/testing/selftests/bpf can run in patch mode, e.g.,
    make -C tools/testing/selftests/bpf run_tests

With the batch mode, I experimented intermittent test failure of
test_xdp_redirect.sh.
    ....
    selftests: test_xdp_redirect [PASS]
    selftests: test_xdp_redirect.sh [PASS]
    RTNETLINK answers: File exists
    selftests: test_xdp_meta [FAILED]
    selftests: test_xdp_meta.sh [FAIL]
    ....

The following illustrates what caused the failure:
     (1). test_xdp_redirect creates veth pairs (veth1,veth11) and
          (veth2,veth22), and assign veth11 and veth22 to namespace
          ns1 and ns2 respectively.
     (2). at the end of test_xdp_redirect test, ns1 and ns2 are
          deleted. During this process, the deletion of actual
          namespace resources, including deletion of veth1{1} and veth2{2},
          is put into a workqueue to be processed asynchronously.
     (3). test_xdp_meta tries to create veth pair (veth1, veth2).
          The previous veth deletions in step (2) have not finished yet,
          and veth1 or veth2 may be still valid in the kernel, thus
          causing the failure.

The fix is to explicitly delete the veth pair before test_xdp_redirect
exits. Only one end of veth needs deletion as the kernel will delete
the other end automatically. Also test_xdp_meta is also fixed in
similar manner to avoid future potential issues.

Fixes: 59aee7f01a75 ("selftests: bpf: add a test for XDP redirect")
Fixes: d409ad5fdf62 ("bpf: improve selftests and add tests for meta pointer")
Signed-off-by: Yonghong Song <yhs@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
tools/testing/selftests/bpf/test_xdp_meta.sh
tools/testing/selftests/bpf/test_xdp_redirect.sh