Skip to contentSkip to conversation

selftests: mptcp: avoid spurious errors on TCP disconnect

PATCH In review Matthieu Baerts (NGI0) 5 participants 14 messages Sep 10, 2025 – Sep 12, 2025

Subsystems (3)
lore
Share & tools
lore

Matthieu Baerts (NGI0)

author maintainer
#0 lore raw

v3 cover selftests: mptcp: avoid spurious errors on TCP disconnect

This should fix the recent instabilities seen by MPTCP and NIPA CIs where the 'mptcp_connect.sh' tests fail regularly when running the 'disconnect' subtests with "plain" TCP sockets, e.g.

# INFO: disconnect

  # 63 ns1 MPTCP -> ns1 (10.0.1.1:20001      ) MPTCP     (duration   996ms) [ OK ]
  # 64 ns1 MPTCP -> ns1 (10.0.1.1:20002      ) TCP       (duration   851ms) [ OK ]
  # 65 ns1 TCP   -> ns1 (10.0.1.1:20003      ) MPTCP     Unexpected revents: POLLERR/POLLNVAL(19)
  # (duration   896ms) [FAIL] file received by server does not match (in, out):
  # -rw-r--r-- 1 root root 11112852 Aug 19 09:16 /tmp/tmp.hlJe5DoMoq.disconnect
  # Trailing bytes are:
  # /{ga 6@=#.8:-rw------- 1 root root 10085368 Aug 19 09:16 /tmp/tmp.blClunilxx
  # Trailing bytes are:
  # /{ga 6@=#.8:66 ns1 MPTCP -> ns1 (dead:beef:1::1:20004) MPTCP     (duration   987ms) [ OK ]
  # 67 ns1 MPTCP -> ns1 (dead:beef:1::1:20005) TCP       (duration   911ms) [ OK ]
  # 68 ns1 TCP   -> ns1 (dead:beef:1::1:20006) MPTCP     (duration   980ms) [ OK ]

# [FAIL] Tests of the full disconnection have failed

Patch 3 fixes this issue, but a fix in MPTCP in patch 1 is also needed to fix MPTCP behaviour, and simplify patch 3. Patches 2 and 4 improve some errors reported by the selftests, and patch 5 helps with the debugging. I guess all these patches can be sent to 'net'

Note: Patch 1 will cause errors in Packetdrill, that's normal, see [1].

---
Changes in v3:
- Patch 2: close some FDs in case of errors (Geliang)
- Patch 4: mention there are now more bytes (Geliang)
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- Patch 1: new
- Patch 3: no more state filtering needed thanks to patch 1
- Patch 4: switch from hexdump to od (Mat)
- Patch 5: new
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Matthieu Baerts (NGI0) (5):
mptcp: propagate shutdown to subflows when possible
selftests: mptcp: connect: catch IO errors on listen side
selftests: mptcp: avoid spurious errors on TCP disconnect
selftests: mptcp: print trailing bytes with od
selftests: mptcp: connect: print pcap suffix

 net/mptcp/protocol.c                               | 16 ++++++++++++++++
 tools/testing/selftests/net/mptcp/mptcp_connect.c  | 11 ++++++-----
 tools/testing/selftests/net/mptcp/mptcp_connect.sh |  6 +++++-
 tools/testing/selftests/net/mptcp/mptcp_lib.sh     |  2 +-
 4 files changed, 28 insertions(+), 7 deletions(-)

---
base-commit: 1e51af26b216c689f6d75872290bb0de1eeaae34
change-id: 20250806-sft-mptcp-disc-err-3357b769bcdb

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/5 mptcp: propagate shutdown to subflows when possible

When the MPTCP DATA FIN have been ACKed, there is no more MPTCP related metadata to exchange, and all subflows can be safely shutdown.

Before this patch, the subflows were actually terminated at 'close()' time. That's certainly fine most of the time, but not when the userspace 'shutdown()' a connection, without close()ing it. When doing so, the subflows were staying in LAST_ACK state on one side -- and consequently in FIN_WAIT2 on the other side -- until the 'close()' of the MPTCP socket.

Now, when the DATA FIN have been ACKed, all subflows are shutdown. A consequence of this is that the TCP 'FIN' flag can be set earlier now, but the end result is the same. This affects the packetdrill tests looking at the end of the MPTCP connections, but for a good reason.

