Skip to content

Commit 4dfd3e5

Browse files
matttbegregkh
authored andcommitted
selftests: mptcp: connect: trunc: read all recv data
commit ee79980f7a428ec299f6261bea4c1084dcbc9631 upstream. MPTCP Join "fastclose server" selftest is sometimes failing because the client output file doesn't have the expected size, e.g. 296B instead of 1024B. When looking at a packet trace when this happens, the server sent the expected 1024B in two parts -- 100B, then 924B -- then the MP_FASTCLOSE. It is then strange to see the client only receiving 296B, which would mean it only got a part of the second packet. The problem is then not on the networking side, but rather on the data reception side. When mptcp_connect is launched with '-f -1', it means the connection might stop before having sent everything, because a reset has been received. When this happens, the program was directly stopped. But it is also possible there are still some data to read, simply because the previous 'read' step was done with a buffer smaller than the pending data, see do_rnd_read(). In this case, it is important to read what's left in the kernel buffers before stopping without error like before. SIGPIPE is now ignored, not to quit the app before having read everything. Fixes: 6bf4102 ("selftests: mptcp: update and extend fastclose test-cases") Cc: [email protected] Reviewed-by: Geliang Tang <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Link: https://patch.msgid.link/20251110-net-mptcp-sft-join-unstable-v1-5-a4332c714e10@kernel.org Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 7558cf8 commit 4dfd3e5

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

tools/testing/selftests/net/mptcp/mptcp_connect.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,14 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd,
710710

711711
bw = do_rnd_write(peerfd, winfo->buf + winfo->off, winfo->len);
712712
if (bw < 0) {
713-
if (cfg_rcv_trunc)
714-
return 0;
713+
/* expected reset, continue to read */
714+
if (cfg_rcv_trunc &&
715+
(errno == ECONNRESET ||
716+
errno == EPIPE)) {
717+
fds.events &= ~POLLOUT;
718+
continue;
719+
}
720+
715721
perror("write");
716722
return 111;
717723
}
@@ -737,8 +743,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd,
737743
}
738744

739745
if (fds.revents & (POLLERR | POLLNVAL)) {
740-
if (cfg_rcv_trunc)
741-
return 0;
746+
if (cfg_rcv_trunc) {
747+
fds.events &= ~(POLLERR | POLLNVAL);
748+
continue;
749+
}
742750
fprintf(stderr, "Unexpected revents: "
743751
"POLLERR/POLLNVAL(%x)\n", fds.revents);
744752
return 5;
@@ -1433,7 +1441,7 @@ static void parse_opts(int argc, char **argv)
14331441
*/
14341442
if (cfg_truncate < 0) {
14351443
cfg_rcv_trunc = true;
1436-
signal(SIGPIPE, handle_signal);
1444+
signal(SIGPIPE, SIG_IGN);
14371445
}
14381446
break;
14391447
case 'j':

0 commit comments

Comments
 (0)