Skip to content

Commit

Permalink
set_nonblock
Browse files Browse the repository at this point in the history
Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang committed Apr 4, 2024
1 parent d55c693 commit f1f32d7
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tools/testing/selftests/bpf/prog_tests/mptcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, F_SETFL, flags | O_NONBLOCK);
}

static int verify_tsk(int map_fd, int client_fd)
{
int err, cfd = client_fd;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit f1f32d7

Please sign in to comment.