[PATCH mptcp-net] selftests: mptcp: sockopt: drop unreachable FIN accounting

Quanye Yang via B4 Relay posted 1 patch 1 month, 1 week ago
Failed in applying to current master (apply log)
tools/testing/selftests/net/mptcp/mptcp_sockopt.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
[PATCH mptcp-net] selftests: mptcp: sockopt: drop unreachable FIN accounting
Posted by Quanye Yang via B4 Relay 1 month, 1 week ago
From: Quanye Yang <quanyeyang@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.

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 <quanyeyang@proton.me>
---
 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 b6e58d936ebe..20e0050e7cd7 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, ret, ret);
 
-	if (eof)
-		total += 1; /* sequence advances due to FIN */
-
 	assert(s.mptcpi_rcv_delta == (uint64_t)total);
 	close(fd);
 }

---
base-commit: a22035be824449c4921ec406f6383089016a628c
change-id: 20261017-fix-mptcp-issue-637-0b14714ab58b

Best regards,
--  
Quanye Yang <quanyeyang@proton.me>
Re: [PATCH mptcp-net] selftests: mptcp: sockopt: drop unreachable FIN accounting
Posted by Matthieu Baerts 1 month ago
Hi Quanye,

On 17/10/2026 10:53, Quanye Yang via B4 Relay wrote:
> From: Quanye Yang <quanyeyang@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.

Thank you for the patch!

Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>

I also just applied it in our tree, but for -next, and added this paragraph:

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.

New patches for t/upstream:
- 5531a8151ac8: selftests: mptcp: sockopt: drop unreachable FIN accounting
- Results: 15904a7a5590..c2dd59af75f8 (export)

Tests are now in progress:

- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/08e13d22410569c3de4f17c5568d2b19d29eb4be/checks

Cheers,
Matt
-- 
Sponsored by the NGI0 Core fund.
Re: [PATCH mptcp-net] selftests: mptcp: sockopt: drop unreachable FIN accounting
Posted by MPTCP CI 1 month ago
Hi Quanye,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal (except selftest_mptcp_join): Success! ✅
- KVM Validation: normal (only selftest_mptcp_join): Success! ✅
- KVM Validation: debug (except selftest_mptcp_join): Success! ✅
- KVM Validation: debug (only selftest_mptcp_join): Success! ✅
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Perf: Critical: No conclusion ❓
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/39578788494

Initiator: Patchew Applier
Commits: https://github.com/multipath-tcp/mptcp_net-next/commits/c0bc9ebb4dd0
Patchwork: https://patchwork.kernel.org/project/mptcp/list/?series=1187878


If there are some issues, you can reproduce them using the same environment as
the one used by the CI thanks to a docker image, e.g.:

    $ cd [kernel source code]
    $ docker run -v "${PWD}:${PWD}:rw" -w "${PWD}" --privileged --rm -it \
        --pull always mptcp/mptcp-upstream-virtme-docker:latest \
        auto-normal

For more details:

    https://github.com/multipath-tcp/mptcp-upstream-virtme-docker


Please note that despite all the efforts that have been already done to have a
stable tests suite when executed on a public CI like here, it is possible some
reported issues are not due to your modifications. Still, do not hesitate to
help us improve that ;-)

Cheers,
MPTCP GH Action bot
Bot operated by Matthieu Baerts (NGI0 Core)