Fixes 3721b9b64676 ("mptcp: Track received DATA_FIN sequence number and add related helpers")
Fixes 16a9a9da1723 ("mptcp: Add helper to process acks of DATA_FIN")
---
 net/mptcp/protocol.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
net/mptcp/protocol.c +16 -0
index 1c26acf6c4145896ecbb5c7f7004121c66a20649..9feb9f437c2bdfff392249e7ad00edd09ba67ac3 100644
@@ -372,6 +372,20 @@ static void mptcp_close_wake_up(struct sock *sk)
 		sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
 }
 
+static void mptcp_shutdown_subflows(struct mptcp_sock *msk)
+{
+	struct mptcp_subflow_context *subflow;
+
+	mptcp_for_each_subflow(msk, subflow) {
+		struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
+		bool slow;
+
+		slow = lock_sock_fast(ssk);
+		tcp_shutdown(ssk, SEND_SHUTDOWN);
+		unlock_sock_fast(ssk, slow);
+	}
+}
+
 /* called under the msk socket lock */
 static bool mptcp_pending_data_fin_ack(struct sock *sk)
 {
@@ -396,6 +410,7 @@ static void mptcp_check_data_fin_ack(struct sock *sk)
 			break;
 		case TCP_CLOSING:
 		case TCP_LAST_ACK:
+			mptcp_shutdown_subflows(msk);
 			mptcp_set_state(sk, TCP_CLOSE);
 			break;
 		}
@@ -564,6 +579,7 @@ static bool mptcp_check_data_fin(struct sock *sk)
 			mptcp_set_state(sk, TCP_CLOSING);
 			break;
 		case TCP_FIN_WAIT2:
+			mptcp_shutdown_subflows(msk);
 			mptcp_set_state(sk, TCP_CLOSE);
 			break;
 		default:
Signature · 1 line
2.51.0
author maintainer
#2 lore raw

Re: [PATCH mptcp-net v3 1/5] mptcp: propagate shutdown to subflows when possible

Hello,

Quoted 10 lines · On 10/09/2025 10:55, Matthieu Baerts (NGI0) wrote:

When the MPTCP DATA FIN have been ACKed, there is no more MPTCP related metadata to exchange, and all subflows can be safely shutdown.

Before this patch, the subflows were actually terminated at 'close()' time. That's certainly fine most of the time, but not when the userspace 'shutdown()' a connection, without close()ing it. When doing so, the subflows were staying in LAST_ACK state on one side -- and consequently in FIN_WAIT2 on the other side -- until the 'close()' of the MPTCP socket.

Quoted 4 lines

Now, when the DATA FIN have been ACKed, all subflows are shutdown. A consequence of this is that the TCP 'FIN' flag can be set earlier now, but the end result is the same. This affects the packetdrill tests looking at the end of the MPTCP connections, but for a good reason.

FYI, I don't know if it is linked to this patch, but the CI recently complained about the "dss_fin_retrans_*" tests, in debug mode only:

Quoted 11 lines

# dss_fin_retrans_close_wait.pkt:27: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.017265 sec

# script packet:  0.791882 . 1:1(0) ack 2 <dss dack4 3007449510 dsn8 8067261375896427910 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>
# actual packet:  0.574617 . 1:1(0) ack 2 win 1050 <dss dack4 3007449510 dsn8 8067261375896427910 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>

# dss_fin_retrans_established.pkt:21: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.021432 sec

# script packet:  0.791877 . 1:1(0) ack 1 <dss dack4 3007449509 dsn8 8629039693965256448 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>
# actual packet:  0.570445 . 1:1(0) ack 1 win 1050 <dss dack4 3007449509 dsn8 8629039693965256448 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>

# dss_fin_retrans_close_wait.pkt:27: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.095031 sec

# script packet:  0.745018 . 1:1(0) ack 2 <dss dack4 3007449510 dsn8 18052974533214962003 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>
# actual packet:  0.449987 . 1:1(0) ack 2 win 1050 <dss dack4 3007449510 dsn8 18052974533214962003 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>

I'm not able to reproduce this issue on my side to get more details about the previous delays. Please also note that a few weeks ago, I also reduced the tolerance by a factor of 4.

Because it is happening only in "debug" mode, I just re-increased a bit the tolerance on the CI side. But if you have an idea of what could cause the kernel to emit the retransmission faster than expected, feel free to share :)

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/17638263507
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/17638077933

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
#3 lore raw

