tools/bpf: fix batch-mode test failure of test_xdp_redirect.sh

"Linux Kernel Mailing List" <[email protected]>
Newsgroups gmane.linux.kernel.commits.head
Message-ID <[email protected]>
Web:        https://git.kernel.org/torvalds/c/7b4eb53d95c30bdc55c44647c6968f24227fd1ba
Commit:     7b4eb53d95c30bdc55c44647c6968f24227fd1ba
Parent:     09584b406742413ac4c8d7e030374d4daa045b69
Refname:    refs/heads/master
Author:     Yonghong Song <[email protected]>
AuthorDate: Mon Feb 5 16:25:24 2018 -0800
Committer:  Daniel Borkmann <[email protected]>
CommitDate: Tue Feb 6 11:34:42 2018 +0100

    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: 996139e801fd ("selftests: bpf: add a test for XDP redirect")
    Fixes: 22c8852624fc ("bpf: improve selftests and add tests for meta pointer")
    Signed-off-by: Yonghong Song <[email protected]>
    Signed-off-by: Daniel Borkmann <[email protected]>
---
 tools/testing/selftests/bpf/test_xdp_meta.sh     | 1 +
 tools/testing/selftests/bpf/test_xdp_redirect.sh | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/tools/testing/selftests/bpf/test_xdp_meta.sh b/tools/testing/selftests/bpf/test_xdp_meta.sh
index 307aa856cee3..637fcf4fe4e3 100755
--- a/tools/testing/selftests/bpf/test_xdp_meta.sh
+++ b/tools/testing/selftests/bpf/test_xdp_meta.sh
@@ -9,6 +9,7 @@ cleanup()
 	fi
 
 	set +e
+	ip link del veth1 2> /dev/null
 	ip netns del ns1 2> /dev/null
 	ip netns del ns2 2> /dev/null
 }
diff --git a/tools/testing/selftests/bpf/test_xdp_redirect.sh b/tools/testing/selftests/bpf/test_xdp_redirect.sh
index 344a3656dea6..c4b17e08d431 100755
--- a/tools/testing/selftests/bpf/test_xdp_redirect.sh
+++ b/tools/testing/selftests/bpf/test_xdp_redirect.sh
@@ -19,6 +19,8 @@ cleanup()
 	fi
 
 	set +e
+	ip link del veth1 2> /dev/null
+	ip link del veth2 2> /dev/null
 	ip netns del ns1 2> /dev/null
 	ip netns del ns2 2> /dev/null
 }
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.