Skip to content

Commit 45d94be

Browse files
matttbejfvogel
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: stable@vger.kernel.org Reviewed-by: Geliang Tang <geliang@kernel.org> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org> Link: https://patch.msgid.link/20251110-net-mptcp-sft-join-unstable-v1-5-a4332c714e10@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> (cherry picked from commit da4f2e33d32055db71ad24075a4b39a0246cb586) Signed-off-by: Jack Vogel <jack.vogel@oracle.com>
1 parent 54d3aac commit 45d94be

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

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

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

697697
bw = do_rnd_write(peerfd, winfo->buf + winfo->off, winfo->len);
698698
if (bw < 0) {
699-
if (cfg_rcv_trunc)
700-
return 0;
699+
/* expected reset, continue to read */
700+
if (cfg_rcv_trunc &&
701+
(errno == ECONNRESET ||
702+
errno == EPIPE)) {
703+
fds.events &= ~POLLOUT;
704+
continue;
705+
}
706+
701707
perror("write");
702708
return 111;
703709
}
@@ -723,8 +729,10 @@ static int copyfd_io_poll(int infd, int peerfd, int outfd,
723729
}
724730

725731
if (fds.revents & (POLLERR | POLLNVAL)) {
726-
if (cfg_rcv_trunc)
727-
return 0;
732+
if (cfg_rcv_trunc) {
733+
fds.events &= ~(POLLERR | POLLNVAL);
734+
continue;
735+
}
728736
fprintf(stderr, "Unexpected revents: "
729737
"POLLERR/POLLNVAL(%x)\n", fds.revents);
730738
return 5;
@@ -1419,7 +1427,7 @@ static void parse_opts(int argc, char **argv)
14191427
*/
14201428
if (cfg_truncate < 0) {
14211429
cfg_rcv_trunc = true;
1422-
signal(SIGPIPE, handle_signal);
1430+
signal(SIGPIPE, SIG_IGN);
14231431
}
14241432
break;
14251433
case 'j':

0 commit comments

Comments
 (0)