Re: [PATCH mptcp-net v3 1/5] mptcp: propagate shutdown to subflows when possible

Quoted 14 lines · Matthieu Baerts

Hello,

Quoted 10 lines · On 10/09/2025 10:55, Matthieu Baerts (NGI0) wrote:

When the MPTCP DATA FIN have been ACKed, there is no more MPTCP related metadata to exchange, and all subflows can be safely shutdown.

Before this patch, the subflows were actually terminated at 'close()' time. That's certainly fine most of the time, but not when the userspace 'shutdown()' a connection, without close()ing it. When doing so, the subflows were staying in LAST_ACK state on one side -- and consequently in FIN_WAIT2 on the other side -- until the 'close()' of the MPTCP socket.

Quoted 9 lines
Quoted 4 lines

Now, when the DATA FIN have been ACKed, all subflows are shutdown. A consequence of this is that the TCP 'FIN' flag can be set earlier now, but the end result is the same. This affects the packetdrill tests looking at the end of the MPTCP connections, but for a good reason.

FYI, I don't know if it is linked to this patch, but the CI recently complained about the "dss_fin_retrans_*" tests, in debug mode only:

Quoted 1 line

# dss_fin_retrans_close_wait.pkt:27: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.017265 sec

What is more suspicious is that the time is negative. Do you capture pcaps when running packetdrill ?
That would allow to see the "real" timestamps independent from packetdrill's scheduling issues.

Christoph

Quoted 29 lines
Quoted 10 lines
# script packet:  0.791882 . 1:1(0) ack 2 <dss dack4 3007449510 dsn8 8067261375896427910 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>
# actual packet:  0.574617 . 1:1(0) ack 2 win 1050 <dss dack4 3007449510 dsn8 8067261375896427910 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>

# dss_fin_retrans_established.pkt:21: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.021432 sec

# script packet:  0.791877 . 1:1(0) ack 1 <dss dack4 3007449509 dsn8 8629039693965256448 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>
# actual packet:  0.570445 . 1:1(0) ack 1 win 1050 <dss dack4 3007449509 dsn8 8629039693965256448 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>

# dss_fin_retrans_close_wait.pkt:27: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.095031 sec

# script packet:  0.745018 . 1:1(0) ack 2 <dss dack4 3007449510 dsn8 18052974533214962003 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>
# actual packet:  0.449987 . 1:1(0) ack 2 win 1050 <dss dack4 3007449510 dsn8 18052974533214962003 ssn 0 dll 1 no_checksum flags: MmAF,nop,nop>

I'm not able to reproduce this issue on my side to get more details about the previous delays. Please also note that a few weeks ago, I also reduced the tolerance by a factor of 4.

Because it is happening only in "debug" mode, I just re-increased a bit the tolerance on the CI side. But if you have an idea of what could cause the kernel to emit the retransmission faster than expected, feel free to share :)

https://github.com/multipath-tcp/mptcp_net-next/actions/runs/17638263507
https://github.com/multipath-tcp/mptcp_net-next/actions/runs/17638077933

Cheers,
Matt
--
Sponsored by the NGI0 Core fund.

author maintainer
#4 lore raw

Re: [PATCH mptcp-net v3 1/5] mptcp: propagate shutdown to subflows when possible

Hi Christoph,

Quoted 23 lines · Christoph Paasch
Quoted 22 lines · Matthieu Baerts

Hello,

Quoted 10 lines · On 10/09/2025 10:55, Matthieu Baerts (NGI0) wrote:

When the MPTCP DATA FIN have been ACKed, there is no more MPTCP related metadata to exchange, and all subflows can be safely shutdown.

Before this patch, the subflows were actually terminated at 'close()' time. That's certainly fine most of the time, but not when the userspace 'shutdown()' a connection, without close()ing it. When doing so, the subflows were staying in LAST_ACK state on one side -- and consequently in FIN_WAIT2 on the other side -- until the 'close()' of the MPTCP socket.

Quoted 4 lines

Now, when the DATA FIN have been ACKed, all subflows are shutdown. A consequence of this is that the TCP 'FIN' flag can be set earlier now, but the end result is the same. This affects the packetdrill tests looking at the end of the MPTCP connections, but for a good reason.

FYI, I don't know if it is linked to this patch, but the CI recently complained about the "dss_fin_retrans_*" tests, in debug mode only:

Quoted 6 lines
Quoted 1 line
Quoted 1 line

