From: Quanye Yang <quan…@proton.me>
connect_one_server() sets eof when read() returns 0, then immediately
checks total != len. The receive loop only observes EOF while total is
still below len, so that check always fires and xerror() terminates the
process. The later if (eof) block that increments total for DATA_FIN is
therefore unreachable.
The client also does not wait for the peer to close: process_one_client()
blocks on hangup first, so a peer DATA_FIN cannot arrive before this
assertion. DATA_FIN sequence advancement is already checked on the server
after EOF. Treat an early EOF as a hard error and drop the dead
adjustment.
This issue has been reported by Sashiko and not seen in CI environments.
Yet, it could be visible, especially when the test is launched manually.
Fixes: ce9979129a0b ("selftests: mptcp: add mptcp getsockopt test cases")
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/637
Signed-off-by: Quanye Yang <quan…@proton.me>
Reviewed-by: Matthieu Baerts (NGI0) <matt…@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matt…@kernel.org>
---
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
index 7b4ccbe10ae1..10bef56acc6c 100644
--- a/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
+++ b/tools/testing/selftests/net/mptcp/mptcp_sockopt.c
@@ -572,7 +572,6 @@ static void connect_one_server(int fd, int pipefd)
char buf[4096], buf2[4096];
size_t len, i, total;
struct so_state s;
- bool eof = false;
ssize_t ret;
memset(&s, 0, sizeof(s));
@@ -610,16 +609,15 @@ static void connect_one_server(int fd, int pipefd)
ret = read(fd, buf2 + total, sizeof(buf2) - total);
if (ret < 0)
die_perror("read");
- if (ret == 0) {
- eof = true;
- break;
- }
+ if (ret == 0)
+ xerror("unexpected EOF, total %lu, len %lu\n",
+ total, len);
total += ret;
} while (total < len);
if (total != len)
- xerror("total %lu, len %lu eof %d\n", total, len, eof);
+ xerror("total %lu, len %lu\n", total, len);
if (memcmp(buf, buf2, len))
xerror("data corruption");
@@ -629,9 +627,6 @@ static void connect_one_server(int fd, int pipefd)
do_getsockopts(&s, fd, total, total);
- if (eof)
- total += 1; /* sequence advances due to FIN */
-
assert(s.mptcpi_rcv_delta == (uint64_t)total);
close(fd);
}
--
2.55.0