Skip to content

Commit 33a09c6

Browse files
committed
Merge branch 'selftests-mptcp-avoid-spurious-errors-on-tcp-disconnect'
Matthieu Baerts says: ==================== selftests: mptcp: avoid spurious errors on TCP disconnect This series 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 These issues started to be visible after some behavioural changes in TCP, where too quick re-connections after a shutdown() can now be more easily rejected. Patch 3 modifies the selftests to wait, but this resolution revealed an issue in MPTCP which is fixed by patch 1 (a fix for v5.9 kernel). Patches 2 and 4 improve some errors reported by the selftests, and patch 5 helps with the debugging of such issues. ==================== Link: https://patch.msgid.link/20250912-net-mptcp-fix-sft-connect-v1-0-d40e77cbbf02@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2 parents 71379e1 + cf74e0a commit 33a09c6

File tree

4 files changed

+28
-7
lines changed

4 files changed

+28
-7
lines changed

net/mptcp/protocol.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,20 @@ static void mptcp_close_wake_up(struct sock *sk)
371371
sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
372372
}
373373

374+
static void mptcp_shutdown_subflows(struct mptcp_sock *msk)
375+
{
376+
struct mptcp_subflow_context *subflow;
377+
378+
mptcp_for_each_subflow(msk, subflow) {
379+
struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
380+
bool slow;
381+
382+
slow = lock_sock_fast(ssk);
383+
tcp_shutdown(ssk, SEND_SHUTDOWN);
384+
unlock_sock_fast(ssk, slow);
385+
}
386+
}
387+
374388
/* called under the msk socket lock */
375389
static bool mptcp_pending_data_fin_ack(struct sock *sk)
376390
{
@@ -395,6 +409,7 @@ static void mptcp_check_data_fin_ack(struct sock *sk)
395409
break;
396410
case TCP_CLOSING:
397411
case TCP_LAST_ACK:
412+
mptcp_shutdown_subflows(msk);
398413
mptcp_set_state(sk, TCP_CLOSE);
399414
break;
400415
}
@@ -563,6 +578,7 @@ static bool mptcp_check_data_fin(struct sock *sk)
563578
mptcp_set_state(sk, TCP_CLOSING);
564579
break;
565580
case TCP_FIN_WAIT2:
581+
mptcp_shutdown_subflows(msk);
566582
mptcp_set_state(sk, TCP_CLOSE);
567583
break;
568584
default:

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ int main_loop_s(int listensock)
10931093
struct pollfd polls;
10941094
socklen_t salen;
10951095
int remotesock;
1096+
int err = 0;
10961097
int fd = 0;
10971098

10981099
again:
@@ -1125,7 +1126,7 @@ int main_loop_s(int listensock)
11251126
SOCK_TEST_TCPULP(remotesock, 0);
11261127

11271128
memset(&winfo, 0, sizeof(winfo));
1128-
copyfd_io(fd, remotesock, 1, true, &winfo);
1129+
err = copyfd_io(fd, remotesock, 1, true, &winfo);
11291130
} else {
11301131
perror("accept");
11311132
return 1;
@@ -1134,10 +1135,10 @@ int main_loop_s(int listensock)
11341135
if (cfg_input)
11351136
close(fd);
11361137

1137-
if (--cfg_repeat > 0)
1138+
if (!err && --cfg_repeat > 0)
11381139
goto again;
11391140

1140-
return 0;
1141+
return err;
11411142
}
11421143

11431144
static void init_rng(void)
@@ -1247,7 +1248,7 @@ void xdisconnect(int fd)
12471248
else
12481249
xerror("bad family");
12491250

1250-
strcpy(cmd, "ss -M | grep -q ");
1251+
strcpy(cmd, "ss -Mnt | grep -q ");
12511252
cmdlen = strlen(cmd);
12521253
if (!inet_ntop(addr.ss_family, raw_addr, &cmd[cmdlen],
12531254
sizeof(cmd) - cmdlen))
@@ -1257,7 +1258,7 @@ void xdisconnect(int fd)
12571258

12581259
/*
12591260
* wait until the pending data is completely flushed and all
1260-
* the MPTCP sockets reached the closed status.
1261+
* the sockets reached the closed status.
12611262
* disconnect will bypass/ignore/drop any pending data.
12621263
*/
12631264
for (i = 0; ; i += msec_sleep) {

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ if $checksum; then
211211
done
212212
fi
213213

214+
if $capture; then
215+
rndh="${ns1:4}"
216+
mptcp_lib_pr_info "Packet capture files will have this prefix: ${rndh}-"
217+
fi
218+
214219
set_ethtool_flags() {
215220
local ns="$1"
216221
local dev="$2"
@@ -361,7 +366,6 @@ do_transfer()
361366

362367
if $capture; then
363368
local capuser
364-
local rndh="${connector_ns:4}"
365369
if [ -z $SUDO_USER ] ; then
366370
capuser=""
367371
else

tools/testing/selftests/net/mptcp/mptcp_lib.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ mptcp_lib_make_file() {
384384
mptcp_lib_print_file_err() {
385385
ls -l "${1}" 1>&2
386386
echo "Trailing bytes are: "
387-
tail -c 27 "${1}"
387+
tail -c 32 "${1}" | od -x | head -n2
388388
}
389389

390390
# $1: input file ; $2: output file ; $3: what kind of file

0 commit comments

Comments
 (0)