# dss_fin_retrans_close_wait.pkt:27: error handling packet: timing error: expected outbound packet in relative time range +0.200000~+0.300000 sec but happened at -0.017265 sec

What is more suspicious is that the time is negative. Do you capture pcaps when running packetdrill ?
That would allow to see the "real" timestamps independent from packetdrill's scheduling issues.

No we don't. I also don't know the effect it would have on the public CI in debug mode.

Locally, I tried to reproduce the issue with '-vvv', but I didn't manage to hit the bug after ~4h, even with stress-ng in parallel. I just tried without packetdrill's debug output, but with the packet capture, and no luck there too.

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.
author maintainer
#5 lore raw

PATCH v3 2/5 selftests: mptcp: connect: catch IO errors on listen side

In reply to Matthieu Baerts (NGI0)

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")

---
v3: close some FDs in case of errors (Geliang).

---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +4 -3
index 4f07ac9fa207cb08a934582b98d688d0b9512f97..1408698df0999730d9a9a4ad6a6362a4ab122d54 100644
@@ -1093,6 +1093,7 @@ int main_loop_s(int listensock)
 	struct pollfd polls;
 	socklen_t salen;
 	int remotesock;
+	int err = 0;
 	int fd = 0;
 
 again:
@@ -1125,7 +1126,7 @@ int main_loop_s(int listensock)
 		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;
@@ -1134,10 +1135,10 @@ int main_loop_s(int listensock)
 	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)
Signature · 1 line
2.51.0
author maintainer
#6 lore raw

PATCH v3 3/5 selftests: mptcp: avoid spurious errors on TCP disconnect

In reply to Matthieu Baerts (NGI0)

The disconnect test-case, with 'plain' TCP sockets generates spurious errors, e.g.

07 ns1 TCP -> ns1 (dead:beef:1::1:10006) MPTCP
read: Connection reset by peer
read: Connection reset by peer
(duration 155ms) [FAIL] client exit code 3, server 3

netns ns1-FloSdv (listener) socket stat for 10006:

  TcpActiveOpens                  2                  0.0
  TcpPassiveOpens                 2                  0.0
  TcpEstabResets                  2                  0.0
  TcpInSegs                       274                0.0
  TcpOutSegs                      276                0.0
  TcpOutRsts                      3                  0.0
  TcpExtPruneCalled               2                  0.0
  TcpExtRcvPruned                 1                  0.0
  TcpExtTCPPureAcks               104                0.0
  TcpExtTCPRcvCollapsed           2                  0.0
  TcpExtTCPBacklogCoalesce        42                 0.0
  TcpExtTCPRcvCoalesce            43                 0.0
  TcpExtTCPChallengeACK           1                  0.0
  TcpExtTCPFromZeroWindowAdv      42                 0.0
  TcpExtTCPToZeroWindowAdv        41                 0.0
  TcpExtTCPWantZeroWindowAdv      13                 0.0
  TcpExtTCPOrigDataSent           164                0.0
  TcpExtTCPDelivered              165                0.0
  TcpExtTCPRcvQDrop               1                  0.0

In the failing scenarios (TCP -> MPTCP), the involved sockets are actually plain TCP ones, as fallbacks for passive sockets at 2WHS time cause the MPTCP listeners to actually create 'plain' TCP sockets.

Similar to commit 218cc166321f ("selftests: mptcp: avoid spurious errors on disconnect"), the root cause is in the user-space bits: the test program tries to disconnect as soon as all the pending data has been spooled, generating an RST. If such option reaches the peer before the connection has reached the closed status, the TCP socket will report an error to the user-space, as per protocol specification, causing the above failure. Note that it looks like this issue got more visible since the "tcp: receiver changes" series from commit 06baf9bfa6ca ("Merge branch 'tcp-receiver-changes'").

Address the issue by explicitly waiting for the TCP sockets (-t) to reach a closed status before performing the disconnect. More precisely, the test program now waits for plain TCP sockets or TCP subflows in addition to the MPTCP sockets that were already monitored.

While at it, use 'ss' with '-n' to avoid resolving service names, which is not needed here.

Fixes 218cc166321f ("selftests: mptcp: avoid spurious errors on disconnect")

---
- v2: no more state filtering needed, thanks to the fix in the kernel

---
 tools/testing/selftests/net/mptcp/mptcp_connect.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/net/mptcp/mptcp_connect.c +2 -2
