]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests: mptcp: connect: catch IO errors on listen side
authorMatthieu Baerts (NGI0) <matttbe@kernel.org>
Fri, 12 Sep 2025 12:25:51 +0000 (14:25 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Sep 2025 09:13:47 +0000 (11:13 +0200)
commit 14e22b43df25dbd4301351b882486ea38892ae4f upstream.

IO errors were correctly printed to stderr, and propagated up to the
main loop for the server side, but the returned value was ignored. As a
consequence, the program for the listener side was no longer exiting
with an error code in case of IO issues.

Because of that, some issues might not have been seen. But very likely,
most issues either had an effect on the client side, or the file
transfer was not the expected one, e.g. the connection got reset before
the end. Still, it is better to fix this.

The main consequence of this issue is the error that was reported by the
selftests: the received and sent files were different, and the MIB
counters were not printed. Also, when such errors happened during the
'disconnect' tests, the program tried to continue until the timeout.

Now when an IO error is detected, the program exits directly with an
error.

Fixes: 05be5e273c84 ("selftests: mptcp: add disconnect tests")
Cc: stable@vger.kernel.org
Reviewed-by: Mat Martineau <martineau@kernel.org>
Reviewed-by: Geliang Tang <geliang@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20250912-net-mptcp-fix-sft-connect-v1-2-d40e77cbbf02@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools/testing/selftests/net/mptcp/mptcp_connect.c

index c83a8b47bbdfa5fcf1462e2b2949b41fd32c9b14..6b348d696fede7d2a7f80cd7d4df181bbdd9ddf5 100644 (file)
@@ -1079,6 +1079,7 @@ int main_loop_s(int listensock)
        struct pollfd polls;
        socklen_t salen;
        int remotesock;
+       int err = 0;
        int fd = 0;
 
 again:
@@ -1111,7 +1112,7 @@ again:
                SOCK_TEST_TCPULP(remotesock, 0);
 
                memset(&winfo, 0, sizeof(winfo));
-               copyfd_io(fd, remotesock, 1, true, &winfo);
+               err = copyfd_io(fd, remotesock, 1, true, &winfo);
        } else {
                perror("accept");
                return 1;
@@ -1120,10 +1121,10 @@ again:
        if (cfg_input)
                close(fd);
 
-       if (--cfg_repeat > 0)
+       if (!err && --cfg_repeat > 0)
                goto again;
 
-       return 0;
+       return err;
 }
 
 static void init_rng(void)