diff --git a/tools/testing/selftests/bpf/prog_tests/mptcp.c b/tools/testing/selftests/bpf/prog_tests/mptcp.c index 3b8435a347d5..19e4b6bab5b1 100644 --- a/tools/testing/selftests/bpf/prog_tests/mptcp.c +++ b/tools/testing/selftests/bpf/prog_tests/mptcp.c @@ -101,6 +101,16 @@ static void cleanup_netns(struct nstoken *nstoken) SYS_NOFAIL("ip netns del %s", NS_TEST); } +static int set_nonblock(int fd) +{ + int flags = fcntl(fd, F_GETFL); + + if (flags == -1) + return -1; + + return fcntl(fd, flags | O_NONBLOCK); +} + static int verify_tsk(int map_fd, int client_fd) { int err, cfd = client_fd; @@ -332,6 +342,9 @@ static void run_mptcp_subflow(int cgroup_fd, struct mptcp_subflow *skel) if (!ASSERT_GE(client_fd, 0, "connect to fd")) goto close_server; + if (set_nonblock(server_fd)) + goto close_server; + send_recv_data(server_fd, client_fd, total_bytes, TIMEOUT_TEST); ASSERT_OK(ss_search(ADDR_1, "fwmark:0x1"), "ss_search fwmark:0x1"); @@ -418,6 +431,9 @@ static void send_data_and_verify(char *msg, int addr1, int addr2) if (!ASSERT_NEQ(client_fd, -1, "connect_to_fd")) goto close_server; + if (set_nonblock(server_fd)) + goto close_server; + if (clock_gettime(CLOCK_MONOTONIC, &start) < 0) goto close_server;