Message ID | ea2c5ea958ce94c36fe2d687aee98a2edefb8789.1715751995.git.tanggeliang@kylinos.cn |
---|---|
State | Superseded |
Headers | show |
Series | add netns helpers | expand |
diff --git a/tools/testing/selftests/bpf/prog_tests/assign_reuse.c b/tools/testing/selftests/bpf/prog_tests/assign_reuse.c index 21e1549d9749..6fa08c47357c 100644 --- a/tools/testing/selftests/bpf/prog_tests/assign_reuse.c +++ b/tools/testing/selftests/bpf/prog_tests/assign_reuse.c @@ -189,6 +189,5 @@ void test_assign_reuse(void) run_assign_reuse(AF_INET6, SOCK_DGRAM, "::1", PORT); cleanup: - close_netns(tok); - SYS_NOFAIL("ip netns delete %s", NS_TEST); + cleanup_netns(tok); } diff --git a/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c b/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c index b1a3a49a822a..ce6ceac8a812 100644 --- a/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c +++ b/tools/testing/selftests/bpf/prog_tests/crypto_sanity.c @@ -190,8 +190,7 @@ void test_crypto_sanity(void) ASSERT_OK(err, "bpf_tc_detach decrypt"); fail: - close_netns(nstoken); + cleanup_netns(nstoken); deinit_afalg(); - SYS_NOFAIL("ip netns del " NS_TEST " &> /dev/null"); crypto_sanity__destroy(skel); } diff --git a/tools/testing/selftests/bpf/prog_tests/decap_sanity.c b/tools/testing/selftests/bpf/prog_tests/decap_sanity.c index dcb9e5070cc3..9528b039ad33 100644 --- a/tools/testing/selftests/bpf/prog_tests/decap_sanity.c +++ b/tools/testing/selftests/bpf/prog_tests/decap_sanity.c @@ -68,10 +68,8 @@ void test_decap_sanity(void) ASSERT_FALSE(skel->bss->broken_csum_start, "broken_csum_start"); fail: - if (nstoken) { + if (nstoken) bpf_tc_hook_destroy(&qdisc_hook); - close_netns(nstoken); - } - SYS_NOFAIL("ip netns del " NS_TEST); + cleanup_netns(nstoken); decap_sanity__destroy(skel); } diff --git a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c index b7eac1fce746..9de05603098d 100644 --- a/tools/testing/selftests/bpf/prog_tests/fib_lookup.c +++ b/tools/testing/selftests/bpf/prog_tests/fib_lookup.c @@ -368,8 +368,6 @@ void test_fib_lookup(void) } fail: - if (nstoken) - close_netns(nstoken); - SYS_NOFAIL("ip netns del " NS_TEST); + cleanup_netns(nstoken); fib_lookup__destroy(skel); } diff --git a/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c b/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c index 6dae14d106ac..b4af39dbc449 100644 --- a/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c +++ b/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c @@ -211,9 +211,7 @@ static void test_in_netns(int (*fn)(void *), void *arg) test_ns_current_pid_tgid_new_ns(fn, arg); cleanup: - if (nstoken) - close_netns(nstoken); - SYS_NOFAIL("ip netns del ns_current_pid_tgid"); + cleanup_netns(nstoken); } /* TODO: use a different tracepoint */ diff --git a/tools/testing/selftests/bpf/prog_tests/sock_destroy.c b/tools/testing/selftests/bpf/prog_tests/sock_destroy.c index c156218c7280..1d3abc7a92c4 100644 --- a/tools/testing/selftests/bpf/prog_tests/sock_destroy.c +++ b/tools/testing/selftests/bpf/prog_tests/sock_destroy.c @@ -209,9 +209,7 @@ void test_sock_destroy(void) RUN_TESTS(sock_destroy_prog_fail); cleanup: - if (nstoken) - close_netns(nstoken); - SYS_NOFAIL("ip netns del " TEST_NS); + cleanup_netns(nstoken); if (cgroup_fd >= 0) close(cgroup_fd); sock_destroy_prog__destroy(skel); diff --git a/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c b/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c index 6a19bfdc0677..786cf316b3fd 100644 --- a/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c +++ b/tools/testing/selftests/bpf/prog_tests/sock_iter_batch.c @@ -126,8 +126,7 @@ void test_sock_iter_batch(void) do_test(SOCK_DGRAM, true); do_test(SOCK_DGRAM, false); } - close_netns(nstoken); done: - SYS_NOFAIL("ip netns del " TEST_NS); + cleanup_netns(nstoken); } diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c b/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c index 7dd18c6d06c6..315777a4c7ce 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_dev_bound_only.c @@ -53,9 +53,8 @@ void test_xdp_dev_bound_only_offdev(void) out: close(fd1); close(fd2); - close_netns(tok); /* eth42 was added inside netns, removing the netns will * also remove eth42 veth pair. */ - SYS_NOFAIL("ip netns del " LOCAL_NETNS); + cleanup_netns(tok); } diff --git a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c index 498d3bdaa4b0..7ae93bbdbf82 100644 --- a/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c +++ b/tools/testing/selftests/bpf/prog_tests/xdp_do_redirect.c @@ -241,8 +241,6 @@ void test_xdp_do_redirect(void) out_tc: bpf_tc_hook_destroy(&tc_hook); out: - if (nstoken) - close_netns(nstoken); - SYS_NOFAIL("ip netns del testns"); + cleanup_netns(nstoken); test_xdp_do_redirect__destroy(skel); }