Skip to content

Commit

Permalink
selftests: mptcp: enable io thread mode
Browse files Browse the repository at this point in the history
This patch adds a new parameter "listensock" for the client main_loop()
to support io thread mode tests. In it, invoke accept() to get the peer
socket and pass it to copyfd_io(), then to copyfd_io_thread().

Signed-off-by: Geliang Tang <[email protected]>
  • Loading branch information
Geliang Tang authored and intel-lab-lkp committed Aug 2, 2024
1 parent ab058b7 commit 5b7e72b
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions tools/testing/selftests/net/mptcp/mptcp_connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,9 @@ void xdisconnect(int fd, int addrlen)
xerror("can't disconnect: %d", errno);
}

int main_loop(void)
int main_loop(int listensock)
{
int fd = 0, ret, fd_in = 0;
int fd = 0, ret, fd_in = 0, peerfd = 1;
struct addrinfo *peer;
struct wstate winfo;

Expand All @@ -1389,6 +1389,19 @@ int main_loop(void)
if (fd < 0)
return 2;

if (cfg_mode == CFG_MODE_THREAD &&
listensock >= 0) {
peerfd = accept(listensock, NULL, NULL);
while (peerfd == -1) {
if (errno == EINTR)
continue;
return -errno;
}

if (cfg_timeo)
settimeo(peerfd, cfg_timeo);
}

again:
check_getpeername_connect(fd);

Expand All @@ -1407,7 +1420,7 @@ int main_loop(void)
xerror("can't open %s:%d", cfg_input, errno);
}

ret = copyfd_io(fd_in, fd, 1, 0, &winfo);
ret = copyfd_io(fd_in, fd, peerfd, 0, &winfo);
if (ret)
return ret;

Expand All @@ -1430,6 +1443,8 @@ int main_loop(void)
close(fd);
}

if (listensock >= 0)
close(listensock);
return 0;
}

Expand Down Expand Up @@ -1630,9 +1645,11 @@ int main(int argc, char *argv[])
set_mark(fd, cfg_mark);
if (cfg_cmsg_types.cmsg_enabled)
apply_cmsg_types(fd, &cfg_cmsg_types);
if (cfg_mode == CFG_MODE_THREAD)
return main_loop(fd);

return main_loop_s(fd);
}

return main_loop();
return main_loop(-1);
}

0 comments on commit 5b7e72b

Please sign in to comment.