index 1408698df0999730d9a9a4ad6a6362a4ab122d54..b148cadb96d0b735901c92a1e4417f29c263dd90 100644
@@ -1248,7 +1248,7 @@ void xdisconnect(int fd)
 	else
 		xerror("bad family");
 
-	strcpy(cmd, "ss -M | grep -q ");
+	strcpy(cmd, "ss -Mnt | grep -q ");
 	cmdlen = strlen(cmd);
 	if (!inet_ntop(addr.ss_family, raw_addr, &cmd[cmdlen],
 		       sizeof(cmd) - cmdlen))
@@ -1258,7 +1258,7 @@ void xdisconnect(int fd)
 
 	/*
 	 * wait until the pending data is completely flushed and all
-	 * the MPTCP sockets reached the closed status.
+	 * the sockets reached the closed status.
 	 * disconnect will bypass/ignore/drop any pending data.
 	 */
 	for (i = 0; ; i += msec_sleep) {
Signature · 1 line
2.51.0
author maintainer
#7 lore raw

PATCH v3 4/5 selftests: mptcp: print trailing bytes with od

In reply to Matthieu Baerts (NGI0)

This is better than printing random bytes in the terminal.

Note that Jakub suggested 'hexdump', but Mat found out this tool is not often installed by default. 'od' can do a similar job, and it is in the POSIX specs and available in coreutils, so it should be on more systems.

While at it, display a few more bytes, just to fill in the two lines. And no need to display the 3rd only line showing the next number of
bytes: 0000040.

---
v2: switch to 'od', and no more check for its presence (Mat)
v3: mention there are more bytes (Geliang)

---
 tools/testing/selftests/net/mptcp/mptcp_lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_lib.sh +1 -1
index 09cd24b2ae466205dacbdf8289eb86c08534c475..d62e653d48b0f2ef7a01e289fa0be8907825667d 100644
@@ -384,7 +384,7 @@ mptcp_lib_make_file() {
 mptcp_lib_print_file_err() {
 	ls -l "${1}" 1>&2
 	echo "Trailing bytes are: "
-	tail -c 27 "${1}"
+	tail -c 32 "${1}" | od -x | head -n2
 }
 
 # $1: input file ; $2: output file ; $3: what kind of file
Signature · 1 line
2.51.0
author maintainer
#8 lore raw

PATCH v3 5/5 selftests: mptcp: connect: print pcap suffix

In reply to Matthieu Baerts (NGI0)

To be able to find which capture files have been produced after several runs.

This suffix was not printed anywhere before.

While at it, always use the same prefix by taking info from ns1, instead of "$connector_ns", which is sometimes ns1, sometimes ns2 in the subtests.

---
 tools/testing/selftests/net/mptcp/mptcp_connect.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +5 -1
index c2ab9f7f0d2133559bb18ce884b613d21d1ec5f0..47ecb5b3836eb5c64787bda0f6f1cc7c3af338aa 100755
@@ -211,6 +211,11 @@ if $checksum; then
 	done
 fi
 
+if $capture; then
+	rndh="${ns1:4}"
+	mptcp_lib_pr_info "Packet capture files will have this prefix: ${rndh}-"
+fi
+
 set_ethtool_flags() {
 	local ns="$1"
 	local dev="$2"
@@ -361,7 +366,6 @@ do_transfer()
 
 	if $capture; then
 		local capuser
-		local rndh="${connector_ns:4}"
 		if [ -z $SUDO_USER ] ; then
 			capuser=""
 		else
Signature · 1 line
2.51.0
maintainer Reviewed-by on v3 5/5
#9 lore raw

Re: [PATCH mptcp-net v3 5/5] selftests: mptcp: connect: print pcap suffix

Quoted 5 lines · On Wed, 10 Sep 2025, Matthieu Baerts (NGI0) wrote:

To be able to find which capture files have been produced after several runs.

This suffix was not printed anywhere before.

One quick change before upstreaming: s/suffix/prefix/

Otherwise LGTM:

Quoted 39 lines

While at it, always use the same prefix by taking info from ns1, instead of "$connector_ns", which is sometimes ns1, sometimes ns2 in the subtests.

---
tools/testing/selftests/net/mptcp/mptcp_connect.sh | 6 +++++-

1 file changed, 5 insertions(+), 1 deletion(-)
tools/testing/selftests/net/mptcp/mptcp_connect.sh +0 -0
index c2ab9f7f0d2133559bb18ce884b613d21d1ec5f0..47ecb5b3836eb5c64787bda0f6f1cc7c3af338aa 100755
@@ -211,6 +211,11 @@ if $checksum; then
 	done

fi

tools/testing/selftests/net/mptcp/mptcp_connect.sh +5 -0
+if $capture; then
+	rndh="${ns1:4}"
+	mptcp_lib_pr_info "Packet capture files will have this prefix: ${rndh}-"
+fi
+
set_ethtool_flags() {
	local ns="$1"
	local dev="$2"
tools/testing/selftests/net/mptcp/mptcp_connect.sh +0 -1
@@ -361,7 +366,6 @@ do_transfer()
 
 	if $capture; then
 		local capuser
-		local rndh="${connector_ns:4}"
 		if [ -z $SUDO_USER ] ; then
 			capuser=""
 		else
Signature · 2 lines
-- 
2.51.0
reviewer Reviewed-by on the v3 series
#10 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matt,

Thanks for this v3.

Quoted 33 lines · On Wed, 2025-09-10 at 10:55 +0200, Matthieu Baerts (NGI0) wrote:

This should fix the recent instabilities seen by MPTCP and NIPA CIs where the 'mptcp_connect.sh' tests fail regularly when running the 'disconnect' subtests with "plain" TCP sockets, e.g.

  # INFO: disconnect
  # 63 ns1 MPTCP -> ns1 (10.0.1.1:20001      ) MPTCP     (duration 996ms) [ OK ]
  # 64 ns1 MPTCP -> ns1 (10.0.1.1:20002      ) TCP       (duration 851ms) [ OK ]
  # 65 ns1 TCP   -> ns1 (10.0.1.1:20003      ) MPTCP     Unexpected
revents: POLLERR/POLLNVAL(19)
  # (duration   896ms) [FAIL] file received by server does not match (in, out):
  # -rw-r--r-- 1 root root 11112852 Aug 19 09:16 /tmp/tmp.hlJe5DoMoq.disconnect
  # Trailing bytes are:
  # /{ga 6@=#.8:-rw------- 1 root root 10085368 Aug 19 09:16 /tmp/tmp.blClunilxx
  # Trailing bytes are:
  # /{ga 6@=#.8:66 ns1 MPTCP -> ns1 (dead:beef:1::1:20004) MPTCP (duration   987ms) [ OK ]
  # 67 ns1 MPTCP -> ns1 (dead:beef:1::1:20005) TCP       (duration 911ms) [ OK ]
  # 68 ns1 TCP   -> ns1 (dead:beef:1::1:20006) MPTCP     (duration 980ms) [ OK ]
  # [FAIL] Tests of the full disconnection have failed

Patch 3 fixes this issue, but a fix in MPTCP in patch 1 is also needed
to fix MPTCP behaviour, and simplify patch 3. Patches 2 and 4 improve some errors reported by the selftests, and patch 5 helps with the debugging. I guess all these patches can be sent to 'net'

Quoted 5 lines

Note: Patch 1 will cause errors in Packetdrill, that's normal, see [1].

Looks good.

-Geliang

Quoted 34 lines

---
Changes in v3:
- Patch 2: close some FDs in case of errors (Geliang)
- Patch 4: mention there are now more bytes (Geliang)
- Link to v2:
https://lore.kernel.org/r/[email protected]

Changes in v2:
- Patch 1: new
- Patch 3: no more state filtering needed thanks to patch 1
- Patch 4: switch from hexdump to od (Mat)
- Patch 5: new
- Link to v1:
https://lore.kernel.org/r/[email protected]

---
Matthieu Baerts (NGI0) (5):
      mptcp: propagate shutdown to subflows when possible
      selftests: mptcp: connect: catch IO errors on listen side
      selftests: mptcp: avoid spurious errors on TCP disconnect
      selftests: mptcp: print trailing bytes with od
      selftests: mptcp: connect: print pcap suffix

 net/mptcp/protocol.c                               | 16
++++++++++++++++
 tools/testing/selftests/net/mptcp/mptcp_connect.c  | 11 ++++++----- tools/testing/selftests/net/mptcp/mptcp_connect.sh |  6 +++++- tools/testing/selftests/net/mptcp/mptcp_lib.sh     |  2 +-

 4 files changed, 28 insertions(+), 7 deletions(-)

---
base-commit: 1e51af26b216c689f6d75872290bb0de1eeaae34
change-id: 20250806-sft-mptcp-disc-err-3357b769bcdb

Best regards,

#11 lore raw
In reply to Matthieu Baerts (NGI0)

Hi Matthieu,

Thank you for your modifications, that's great!

Our CI did some validations and here is its report:

- KVM Validation: normal: Unstable: 3 failed test(s): packetdrill_dss packetdrill_fastopen packetdrill_syscalls 🔴
- KVM Validation: debug: Unstable: 3 failed test(s): packetdrill_dss packetdrill_fastopen packetdrill_syscalls 🔴
- KVM Validation: btf-normal (only bpftest_all): Success! ✅
- KVM Validation: btf-debug (only bpftest_all): Success! ✅
- Task: https://github.com/multipath-tcp/mptcp_net-next/actions/runs/17609032414

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

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)

maintainer Reviewed-by on the v3 series
#12 lore raw
In reply to Matthieu Baerts (NGI0)
Quoted 25 lines · On Wed, 10 Sep 2025, Matthieu Baerts (NGI0) wrote:

This should fix the recent instabilities seen by MPTCP and NIPA CIs where the 'mptcp_connect.sh' tests fail regularly when running the 'disconnect' subtests with "plain" TCP sockets, e.g.

# INFO: disconnect

 # 63 ns1 MPTCP -> ns1 (10.0.1.1:20001      ) MPTCP     (duration   996ms) [ OK ]
 # 64 ns1 MPTCP -> ns1 (10.0.1.1:20002      ) TCP       (duration   851ms) [ OK ]
 # 65 ns1 TCP   -> ns1 (10.0.1.1:20003      ) MPTCP     Unexpected revents: POLLERR/POLLNVAL(19)
 # (duration   896ms) [FAIL] file received by server does not match (in, out):
 # -rw-r--r-- 1 root root 11112852 Aug 19 09:16 /tmp/tmp.hlJe5DoMoq.disconnect
 # Trailing bytes are:
 # /{ga 6@=#.8:-rw------- 1 root root 10085368 Aug 19 09:16 /tmp/tmp.blClunilxx
 # Trailing bytes are:
 # /{ga 6@=#.8:66 ns1 MPTCP -> ns1 (dead:beef:1::1:20004) MPTCP     (duration   987ms) [ OK ]
 # 67 ns1 MPTCP -> ns1 (dead:beef:1::1:20005) TCP       (duration   911ms) [ OK ]
 # 68 ns1 TCP   -> ns1 (dead:beef:1::1:20006) MPTCP     (duration   980ms) [ OK ]

# [FAIL] Tests of the full disconnection have failed

Patch 3 fixes this issue, but a fix in MPTCP in patch 1 is also needed to fix MPTCP behaviour, and simplify patch 3. Patches 2 and 4 improve some errors reported by the selftests, and patch 5 helps with the debugging. I guess all these patches can be sent to 'net'

Note: Patch 1 will cause errors in Packetdrill, that's normal, see [1].

Quoted 7 lines

---
Changes in v3:
- Patch 2: close some FDs in case of errors (Geliang)
- Patch 4: mention there are now more bytes (Geliang)
- Link to v2: https://lore.kernel.org/r/[email protected]

Hi Matthieu -

Patch 5 I acked separately, one minor fix in the commit message but no need for v4.

Patches 1-4 LGTM. Even though it's possible (in patch 1) that a shutdown may be attempted on a subflow that doesn't need it, tcp_shutdown() has the logic to handle that.

Quoted 31 lines

Changes in v2:
- Patch 1: new
- Patch 3: no more state filtering needed thanks to patch 1
- Patch 4: switch from hexdump to od (Mat)
- Patch 5: new
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Matthieu Baerts (NGI0) (5):
mptcp: propagate shutdown to subflows when possible
selftests: mptcp: connect: catch IO errors on listen side
selftests: mptcp: avoid spurious errors on TCP disconnect
selftests: mptcp: print trailing bytes with od
selftests: mptcp: connect: print pcap suffix

net/mptcp/protocol.c                               | 16 ++++++++++++++++
tools/testing/selftests/net/mptcp/mptcp_connect.c  | 11 ++++++-----
tools/testing/selftests/net/mptcp/mptcp_connect.sh |  6 +++++-
tools/testing/selftests/net/mptcp/mptcp_lib.sh     |  2 +-
4 files changed, 28 insertions(+), 7 deletions(-)

---
base-commit: 1e51af26b216c689f6d75872290bb0de1eeaae34
change-id: 20250806-sft-mptcp-disc-err-3357b769bcdb

Best regards,

Signature · 1 line
Matthieu Baerts (NGI0) <[email protected]>
author maintainer
#13 lore raw

Hi Geliang, Mat,

Quoted 46 lines · Mat Martineau
Quoted 34 lines · On Wed, 10 Sep 2025, Matthieu Baerts (NGI0) wrote:

This should fix the recent instabilities seen by MPTCP and NIPA CIs where the 'mptcp_connect.sh' tests fail regularly when running the 'disconnect' subtests with "plain" TCP sockets, e.g.

 # INFO: disconnect
 # 63 ns1 MPTCP -> ns1 (10.0.1.1:20001      ) MPTCP     (duration 996ms) [ OK ]
 # 64 ns1 MPTCP -> ns1 (10.0.1.1:20002      ) TCP       (duration 851ms) [ OK ]
 # 65 ns1 TCP   -> ns1 (10.0.1.1:20003      ) MPTCP     Unexpected
revents: POLLERR/POLLNVAL(19)
 # (duration   896ms) [FAIL] file received by server does not match (in, out):
 # -rw-r--r-- 1 root root 11112852 Aug 19 09:16 /tmp/ tmp.hlJe5DoMoq.disconnect
 # Trailing bytes are:
 # /{ga 6@=#.8:-rw------- 1 root root 10085368 Aug 19 09:16 /tmp/ tmp.blClunilxx
 # Trailing bytes are:
 # /{ga 6@=#.8:66 ns1 MPTCP -> ns1 (dead:beef:1::1:20004) MPTCP (duration   987ms) [ OK ]
 # 67 ns1 MPTCP -> ns1 (dead:beef:1::1:20005) TCP       (duration 911ms) [ OK ]
 # 68 ns1 TCP   -> ns1 (dead:beef:1::1:20006) MPTCP     (duration 980ms) [ OK ]
 # [FAIL] Tests of the full disconnection have failed

Patch 3 fixes this issue, but a fix in MPTCP in patch 1 is also needed to fix MPTCP behaviour, and simplify patch 3. Patches 2 and 4 improve some errors reported by the selftests, and patch 5 helps with the debugging. I guess all these patches can be sent to 'net'

Note: Patch 1 will cause errors in Packetdrill, that's normal, see [1].

Quoted 8 lines

---
Changes in v3:
- Patch 2: close some FDs in case of errors (Geliang)
- Patch 4: mention there are now more bytes (Geliang)
- Link to v2: https://lore.kernel.org/r/20250905-sft-mptcp-disc-err-
[email protected]

Quoted 4 lines

Hi Matthieu -

Patch 5 I acked separately, one minor fix in the commit message but no need for v4.

Good catch! Fixed!

Quoted 3 lines

Patches 1-4 LGTM. Even though it's possible (in patch 1) that a shutdown may be attempted on a subflow that doesn't need it, tcp_shutdown() has the logic to handle that.

Indeed, that's why I didn't add extra checks before calling tcp_shutdown(). I just added this note in the commit message:

Note that tcp_shutdown() will check the subflow state, so no need to do that again before calling it.

Quoted 1 line

Thank you for the review here and in the packetdrill PR (applied and backported)!

Now in our tree (fixes for -net):

New patches for t/upstream-net and t/upstream:
- 8cc6e542f150: mptcp: propagate shutdown to subflows when possible
- 07cc3161a4a6: selftests: mptcp: connect: catch IO errors on listen side
- 4f6152573302: selftests: mptcp: avoid spurious errors on TCP disconnect
- 42c1206d2751: selftests: mptcp: print trailing bytes with od
- 83fd25a7e401: selftests: mptcp: connect: print pcap prefix
- Results: c62821417a96..c3bb5aa20b8e (export-net)
- Results: 623fb42fecc5..6ff9d54223e3 (export)

Tests are now in progress:

- export-net:
https://github.com/multipath-tcp/mptcp_net-next/commit/b6b24ce1bd89c893d3e7f9262f7a9b92aaa19736/checks
- export:
https://github.com/multipath-tcp/mptcp_net-next/commit/bf5738cace8ab21e5bba9ebe1d8fa7175407f222/checks

Cheers,
Matt

Signature · 1 line
Sponsored by the NGI0 Core fund.