diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 83efcdd7739d45..62d4d4a09ebf40 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -417,7 +417,7 @@ void test_subflow(void) } static const unsigned int total_bytes = 10 * 1024 * 1024; -static int stop, duration; +static int stop; static void *server(void *arg) { @@ -476,11 +476,12 @@ static void send_data(int lfd, int fd, char *msg) int err; WRITE_ONCE(stop, 0); + if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) return; err = pthread_create(&srv_thread, NULL, server, (void *)(long)lfd); - if (CHECK(err != 0, "pthread_create", "err:%d errno:%d\n", err, errno)) + if (!ASSERT_OK(err, "pthread_create")) return; /* recv total_bytes */ @@ -513,10 +514,6 @@ static void send_data(int lfd, int fd, char *msg) printf("FAIL:pthread_join thread_ret:%ld\n", PTR_ERR(thread_ret)); } -#define ADDR_1 "10.0.1.1" -#define ADDR_2 "10.0.1.2" -#define PORT_1 10001 - static struct nstoken *sched_init(char *flags, char *sched) { struct nstoken *nstoken; @@ -525,12 +522,9 @@ static struct nstoken *sched_init(char *flags, char *sched) if (!ASSERT_OK_PTR(nstoken, "create_netns")) goto fail; - SYS(fail, "ip -net %s link add veth1 type veth peer name veth2", NS_TEST); - SYS(fail, "ip -net %s addr add %s/24 dev veth1", NS_TEST, ADDR_1); - SYS(fail, "ip -net %s link set dev veth1 up", NS_TEST); - SYS(fail, "ip -net %s addr add %s/24 dev veth2", NS_TEST, ADDR_2); - SYS(fail, "ip -net %s link set dev veth2 up", NS_TEST); - SYS(fail, "ip -net %s mptcp endpoint add %s %s", NS_TEST, ADDR_2, flags); + if (!ASSERT_OK(endpoint_init("subflow"), "endpoint_init")) + goto fail; + SYS(fail, "ip netns exec %s sysctl -qw net.mptcp.scheduler=%s", NS_TEST, sched); return nstoken; @@ -538,12 +532,13 @@ static struct nstoken *sched_init(char *flags, char *sched) return NULL; } -static int has_bytes_sent(char *addr) +static int has_bytes_sent(char *dst) { char cmd[128]; - snprintf(cmd, sizeof(cmd), "ip netns exec %s ss -it src %s sport %d dst %s | %s", - NS_TEST, ADDR_1, PORT_1, addr, "grep -q bytes_sent:"); + snprintf(cmd, sizeof(cmd), + "ip netns exec %s ss -it src %s sport %d dst %s | %s", + NS_TEST, ADDR_1, PORT_1, dst, "grep -q bytes_sent:"); return system(cmd); }