diff mbox series

[mptcp-next,v8,05/13] Squash to "selftests/bpf: Add bpf scheduler test"

Message ID 0eab9060d945d4b3150fabb7bf61e2748192703f.1729676320.git.tanggeliang@kylinos.cn (mailing list archive)
State Superseded, archived
Headers show
Series use bpf_iter in bpf schedulers | expand

Checks

Context Check Description
matttbe/KVM_Validation__normal warning Unstable: 1 failed test(s): selftest_mptcp_join
matttbe/KVM_Validation__debug warning Unstable: 2 failed test(s): packetdrill_regressions selftest_mptcp_join
matttbe/KVM_Validation__btf-normal__only_bpftest_all_ success Success! ✅
matttbe/KVM_Validation__btf-debug__only_bpftest_all_ success Success! ✅
matttbe/checkpatch success total: 0 errors, 0 warnings, 0 checks, 44 lines checked
matttbe/shellcheck success MPTCP selftests files have not been modified
matttbe/build success Build and static analysis OK

Commit Message

Geliang Tang Oct. 23, 2024, 9:40 a.m. UTC
From: Geliang Tang <tanggeliang@kylinos.cn>

A cleanup, move create_netns() out of sched_init().

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
 .../testing/selftests/bpf/prog_tests/mptcp.c  | 22 +++++++++----------
 1 file changed, 10 insertions(+), 12 deletions(-)
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index be746e0fc393..9758ee83c81f 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -580,23 +580,16 @@  static void test_iters_subflow(void)
 	close(cgroup_fd);
 }
 
-static struct nstoken *sched_init(char *flags, char *sched)
+static int sched_init(char *flags, char *sched)
 {
-	struct nstoken *nstoken;
-
-	nstoken = create_netns();
-	if (!ASSERT_OK_PTR(nstoken, "create_netns"))
-		return NULL;
-
-	if (endpoint_init("subflow", 2) < 0)
+	if (endpoint_init(flags, 2) < 0)
 		goto fail;
 
 	SYS(fail, "ip netns exec %s sysctl -qw net.mptcp.scheduler=%s", NS_TEST, sched);
 
-	return nstoken;
+	return 0;
 fail:
-	cleanup_netns(nstoken);
-	return NULL;
+	return -1;
 }
 
 static int ss_search(char *src, char *dst, char *port, char *keyword)
@@ -654,11 +647,16 @@  static void send_data_and_verify(char *sched, bool addr1, bool addr2)
 static void test_default(void)
 {
 	struct nstoken *nstoken;
+	int err;
 
-	nstoken = sched_init("subflow", "default");
+	nstoken = create_netns();
 	if (!nstoken)
 		goto fail;
 
+	err = sched_init("subflow", "default");
+	if (!ASSERT_OK(err, "sched_init"))
+		goto fail;
+
 	send_data_and_verify("default", WITH_DATA, WITH_DATA);
 
 fail: