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

Geliang Tang posted 13 patches 3 weeks, 1 day ago
[PATCH mptcp-next v9 05/13] Squash to "selftests/bpf: Add bpf scheduler test"
Posted by Geliang Tang 3 weeks, 1 day ago
From: Geliang Tang <tanggeliang@kylinos.cn>

A cleanup, move netns_new() 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 --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c
index 1d68bbda3370..b00af99c5c9d 100644
--- a/tools/testing/selftests/bpf/prog_tests/mptcp.c
+++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c
@@ -562,23 +562,16 @@ static void test_iters_subflow(void)
 	close(cgroup_fd);
 }
 
-static struct netns_obj *sched_init(char *flags, char *sched)
+static int sched_init(char *flags, char *sched)
 {
-	struct netns_obj *netns;
-
-	netns = netns_new(NS_TEST, true);
-	if (!ASSERT_OK_PTR(netns, "netns_new"))
-		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 netns;
+	return 0;
 fail:
-	netns_free(netns);
-	return NULL;
+	return -1;
 }
 
 static int ss_search(char *src, char *dst, char *port, char *keyword)
@@ -636,11 +629,16 @@ static void send_data_and_verify(char *sched, bool addr1, bool addr2)
 static void test_default(void)
 {
 	struct netns_obj *netns;
+	int err;
 
-	netns = sched_init("subflow", "default");
+	netns = netns_new(NS_TEST, true);
 	if (!netns)
 		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:
-- 
2.45.2