From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557659; b=N7HVjpHR3PWPpzcM7GLUEwsVAqubyFaMoDzM8F380SAqc92D9az0I0c72+AlyO/gH9Yn wPyGlTlYP7PTs2ybDILsWrkr8wG6oi2PT/9s0dkbobCB23aQTH5cN9L9OJjd4wI+733+9 lujP4f/3jM39DkrNhqDH04sGOkEh7MEKdVqzvUToWvGOIADmPQz9qYPKCzKAvWuGJhaBm 78iDqXTNL92WptbHhQoleJm7uopBPO8ObcITEWIuqiuhEIb8hwwXLowtZN3P6sIXELuLe Ml/gJz9vZkkxvzlNZOnfbU2Y6kmBn6FRQ8vQj8a5BA7RPKT/zt0q2yg0h8Ic1Q8S81g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557659; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=NFHl0WA5e1oy/ZWXXqipZ8X9aveWbffDTV12VSEKKM4=; b=Y/L0zLZYu/oaMMIDo4QK+IZ0u4YI/PcYIpN8KdXC8Reh7gm3OacbZfzPJwiaNQi/rV1e 3Ufhmu8gUnYpWjiDUUPRvYQmkOg9AG1I59U9QQmiU5pGCSZEJ6wa/Yn4lOXJYcdVwMf6M J5ikDOfKLulTB7ND7uh0IbXhO2zV2ICKNkFY0+h3p8FtHAtLmgQGeyCpuEu1oZBIMlJCQ qIry4ungaqXq/ddBjLHKuDELrfvP/jvsQVA3W4v8iWz/+I3JEWV7jAUsEz4bHHKnAZq5p 0wJ8QtqchJ8+mXMFbMTuLQG/3Nx+X4feO1da1l0jV9lSNTeyHPEq5fRA0pNe9yq1c0w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gwn+WPh4; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 696D4606A331 for ; Tue, 24 Nov 2026 22:00:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gwn+WPh4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A53651F000D2; Tue, 24 Nov 2026 22:00:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557659; bh=NFHl0WA5e1oy/ZWXXqipZ8X9aveWbffDTV12VSEKKM4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=gwn+WPh4TthSVM4UwQjkKuOrK15ATzkf6F/b/pv2lV40WHZTRe+BdCNIIhd0bMYmX F+H5tJ6zP2HxQU+cwxpHl3+a42LfStvIeJkchc+eknAgWax4eACeU8uZk6stBabj1t Rc+EV/u0/spztE4YGWtOkJf4nwjlrz3uRZDZAXf0GR6oV5QopxH2WPh76Z6J3H1a/s NMJgDUtqASaiWI9fEAQG2QWuxfj/U6fzk1ZJ4gVeXmcKbP8XOHnUWMnFQ82admM+6u 3ZzOyA+FfoQJUsZkofYyGhoDfa4afK6kkEuLRPoQzUMIt4VVlouKuJCweu65Th7S4/ zDK9YPvySow5w== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:18 +0100 Subject: [PATCH mptcp-net v3 01/50] mptcp: keep an orphan while it can send its data X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-1-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3841; i=matttbe@kernel.org; h=from:subject:message-id; bh=TCaYGg220Y3RmdYx6fWeMluPNm1OOK0qvvDBK1lYD+U=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOL47zTm8hePtJKeYritvP/LYnYmoijxua9ewgdFA0 C5kmnBDRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwETq/zAynP07xY1n1b47Pe0y NXMd+t62Prq8Mjp94ZOLc1VmVxv938Lwv3jtW1mlq7Ju/r2X7l1bLNtUvWRR2PU4OYGHmpdNDyn pcAEA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The close timeout of an orphaned MPTCP socket started at close(), and its expiry reset the connection, while some data could still be waiting for the peer to open its window: a peer reading slowly or pausing got a reset 60 seconds after close(), and lost the end of the data, while TCP delivers it. This timeout is there for the DATA_FIN exchange, see commit d866ae9aaa43 ("mptcp: add a new sysctl for make after break timeout"), and for an orphan that can no longer send anything. So restart it when the DATA_FIN is sent, and when it expires before, as long as a subflow can still send the data, which is then pushed again: an established subflow, on which the peer acked something recently, at least the window probes. Until then, as for a TCP socket that is not orphaned, nothing limits how long the peer can keep its window closed, while it acks the window probes. The timeout still starts at close(): the subflows are not TCP orphans, so its expiry is the only check that the orphan can still send. This was reported on GitHub, with a reproducer: a server writes 2 MB, then calls close(), while the client pauses before reading the rest. After a pause of 90 seconds, the client got ECONNRESET, while TCP delivered everything, as MPTCP now does. If the client vanishes instead, the orphan is now reset as TCP does. Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close") Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/647 Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau --- v2: new, for issue #647 reported on GitHub Note (Clashiko on v2): when the last subflow is closed in the same worker run, before the DATA_FIN is sent, the destruction of the orphan is delayed once, by the close timeout. Not restarting the timeout once expired would reset an orphan sending its DATA_FIN after a long probing. --- net/mptcp/protocol.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d64e04245963..944c9d11d211 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2871,6 +2871,28 @@ static bool mptcp_close_tout_expired(const struct so= ck *sk) inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk)); } =20 +/* Before its DATA_FIN, keep an orphan while a subflow can send its data */ +static bool mptcp_orphan_keep(struct sock *sk) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + + if (!sock_flag(sk, SOCK_DEAD) || msk->snd_nxt =3D=3D msk->write_seq) + return false; + + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + + /* a live peer acks at least the probes, every TCP_RTO_MAX */ + if (__mptcp_subflow_active(subflow) && + tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < + 2 * TCP_RTO_MAX) + return true; + } + + return false; +} + static void mptcp_check_fastclose(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow, *tmp; @@ -3208,6 +3230,11 @@ static void mptcp_worker(struct work_struct *work) if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags)) __mptcp_close_subflow(sk); =20 + if (mptcp_close_tout_expired(sk) && mptcp_orphan_keep(sk)) { + mptcp_start_tout_timer(sk); + __mptcp_push_pending(sk, 0); + } + if (mptcp_close_tout_expired(sk)) { struct mptcp_subflow_context *subflow, *tmp; =20 @@ -3449,6 +3476,10 @@ static void mptcp_check_send_data_fin(struct sock *s= k) =20 WRITE_ONCE(msk->snd_nxt, msk->write_seq); =20 + /* an orphan's close timeout is for the DATA_FIN exchange */ + if (sock_flag(sk, SOCK_DEAD)) + mptcp_start_tout_timer(sk); + mptcp_for_each_subflow(msk, subflow) { struct sock *tcp_sk =3D mptcp_subflow_tcp_sock(subflow); =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557660; b=UHKiQo8vOWAcWduTCL+E7VUFbxDG8l07hRfEX6qyBcaKmvEVd7smez3LW/A7ZbhemcxE iEaG/Ob1UHUM0+EQqCdyH6rD4HG/Jo3SIKY5YrXydbsF6RGvykrF4i6Ure9/Jkc434SjN KOlALMzz2azSrhv0Nun+uhkojKsG0qhGbLlI0kiMYIQzesGVzyXuTug566qIPoX6OOSjY rTX+phSNZFYKWB9XgxnZsaPvwJDTGsD3wmiuCvs4Pn8kHZ71bZdQ87hvbLBfz94M3h0S1 3UP+nabU2d9GfkXO4Oc1+94p/AITabjlk2bqTO8639lSY/aUUwuN9dhHqFV/hjJsdXQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557660; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=H87p4BaCJ9/1S2/jNtJswWg+CJoVJVLNVXu7TjHOntA=; b=DPgmbgNUZdM5O9idVpIyOuFwhoo7bD2n5huRk3FnjMe1W5+K/v7kUn3hdkb8v/P6981o 1ErhaNT/igHj4Xdp8CDVA6mDxondvgGVR/u0H9duKSmcwtyZwZYoJV028Q/173+v72TE7 4AS6b2NV8keSz9+dCPWSt2RqGT8l7w23Rtosg2PUlXM7k/5Dl4pHOMp7qOmpLGcz4m9NP d99CTDft54rSQS3MKwONFibU0cCzZli8zkTR7OicceRCkI8AljALg9x7WB7IkHvm3NQ+j 5FKPg0z74DsNmEnG0hoZaG4kEhgJfkloscKJihfMlLxayd+iW8sRubnn68y4kAng/Jw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IcIb7mH2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DBDE606A321 for ; Tue, 24 Nov 2026 22:01:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=IcIb7mH2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7881F000C0; Tue, 24 Nov 2026 22:00:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557660; bh=H87p4BaCJ9/1S2/jNtJswWg+CJoVJVLNVXu7TjHOntA=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=IcIb7mH21Ms5NYtoCrDGuY0KtsbLfWwOlQRzf+Oqzj/SnmcEK/yLe0yjKjCmsvC+u 2Nlit63cBbfEemF+4wP92oU5r21icYwhw5cMdMJxDVAy1XSlO5SBfs9wnwzvePCsvH xcFejXDFlyTyF2A266bKKMQjpjUMCd9xZf1wE/7CXK+K9aattWZnGv2HJ5VwVx/vc1 Urisn8eAq5G3O4Lo2C3gc9eLVniuuZBKqhVlv7nkKgklnWQt0oWb/El1DROWt86ERR bc/untzqezg9p17evBqcZUgQCGhYOTs3iWWzeQPQVB629Jg4sX/gUnp19Nf9U13y6d afDL5fJXIeC1Q== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:19 +0100 Subject: [PATCH mptcp-net v3 02/50] mptcp: limit an orphan probing a zero window X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-2-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3493; i=matttbe@kernel.org; h=from:subject:message-id; bh=r1DBDbV2ULWkfhAuLVqd6z/2O8cAIJ/YuPi80RA5d9M=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH7YMfN5ThBXOvFkXq6Ut0PNDTO/58+3tl9XEnNmm VlydMOpjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlwnmP4xZR4SWn+Z24m0zW/ 72z/4MOb98bA+8mvzZ3LejrtPTc80WX4Z63Hw92SkaT68maZ6K2YS2zRJz7OnDA99V6M949Vbo/ /8AIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Since the previous commit, an orphan with data to send is kept while the peer acks something, at least the window probes: a peer keeping its window closed, e.g. not reading, could then keep the orphan forever. TCP limits this for its orphans: tcp_probe_timer() aborts them instead of probing again after the max interval. The subflows of an MPTCP orphan are not orphaned: they probe again then, and back off once more, up to tcp_retries2. So check if TCP would have aborted them, when the close timeout expires. Same with data in flight, when the peer has shrunk its window to zero: tcp_retransmit_timer() only aborts orphans then. Two corner cases needing non-default settings are not covered, which is fine: an idle subflow refreshed by keepalives still keeps the orphan when the stale detection is disabled, and tcp_orphan_retries is ignored. This was found by an AI code review agent, while reviewing the previous commit. With its reproducer and a long pause, the orphan was kept until the end of the pause. It is now reset as TCP does, respecting tcp_retries2. Note for the backports: this patch is needed with the previous one, and before v6.15, tcp_rto_max() can be replaced by TCP_RTO_MAX. Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close") Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau --- v2: new, to limit the orphans kept by the previous patch, with the same Fixes tag to backport them together. Note (Clashiko on v2): a peer acking the data at the TCP level only keeps the orphan, but this is bounded by tcp_max_orphans and tcp_mem since the next patch. With the stale detection, the probing subflow is marked as stale, and its data is moved to the idle one. --- net/mptcp/protocol.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 944c9d11d211..ff71f1954077 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2871,6 +2871,32 @@ static bool mptcp_close_tout_expired(const struct so= ck *sk) inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk)); } =20 +/* Would TCP abort this subflow if it were an orphan probing a zero window= ? */ +static bool mptcp_subflow_probe_timed_out(struct sock *ssk) +{ + u8 retries2 =3D READ_ONCE(sock_net(ssk)->ipv4.sysctl_tcp_retries2); + struct inet_connection_sock *icsk =3D inet_csk(ssk); + const struct tcp_sock *tp =3D tcp_sk(ssk); + unsigned long limit; + bool slow, ret; + u64 when; + + slow =3D lock_sock_fast_nested(ssk); + limit =3D tcp_rto_max(ssk); + if (tp->packets_out) { + ret =3D !tp->snd_wnd && icsk->icsk_rto >=3D limit; + } else { + if (icsk->icsk_backoff < retries2) + limit *=3D 2; + /* a shift of 32 already exceeds the limit */ + when =3D (u64)icsk->icsk_rto << min_t(u8, icsk->icsk_backoff, 32); + ret =3D tcp_send_head(ssk) && when >=3D limit; + } + unlock_sock_fast(ssk, slow); + + return ret; +} + /* Before its DATA_FIN, keep an orphan while a subflow can send its data */ static bool mptcp_orphan_keep(struct sock *sk) { @@ -2886,7 +2912,8 @@ static bool mptcp_orphan_keep(struct sock *sk) /* a live peer acks at least the probes, every TCP_RTO_MAX */ if (__mptcp_subflow_active(subflow) && tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < - 2 * TCP_RTO_MAX) + 2 * TCP_RTO_MAX && + !mptcp_subflow_probe_timed_out(ssk)) return true; } =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557661; b=j9gI7B/VldDVAEMrozXNaOZDzzgRRSpwQ8yLA4io42t7If6YMPKfeTEGXNjKvXDb729t ruMelHfjn4Pp9/O/ngYfRE16Daga8DZd5L6dAHqucqfk/gmURTh8yfVdrHFDGCqWIPZqC EvCx8Q7REvpyJSuARhS43sW+bSSKOcnGhmwRZKJneOjyQzWvEP7tn+Cbk0HPBml0QLLdA RmcqSzUUFKvtmAWed1Qgpl9rd5ALhUVT3WeMG5v+NW3+V5miR/0LHk2W90eolfAnrbQeR 6Tta/74u8CXOG3eKe+wOQ3plSPnSCFWqVl6WXTgjWmodv83/1SUTf7XzPpIPl9GZRwA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557661; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=j7YnxP6rOSNn2PLyHdvoPa30Rf+gWB4c1ghCXQvP3qE=; b=HjiNdYKEkpF0S1F5N8g3sFnhF3qkbBGP0bfGatGrDg8sBLZ+9xXMnrjSNuTMuUe+9rX2 rXtHxUbOgSbV8RCeOLI6y63bF050TP8XNf3JVQzAMCvAd9gxL27p1woBCUJncFdVq8OSL gwjT8jhnqNqT/6dufQZwxPMBjykD7J5JKmMU3GKPqIi04bx2G7d/ZNf+FrnJhakc19qTI c6b+gU3HPPtvtZe3/wQQQwACbfwbNTf63lKcZdAog91kIJA0i2+HQQpe5qC1Bludki9px EnrNHdHThcQ0Y+qadI1Sq0p+xPmu4p7vRzmit5UEOO9tlHJbSnhTyP6wavV9xswnYNQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mAZrFlms; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F955606A321 for ; Tue, 24 Nov 2026 22:01:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=mAZrFlms Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBBFB1F000E6; Tue, 24 Nov 2026 22:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557661; bh=j7YnxP6rOSNn2PLyHdvoPa30Rf+gWB4c1ghCXQvP3qE=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=mAZrFlmsf02t7X6Rj9b69lfChEnfNrmowdsxTeeKhgj4pVtyjGKRmMcTq0t5j1so4 cZhO01NWK7oeqvWN+TppSVVN7eyLPdA6XFN530qVh9QOvLCjrZJO7NeO65szC3l9l1 2dJTSSZbL1jO6T8jiWlxq6v1sHrWt8PDGCgUSxhB9Mg9hvG+cayZsfuk5gdVntP7KW LUw1u417+0u1s7Wx+ienaY8qRWGzSCo9zWre4HoXVEjIdSoyskCLs4SVQZNVqGXuCg WTwXirJoKHRiSmxA/ZH8ecs1MOuPCLtNlk96HQG8rkNI/GhV9M66xOFjE94309M++j PRGOOVJlHJTtg== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:20 +0100 Subject: [PATCH mptcp-net v3 03/50] mptcp: count orphans as TCP does X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-3-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3856; i=matttbe@kernel.org; h=from:subject:message-id; bh=Vg4GQk5+3D7+3VKlhfVN6aAsV+cniQHjHlFCuV3qc70=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH68+he2dX28y/2PL641zj6+cPtU5XyP1YuusbS75 bpUs1vrdZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExk8haGPxw3DAI2/GPiqy5o tMkQvxP3fOksW9cgXc2pmjHTWy7kTmb4Z/NoqaFFhiLfkxl/m5afabHaH8BnJ++8xGjyhzCn8mI LHgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The MPTCP sockets orphaned by close() were not counted in tcp_orphan_count, contrary to TCP: tcp_max_orphans did not limit them, and they were not visible in /proc/net/sockstat. This is all the more needed since commit "mptcp: keep an orphan while it can send its data": an orphan can then be kept longer than its close timeout, e.g., as Sashiko noticed, by a peer acking the data at the TCP level only, without moving the DATA_ACK. Count them, and as TCP does, reset an orphan when there are too many orphans, or when TCP uses too much memory: at close(), and when its close timeout expires while it is kept to send its data. This is similar to what tcp_out_of_resources() does from the TCP timers, without the stricter limit for the stalled orphans. These resets are counted in TCPAbortOnMemory, not in a new MPTCP counter: the MPTCP orphans now share the TCP orphan count and limits. This has been found by a review agent, and validated with a script closing 8 connections whose peer doesn't read, with tcp_max_orphans set to 4: the MPTCP orphans were all kept, without being counted, while other orphans were reset. Now, only 5 or 6 are kept, vs 4 or 5 with TCP, which also checks the limit from the timers of its orphans. Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close") Signed-off-by: Matthieu Baerts (NGI0) Reviewed-by: Mat Martineau --- v2: new, spotted by a review agent Note (Clashiko on v2): the reset reason stays TCP_ABORT_ON_CLOSE, as for the other fastclose resets: only the tracepoint is affected. --- net/mptcp/protocol.c | 24 ++++++++++++++++++++++-- net/mptcp/protocol.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index ff71f1954077..9e297fa08bfe 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2897,6 +2897,16 @@ static bool mptcp_subflow_probe_timed_out(struct soc= k *ssk) return ret; } =20 +/* As TCP orphans: limited in number and memory */ +static bool mptcp_orphan_oom(struct sock *sk) +{ + if (!tcp_check_oom(sk, 0)) + return false; + + NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY); + return true; +} + /* Before its DATA_FIN, keep an orphan while a subflow can send its data */ static bool mptcp_orphan_keep(struct sock *sk) { @@ -2914,7 +2924,7 @@ static bool mptcp_orphan_keep(struct sock *sk) tcp_jiffies32 - READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < 2 * TCP_RTO_MAX && !mptcp_subflow_probe_timed_out(ssk)) - return true; + return !mptcp_orphan_oom(sk); } =20 return false; @@ -3547,6 +3557,9 @@ static void __mptcp_destroy_sock(struct sock *sk) sk_stream_kill_queues(sk); xfrm_sk_free_policy(sk); =20 + if (test_and_clear_bit(MPTCP_ORPHAN_COUNTED, &msk->flags)) + tcp_orphan_count_dec(); + sock_put(sk); } =20 @@ -3636,8 +3649,15 @@ bool __mptcp_close(struct sock *sk, long timeout) /* all the subflows are closed, only timeout can change the msk * state, let's not keep resources busy for no reasons */ - if (subflows_alive =3D=3D 0) + if (subflows_alive =3D=3D 0) { mptcp_set_state(sk, TCP_CLOSE); + } else if (sk->sk_state !=3D TCP_CLOSE) { + /* as TCP orphans: counted, and limited */ + tcp_orphan_count_inc(); + set_bit(MPTCP_ORPHAN_COUNTED, &msk->flags); + if (mptcp_orphan_oom(sk)) + mptcp_do_fastclose(sk); + } =20 sock_hold(sk); pr_debug("msk=3D%p state=3D%d\n", sk, sk->sk_state); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 2c9a442dacd6..888ee9d66967 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -117,6 +117,7 @@ #define MPTCP_FALLBACK_DONE 2 #define MPTCP_WORK_CLOSE_SUBFLOW 3 #define MPTCP_RTX_ENABLED 4 +#define MPTCP_ORPHAN_COUNTED 5 =20 /* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557663; b=lwBg3fYQaqd+97M2mM25z8/kDsFItiPRIV1yggBuzBzFOcrOouIhPRwID/j8OBj6F+Xn R+iDGysR1EDTh4K8KZ5T4YbZXK98NLv/JZuPskFYx428wDGY7hB+RLZbDMEy/UNPr6Mo1 moCHfgXqE0eYRmnpBR8zL3dgNbGgJh5ZpyLGqz63guQI8mJ/0nwLF+1XaPLn41tMeh3hY q6tUdVSfA1JhQpPMzfT50moo3pJirrVckk1KH7Nwvsbk730j0KOMqrA2ijOwVXTx95z0V tcQRpCMGeqf8YrFPomKx2i6exZ3O8QZOAVedw0UC28sCPifeXouAWxizg9AfYvmNQag== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557663; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=fbeDYkmV6VhSwEDRHYGI8E7aGE9via/0e814aCWXP8k=; b=XyBVqDI6kfh8pANMkYCieEI8X+I7vLMJjE52nAG23NDKpbfLKd57Co7IzZ/iSWV40psm ijzqGtJ2cOcqqej74cZMuXCmMr2lo7Foc6p3LoAdC2kYdndhSerat1h9GTKajuGCG3VG4 TKAOYpHAJy9dua6mXA6B490iGbjk/ulCuf4kfBaojgPlTLhSGXvTYDqUSfLQUl07mzmIN rE8HfVl5RYcEZ6dldGPl3XJIcZo6Lk48/jCFcvwtCR6MPFE208zN87HhEaKub+hHYx/aj mNiMU/uOU7rybEgSonkGxxAJ889VgEOoebVRQFpc8k2wGqShtSv8ljHgON378dCgYnw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=f2PiHCFJ; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48E3B606A337 for ; Tue, 24 Nov 2026 22:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=f2PiHCFJ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2152F1F000C0; Tue, 24 Nov 2026 22:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557662; bh=fbeDYkmV6VhSwEDRHYGI8E7aGE9via/0e814aCWXP8k=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=f2PiHCFJEfF2wZ9WRRfrnGz/urIoTPbDjWYPxMI+QmzuCD3g2nPrZlADjO3G2ZGdP 6dv9Nrv+dPERRFgHfsRWj28A6yJP4jGH9SvBm+rwb6dwcxBzSYJnMOxtsPzXNi6zUx S9s16yxICITc+jX8dVYDRXm82HTkMjmiy8SdCWPL+SyDmrGxiLv+s9ayY4wDIlWxXE qibY2xpasvRXfSNg9frOL4qbBuGIwomi4jwpp6Ofm3OaEx77PwFUnscYqKkJtou6jp JkfMCEtw5YXFSvzi1jv0haOAk0rAFLVe6liNwuQzpDzlzGkZ1t6zvs1MepyvJo+G00 SB3v9CE3TDs9A== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:21 +0100 Subject: [PATCH mptcp-net v3 04/50] mptcp: return EOF after a DATA_FIN, as TCP does X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-4-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5590; i=matttbe@kernel.org; h=from:subject:message-id; bh=9ZM9ZrqkI1nmyNEvqaYHn+7jnnuCy59ahMcpu9T5G3Y=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH5WGlS4iNVvXffitWvaBL6X5zs6K5XYeV+uqE459 uT2wUtaHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABPhbmb4X52e99FieltG7ZkG PqYTq9mfVK67/zDxeOED+7s+LltP6TMytL998/68l4ZUztUNR7vmT1vw2KNMTiXM/vx17S1zr7z p5gMA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 Once an MPTCP socket has received a DATA_FIN, recv() returns the remaining data, then EOF. But if the connection was then reset, e.g. by an MP_FASTCLOSE, recv() returned an error after the data, e.g. EPIPE, instead of EOF as TCP does. A proxy resetting the other connection on read errors then dropped the data it still had to forward. As TCP does with a FIN, set SOCK_DONE when processing the DATA_FIN, and check it before the socket error in recvmsg(). With an MP_FASTCLOSE, the data still in the backlog is moved first, not to miss the DATA_FIN. After a fallback, a DATA_FIN is also emulated after a reset: only set SOCK_DONE after a FIN, not to hide a reset behind an EOF. This FIN is cleared when the first subflow is disconnected: process this DATA_FIN before. This was reported on GitHub, and is validated with new Packetdrill tests: data and a DATA_FIN are received, then an MP_FASTCLOSE; and after a fallback, data, a FIN and a reset. Without this patch, the second read() returned EPIPE in both cases: receive_fastclose_after_data_fin.pkt:27: runtime error in read call: Expe= cted result 0 but got -1 with errno 32 (Broken pipe) v1_connect_tcpfallback_fin_reset.pkt:19: runtime error in read call: Expe= cted result 0 but got -1 with errno 32 (Broken pipe) Note for the backports: the issue with an MP_FASTCLOSE comes from commit 69800e516e96 ("mptcp: propagate fastclose error"), in v6.1. Before that, the modifications in mptcp_check_fastclose() and mptcp_disconnect() are not needed. Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk") Link: https://github.com/multipath-tcp/mptcp_net-next/issues/647 Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for issue #647 reported on GitHub v3: process the DATA_FIN before disconnecting the first subflow, which clears its FIN (Clashiko) Note (Clashiko on v2): with a DATA_FIN, then an MP_FASTCLOSE in FIN_WAIT2, the reset subflows are only released at close(): not a leak. A DATA_FIN mapped on another CPU while an MP_FASTCLOSE is processed can still lead to ECONNRESET: two subflows racing, and the connection reset by the peer anyway. --- net/mptcp/protocol.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 9e297fa08bfe..de6da0b6c4ca 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -714,6 +714,10 @@ static void mptcp_check_data_fin(struct sock *sk) WRITE_ONCE(msk->rcv_data_fin, 0); =20 WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | RCV_SHUTDOWN); + /* on fallback, also emulated after a reset: check for a FIN */ + if (!__mptcp_check_fallback(msk) || + (msk->first && sock_flag(msk->first, SOCK_DONE))) + sock_set_flag(sk, SOCK_DONE); smp_mb__before_atomic(); /* SHUTDOWN must be visible first */ =20 switch (sk->sk_state) { @@ -972,6 +976,9 @@ static bool __mptcp_subflow_error_report(struct sock *s= k, struct sock *ssk) * destroy the msk as needed. */ ssk_state =3D inet_sk_state_load(ssk); + /* a FIN received before still leads to EOF, as with TCP */ + if (sock_flag(ssk, SOCK_DONE) && mptcp_pending_data_fin(sk, NULL)) + sock_set_flag(sk, SOCK_DONE); if (ssk_state =3D=3D TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) mptcp_set_state(sk, ssk_state); WRITE_ONCE(sk->sk_err, -err); @@ -2494,6 +2501,9 @@ static int mptcp_recvmsg(struct sock *sk, struct msgh= dr *msg, size_t len, !timeo) break; } else { + if (sock_flag(sk, SOCK_DONE)) + break; + copied =3D sock_error(sk); if (copied) break; @@ -2813,6 +2823,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, void mptcp_close_ssk(struct sock *sk, struct sock *ssk, struct mptcp_subflow_context *subflow) { + struct mptcp_sock *msk =3D mptcp_sk(sk); + /* The first subflow can already be closed or disconnected */ if (subflow->close_event_done || READ_ONCE(subflow->local_id) < 0) return; @@ -2820,12 +2832,21 @@ void mptcp_close_ssk(struct sock *sk, struct sock *= ssk, subflow->close_event_done =3D true; =20 if (sk->sk_state =3D=3D TCP_ESTABLISHED) - mptcp_event(MPTCP_EVENT_SUB_CLOSED, mptcp_sk(sk), ssk, GFP_KERNEL); + mptcp_event(MPTCP_EVENT_SUB_CLOSED, msk, ssk, GFP_KERNEL); =20 /* subflow aborted before reaching the fully_established status * attempt the creation of the next subflow */ - mptcp_pm_subflow_check_next(mptcp_sk(sk), subflow); + mptcp_pm_subflow_check_next(msk, subflow); + + /* On fallback, the FIN of the first subflow is cleared when it is + * disconnected: process the DATA_FIN emulated from it before. + */ + if (ssk =3D=3D msk->first && __mptcp_check_fallback(msk) && + READ_ONCE(msk->rcv_data_fin) && !sock_flag(sk, SOCK_DEAD)) { + mptcp_move_skbs(sk); + mptcp_check_data_fin(sk); + } =20 __mptcp_close_ssk(sk, ssk, subflow, MPTCP_CF_PUSH); } @@ -2938,6 +2959,11 @@ static void mptcp_check_fastclose(struct mptcp_sock = *msk) if (likely(!READ_ONCE(msk->rcv_fastclose))) return; =20 + /* a DATA_FIN received before still leads to EOF, as with TCP */ + if (READ_ONCE(msk->rcv_data_fin)) + mptcp_move_skbs(sk); + mptcp_check_data_fin(sk); + mptcp_token_destroy(msk); =20 mptcp_for_each_subflow_safe(msk, subflow, tmp) { @@ -3797,6 +3823,7 @@ static int mptcp_disconnect(struct sock *sk, int flag= s) atomic64_set(&msk->rcv_wnd_sent, 0); =20 WRITE_ONCE(sk->sk_shutdown, 0); + sock_reset_flag(sk, SOCK_DONE); sk_error_report(sk); return 0; } --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557664; b=lxatMn8dxUnKaq8XJ4sNiq7ZmKP7hx4bdmdqn/bsb0HiTX/08fr9YDfS9joTHWz5O7td nX8hQDRT3kVotHLco4ibWrNg1iwyIq3HWa9tZLOFwiWr3yoWZFZXTq00jgk1KiHdyLdTP idW4P2GFiSnJbV7yc0fq1B7koVlC1qMKhl/xMBEXW9d037K3aCBy01Fd/z/YEQn6/ZDgj UPwGVHffvfMt8mS0SRocnNjpRxNuG6HGJ+ruCMEV5ARy+RwqoWXUrlD6SfBaRcbkGRL56 atp0e7XPD6e3bD8CQ4ZQzXdL8ktoqP2e2a7rk2/W869kHzJ5/XV+UjeP+dHJaUqFyiA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557664; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=08HOn/tspRTQoLt/ywNuNCp3wuOGGAg3BYX9BFMUL1s=; b=gWqORfMyCwPF+grPI1jaA/oXCyqSgiMF6tSUBRGA7LLBvoP7Y8ucTrZuKDTFZPHxYCrz 2gM2WMDvGw/Ze/mnqesggmcWfMzczCkJ/K0LSfTtC+JMMAnPbhHZS9RKlLb/7YmPdkSd+ eXHPc9LLH3vag9MU7MVrgr/nBUy/N900tyaw8rRItjuyW2OMyxkkN9qx894gwsU0LaBzD jO4a6quo1mU5BnAd0biu8y2U5GdRqQyhEwPq2ZVuzr1pB4r/KxPSVcb9vPUqAuTGiDLp7 TZG3VxkpZUP0PAbhcz6gqq38NHOyRpo1B345iGyyDuinFiBYk3rM7St6AvFeYhpdo6w== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kGpcMmgO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 14D07606A323 for ; Tue, 24 Nov 2026 22:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kGpcMmgO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7F1411F000C0; Tue, 24 Nov 2026 22:01:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557663; bh=08HOn/tspRTQoLt/ywNuNCp3wuOGGAg3BYX9BFMUL1s=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=kGpcMmgO6NOw1EH8A6xPp8kBr8ghNmaqHy3cy1q2E2q4MCF2FD76bZ1uSIZNraj9y Y28ge72HhJVt6R7oeUEJQIvMmAsTfcxk8PQ0APNg3j9MVYC5XSlVPxXGVJhvAut7w1 29RWbn0qw/72rIVuf0x1MG4qOpxRKjuS35a29cQRq3wb7FnXkKNvsRoiU9CEAlNRVl vMormYbnhTZOasZ9+katKGrRVjkyUb8k0mRRZquB5TSEAKkglpNFQ2XftHRgQBEkOV cJoEXGLPuWmQUUJVf0H99YBqlrDoxnfhqYvNLmwglazUp3p/PO4M4nihsXfvfQD6pQ bQue0AG62U78Q== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:22 +0100 Subject: [PATCH mptcp-net v3 05/50] mptcp: let TCP send orphan data after fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-5-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3098; i=matttbe@kernel.org; h=from:subject:message-id; bh=8t4K8hM8sjEIUgkebgtzt6uPvXe4abmymSdoEdNF4oA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH7+vf6x91Hq14yyL7Xzt17OOJtUEvnCY7LzM/M1t wp39Vgf7ihlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZjIAzWG/7nZl3Q7eXuK3/lt ma/At4B3TT6ThyCfVdcu+eDimqL17Qz/Mz6aKRnxfkrWDRPa37OjZbvLDPHa9Rq3Ba3bb/67KhD DBwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After a fallback to TCP, once an orphaned MPTCP socket has given all its data and the FIN to the subflow, the rest of the transfer is in the hands of TCP. But when the close timeout expired, the subflow was reset, and the data it still had was lost, e.g. with a peer reading slowly, while TCP sends it, within the limits set for its orphans. Close the MPTCP socket without reset in this case: the subflow is then closed as after a graceful close, and TCP sends the remaining data. Unless data received after close() has not been read: as in __mptcp_close(), a reset is then needed. Before checking that, the subflows stop passing data to the MPTCP socket: what is received later stays there, and TCP resets when closing them. This issue has been found by an AI code review agent, while validating a fix for a similar issue, and confirmed with the reproducer from the linked GitHub issue, adapted to a fallback: the writer is an MPTCP client connected to a TCP server. The server got ECONNRESET after its pause, while it gets everything with a TCP client, and now with an MPTCP one too. Fixes: d21f83485518 ("mptcp: use fastclose on more edge scenarios") Link: https://github.com/multipath-tcp/mptcp_net-next/issues/647 Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for a similar issue found by a review agent v3: stop passing data to the msk before checking for unread data, not to ack data received meanwhile without reset (Clashiko) --- net/mptcp/protocol.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index de6da0b6c4ca..f28262f07282 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2951,6 +2951,30 @@ static bool mptcp_orphan_keep(struct sock *sk) return false; } =20 +/* On fallback, TCP can send what an orphan gave to the subflow. As in + * __mptcp_close(), unread data requires a reset, also in the backlog: stop + * passing data to the msk first, TCP resets on what is received later. + */ +static bool mptcp_orphan_handover(struct sock *sk) +{ + struct mptcp_sock *msk =3D mptcp_sk(sk); + struct mptcp_subflow_context *subflow; + + if (!sock_flag(sk, SOCK_DEAD) || !__mptcp_check_fallback(msk) || + msk->snd_nxt !=3D msk->write_seq) + return false; + + mptcp_for_each_subflow(msk, subflow) { + struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); + + lock_sock(ssk); + subflow->closing =3D 1; + release_sock(ssk); + } + + return !mptcp_data_avail(msk) && !READ_ONCE(msk->backlog_len); +} + static void mptcp_check_fastclose(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow, *tmp; @@ -3298,6 +3322,10 @@ static void mptcp_worker(struct work_struct *work) __mptcp_push_pending(sk, 0); } =20 + /* TCP will close the subflow, as with its own orphans */ + if (mptcp_close_tout_expired(sk) && mptcp_orphan_handover(sk)) + mptcp_set_state(sk, TCP_CLOSE); + if (mptcp_close_tout_expired(sk)) { struct mptcp_subflow_context *subflow, *tmp; =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557665; b=unIDZtjEfzY8//CjEKDOfF4iiyi4w7NqF8X2W3kKXisuSA7lbFLA3AMBRp4XmaeoUbSN L/2sqSbu1m0xzVrqs21PiCrgxj/CkGI0e5YNepgBaF8lebzDI2IHShHloznQw8so27JK6 00Ts8WCNjp5UaDSTJk7Is8RsPoafoFALaTpF591lZ+UOlnMumWM9mDOSVEqSeyb+gKYR6 KplMgU/l5GmIh/AqJZ2D5O6xBhIeGP72Kk8RLfizNUxU3WWDflfM9b9RJRU55IhwQSxzn AVBUxAT7lGSfNperEZn8K/gg/VuLk4FYwWepwBcALMm9gS/ahreyYGV4VLermCdaNTA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557665; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=NQ6O6I9lgWJkoD59oZb2bESSWFObxrQ4jdNicUxSFHg=; b=XvkTkXPvDs84qyiOg+a01T8+GVVV29k3nyeJojZ3MrAzMHsCBD7rM/iC9p5ESN6UGZd9 /SB6aMNtOAqAA973axpVGk4oCeahvc6XAmCfJecjAIqaOniZ08QxtZWdprMmsrLgROmVR UuK9zEB8bLex+l6cyYeNtRhktQ3A04cOnXKHkUxtCLWlB7mi1EdkuYSDTW6AeR5PAEhQx aTblEPTwfixFxmrHhFNLS6fRf4tOVYdXmLbnUTnF76/Vt3aL1mB35xMHm+INR9bZKjXph W2+YxiNsZzSh0VjXFws9ShDCa0d57fjn0fR4y+zGI8vdG9CTzXZisK4LeP6IgsBC5Ew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nVOOiuxO; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EABF8606A31E for ; Tue, 24 Nov 2026 22:01:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=nVOOiuxO Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61FA01F000C0; Tue, 24 Nov 2026 22:01:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557664; bh=NQ6O6I9lgWJkoD59oZb2bESSWFObxrQ4jdNicUxSFHg=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=nVOOiuxOMbm0tIYBFEWkEvlC/g3vS23N3rfr01ailwJJxqVT2+TYTLZXsyEWmV8pY AwLjmYJZB1hQAlnaKb1Qi3DOijJIj0ZZZ4T8RI/AVXyc2Yx3miMLMfsbcanaDz8aGn T+twlRpyU26dTU/0PNqlv/5R3qr+9OgENegNE6z4g4AnCcKSNiaxZjGZoswQF6Jm4w lWp2DPsyLGYMnIxPOWIG8RqE5fPd7I5Pqksi0xek84M2r7bbWOuFSTPKxR8S/AGImn Wti68SNRPE201o9lQygc4lgC7wPuK4U5xFeyhzJRzWkHadjAesS7v+HT+mjs4eGEBm ohIeLuIiZ9KSg== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:23 +0100 Subject: [PATCH mptcp-net v3 06/50] mptcp: reset the subflow on abort after fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-6-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3572; i=matttbe@kernel.org; h=from:subject:message-id; bh=v1bW90uvKg98FPN9It079PjRN2cAgOXqW1SJbeBurgg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH6JayntX7aL54Jae1yyb4vGFI5HtV/qG/m2dt7UU 2Z/xXSio5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCIunxn+F8efmjTVJNeg7+7z xIVSpVYHD1n7PF90f/Gxz3WB7xZ/OcXwh6N0b93BuzuCJE9fdjPyWd4u9fSz+VsXry8/S5OC1tq KcgIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After a fallback to TCP, closing an MPTCP socket with unread data, or with SO_LINGER and a zero timeout, did not reset the connection as TCP does: the data still in the MPTCP send queue was dropped, and the subflow was closed with a FIN. The peer then got a truncated stream, followed by EOF, without error. mptcp_do_fastclose() sends a reset on each subflow, except after a fallback: send it in this case too. No MPTCP option is added after a fallback: this is a plain TCP reset. Its other callers, on disconnect() and when the close timeout of an orphan expires, were already resetting the subflow after a fallback, via tcp_disconnect(), in most states: the reset is now sent as without a fallback. When a listener is closed, its MPTCP sockets not accepted yet then got a second reset from tcp_disconnect(), as already without fallback since the commit below: move their subflow to TCP_CLOSE after the first reset too, as done for the other subflows. This has been found by an AI code review agent (Clashiko), and confirmed with Packetdrill, by counting the resets: two in both cases, one with TCP. This issue has been found by an AI code review agent, while reviewing another fix, and confirmed with a new Packetdrill test: an MPTCP client falls back to TCP, receives data, and closes the socket without reading it. Without this patch, a FIN was sent instead of a reset: v1_connect_tcpfallback_close_unread_data.pkt:19: error handling packet: l= ive packet field tcp_fin: expected: 0 (0x0) vs actual: 1 (0x1) Fixes: ae155060247b ("mptcp: fix duplicate reset on fastclose") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent v3: no second reset for the children of a closed listener, also without fallback (Clashiko) Note (Clashiko on v2): with SO_LINGER set to 0, a subflow in LAST_ACK or CLOSING gets a reset, while TCP would only drop the unacked data. --- net/mptcp/protocol.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f28262f07282..bbb28f778d81 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2738,6 +2738,10 @@ static void __mptcp_close_ssk(struct sock *sk, struc= t sock *ssk, subflow->lent_mem_frag =3D 0; } =20 + /* also before accept(), not to reset again in inet_child_forget() */ + if (subflow->send_fastclose && ssk->sk_state !=3D TCP_CLOSE) + tcp_set_state(ssk, TCP_CLOSE); + /* If the first subflow moved to a close state before accept, e.g. due * to an incoming reset or listener shutdown, the subflow socket is * already deleted by inet_child_forget() and the mptcp socket can't @@ -2756,9 +2760,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, if (dispose_it) list_del(&subflow->node); =20 - if (subflow->send_fastclose && ssk->sk_state !=3D TCP_CLOSE) - tcp_set_state(ssk, TCP_CLOSE); - need_push =3D (flags & MPTCP_CF_PUSH) && __mptcp_retransmit_pending_data(= sk); if (!dispose_it) { __mptcp_subflow_disconnect(ssk, subflow, msk->fastclosing); @@ -3268,10 +3269,7 @@ static void mptcp_do_fastclose(struct sock *sk) mptcp_backlog_purge(sk); msk->fastclosing =3D 1; =20 - /* Explicitly send the fastclose reset as need */ - if (__mptcp_check_fallback(msk)) - return; - + /* Explicitly send the fastclose reset, a plain one after a fallback */ mptcp_for_each_subflow_safe(msk, subflow, tmp) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557666; b=Mi+X42a5kNzkienRazN3FTZf9UxD802xMaynwHjkXISqpRC6R0MSSNaltNWSZLlBGCpL mjGPygL9vCn1uBccKEUdUDzNagHvEVzsRlocFaV/46PASat5buNfQzGH0ek1cYA9hTDcn dgRRlHhjC4EUgsGQ81EgTodaKJ4lQ+t4wHQYj1APyGuW5ImK+GUcy18l2I3ZfxtQuRpvJ 4iu84Y/mQ1YN+qd/Ft4Qg3KypH/kfi77bGVTWSXVzuSoiPnb7QvoqWz9cjp523vu0VAyo oogMnJ+Qci3xd2/INGsE7FxFBblJjd/SAN9qjyz/8DwY2LZYrg+bhxhILZt8cmtteTg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557666; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=NC8NjKXPPOZb89SBcxp2L8Kabw77plC0RF/TOei9Alo=; b=pA1vFS9uCGKIXzMno2usEqQW0At45osjqMdKO9Qj6wDxT+n+9yvuGy6K2s02V8sq26JN Tmdss2EJxh8MiABccqZbnf/yO1nZojG7Yl4kxrqPr2XBsiD8e5we1EPF0ZtEW6esPZ3of rYQnm0YbOJ7xfCP5c8J/fqxmNoZos9YvvajCN7wXOriNX0TBiXmSL2RF0Z0ZQ9s/+DPvX rZfPvx2/5KT6YQIH4TvEz1dliC/5haGc2WHNUfDFwiEHrvhf9MvCg2MQWTvp8TxgcFEo1 Lb3OC+QEGmoupGj/y2aZm8enqSwHFuKEtnCoZ7QF67/vnZrDAOyKJbpKYdJsKKxzkUQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yl5Fjbpq; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D777B606A323 for ; Tue, 24 Nov 2026 22:01:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Yl5Fjbpq Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8F13A1F008B2; Tue, 24 Nov 2026 22:01:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557666; bh=NC8NjKXPPOZb89SBcxp2L8Kabw77plC0RF/TOei9Alo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Yl5Fjbpq9NS1BT8L2LNTnylxMG9uL+2NHL3pw1bo51xGqiSUJ3pWC6KZen8njEMVE 7tmShPDu7MUjbD6GyI24ubvkdeWMnreIA1ogYpHAfTmboNlkSZom3NjR99v6f3wGov Sg37Njb+ACTXublwOWAG4qXLokX1mDonO6HVmsK1Q1JRReVne2+tLKLuKi9aVKtBsX Pij9uPPhjmbtlkQURs46+k081HMGtxy1/e8lUJxQpR13qaK5n91OFR98zPEISjt2YU yY7ymPjHyG06SIlacUqnuVovGtTeemh/Za3tU8ld7FXjBUndyEHOxgnjcbyosmY1QV MBSWOxOPd0v9A== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:24 +0100 Subject: [PATCH mptcp-net v3 07/50] mptcp: wake up blocked senders when no sf left X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-7-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2404; i=matttbe@kernel.org; h=from:subject:message-id; bh=potabgVVuKyV53rWviiJ5aw/44XrcNt/e+Efyw6woVc=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH7ffDJ7iUTAdMV/Mw5bXH8/Kz/tiKnsyV/+ZqpJb VoVPaaTO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACYSHsHIsMi+2+M3X9aaGuvY zjhzP/YPcyalGft/2pUdEmgw00iVm+Gv/K1e3eKd7BatLhmxj32f1K97ev2KXpvsZlb/ooo6w2B mAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When an MPTCP socket moves to TCP_CLOSE because its last subflow is closed, after the close timeout or not, sk_shutdown was not updated, and no error was set in most cases. A thread blocked in send() was then never woken up for good. Set SEND_SHUTDOWN in these cases: no more data can be sent. The blocked send() then returns EPIPE, as a send() called after the close timeout already does. Reporting another error first, e.g. ETIMEDOUT as TCP does after a timeout, would change the behaviour seen by the applications: this is left for net-next. This was reported on GitHub, with a reproducer: the only subflow dies by RTO, and send() was never woken up, while it returned ETIMEDOUT after a few seconds with TCP. With this patch, send() returns EPIPE after the subflow timeout (like TCP) and the close timeout (by default at 60 seconds). This is also validated with new Packetdrill tests, with the close timeout, and with a reset received in CLOSE_WAIT. Without this patch, send() stayed blocked in both cases: close_timeout_blocked_send.pkt:24: runtime error: exiting while a blockin= g system call is in progress close_wait_reset_blocked_send.pkt:25: runtime error: exiting while a bloc= king system call is in progress Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up") Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/648 Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for issue #648 reported on GitHub --- net/mptcp/protocol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index bbb28f778d81..d54ca367fc39 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2814,6 +2814,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, } else if (sk->sk_state !=3D TCP_ESTABLISHED || msk->in_accept_queue) { mptcp_set_state(sk, TCP_CLOSE); + WRITE_ONCE(sk->sk_shutdown, + sk->sk_shutdown | SEND_SHUTDOWN); mptcp_close_wake_up(sk); } else { mptcp_start_tout_timer(sk); @@ -3330,6 +3332,7 @@ static void mptcp_worker(struct work_struct *work) mptcp_do_fastclose(sk); mptcp_for_each_subflow_safe(msk, subflow, tmp) __mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0); + WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); mptcp_close_wake_up(sk); } =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557667; b=oaZQ9tO13RWbDdGe7p2qZDMCREC2RWEmveGFc/1JoN/1EC+qI3z5l8v3tUp0dKOEFvls bbm89NtxBCOcvntUTSiCUSIBALxs7LbUJFEpTTgdbXXvyOFp+BRfjAyJU1B5ZlrDKIiIq T0Imo4a+jUnGJnnOh762DNrv6uo9DoEp7t4FEisb30pAn2VAU5GQ84X0J3DVsV5PI00Jv fS83Fs1B5Fu5wg8BcnQI1uOUtvGcPfyOqfOE1aLSUKE1udmTY7Byllc8sYzSPFhLDfUWn fOmgo8wubY7FehCqr5+U57dTJPK4fQYhQ1W5/CfXU1ywUrGhCc/yrjO3uykXdfztILw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557667; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=VETGxmR8wNKj/imU7IijmkgeBkHY+lhHhlHq0BILz+Q=; b=CaQbdODjhRRFZg0Xm6jLZYpxFBcD2lzFPK+PYEbpA1GV6YAP0f655T1NbMYJo8xsg138 55zCV78bveaJFfzVHdlUgrX9GIBYnyNOSou8jCA38nW1ujVAbo/kkU1gesFK6yq1KTplL X/J6Pzn+Bu83yowriagsSKLKQiv1QgF+wy9A2azGJvXtSeNcbSAo+6MJEQExeeZvE1eAB omBJTYiP5Znc45Q60ItBQdxz6GXhzu7sCc9gOw2HGhd7vShjVKSG+PxkW045/C0CFvDj2 lamudgcOcRbW8DMpanBgqbYYPHOF6evicX/PMFyQ++fQjRe+22PuxUi3l9Y/Drq44Eg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hEK68anu; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB9B1606A329 for ; Tue, 24 Nov 2026 22:01:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hEK68anu Received: by smtp.kernel.org (Postfix) with ESMTPSA id D3E281F000D0; Tue, 24 Nov 2026 22:01:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557667; bh=VETGxmR8wNKj/imU7IijmkgeBkHY+lhHhlHq0BILz+Q=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hEK68anubg8f5mUT3BRs9ulFNNuek+yS97+ZU/rwAONXoQUTMZol/crxrbOKvaNKR YM1eAw9MmYOTt7+EO9ie873qP/LqkZxZHq8XErFDqoUhnKz0fZ1Gym+QgOuuW27CK1 jRsKM880UfoRObTWECeR+JHPYzpdSiWY7dlJMfGeHibqJBu/H93TJKBwaHDHycPKM9 iLoUwjnBiwa3NgC8AQo15OV8fJzxUKkmTJDjifX0cWgEUGUszNYUrWVAA+4obrwlYa AlOdAAli52eag7ZOOUS3pgFAs306xUZCRiJWHjBeQtS/HlMPbHn0M56r+gpVmpJW2j QS7beq2gd/ppw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:25 +0100 Subject: [PATCH mptcp-net v3 08/50] mptcp: set SEND_SHUTDOWN on close by an sf error X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-8-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2263; i=matttbe@kernel.org; h=from:subject:message-id; bh=w/V3HpV0/PH+pPe5qMiv6etcBkbZVYwqmw7fMpP+OZM=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOH5HnNzypv/e2qvyKefC4/h471jFha8RaJMom8n10 e68n+zljlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIkoFDD84Tjy3+gRt5LDhFSd hQ9mTii+9W56oreWw9rcmT43Tr4ymcrwz3x7YMKUxfoWkfMMbkz8FNmaOcn53Zvox+GqaouOn3J czgMA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After a fallback to TCP, or during the MPC connection, an error on a subflow is propagated to the MPTCP socket, which moves to TCP_CLOSE. But sk_shutdown was not updated, while tcp_done() does it. A thread blocked in send() was then only woken up by the socket error: if another thread consumed it first, the sender went back to sleep, for good. Set SEND_SHUTDOWN here too, after the error, as tcp_done_with_error() does, not to have poll() reporting a close without error in between. Setting RCV_SHUTDOWN, as tcp_done() does, would change what recv() returns once the error has been consumed: this is left for net-next. This issue has been found by an AI code review agent, while fixing a similar issue, and confirmed with a reproducer: after a fallback to TCP, a thread reads and another one writes on the same socket, until the peer resets the connection. A part of the writers were then still blocked in send(), and none with TCP or with this patch. Fixes: 15cc10453398 ("mptcp: deliver ssk errors to msk") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for a similar issue found by a review agent Note (Clashiko on v2): the comment in mptcp_poll() names __mptcp_error_report(), not __mptcp_subflow_error_report(): pre-existing, can be fixed in net-next. --- net/mptcp/protocol.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d54ca367fc39..d1bbba582aa1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -979,9 +979,13 @@ static bool __mptcp_subflow_error_report(struct sock *= sk, struct sock *ssk) /* a FIN received before still leads to EOF, as with TCP */ if (sock_flag(ssk, SOCK_DONE) && mptcp_pending_data_fin(sk, NULL)) sock_set_flag(sk, SOCK_DONE); - if (ssk_state =3D=3D TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) - mptcp_set_state(sk, ssk_state); WRITE_ONCE(sk->sk_err, -err); + if (ssk_state =3D=3D TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) { + /* This barrier is coupled with smp_rmb() in mptcp_poll() */ + smp_wmb(); + WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); + mptcp_set_state(sk, ssk_state); + } report =3D true; propagated =3D true; =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557669; b=OTcm38DHlr1MLff0EC3N76eSYz+YfahmQgrKdDiAlJZEV6yuOJv5+S41jfn2ItU63JJM LgfHTT5RyUA0M2n59Rk/jkCEZLqQLMrgtkjes5m5NuL7jj6GSnqkcKVz6YCAcv1wW3/Z+ SGAETb5wBHwuUoCr7EDEcdlFy/pWl6d3Ci755GisCOSfwgXf6X1VJvtpipV6+PiaLv6i/ AvEjARnsMx81LaagoFn8UuzUxNclhE3t5Ns6zB9NAbrTsGEkYNwO+S498onqDNSKbvUqe /FfNElmwyq7IRe+YhCcmWd4LctbGRvn/aOSs1S5Uzj07iVo6oeKHqs944q0ut8h7iHA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557669; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=O4aCcBi7Us3eM0HBea8VkJSovXuzIfvbDTIVlAQcp6M=; b=HVWMCAi3h1O7MhStN6jEPOCCDrB5uVnLIwb7GRupR8MhBDbm9UncVdE/o90Jv3GxumlQ zjHTICqYWP6AwnlLiYNRIhqdORAlwGQsIdCu04Y+wbniMDGfwxGufq0e7JQPEuQ7uLB16 rSWd8nolGK414++MZN5NYofsdXg73m4Ti6ifMphs458xxRAiptxhoteJCkqTHJdH0b5Vv xQ0tFIrjS+CmcIHHHWQozDqHYl6POzRCCujApZp3uxfU9BV5ysTe7VVOSVsG9Se6ods/9 8P1+g9bS1/gphn5Rqs0bhVlCSXjshL6oNQ97X/vEMEdBJCAWmXBtBuy+w6xkSZOarhg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TOWsMCy7; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C85C606A31E for ; Tue, 24 Nov 2026 22:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TOWsMCy7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F33A1F000E6; Tue, 24 Nov 2026 22:01:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557668; bh=O4aCcBi7Us3eM0HBea8VkJSovXuzIfvbDTIVlAQcp6M=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=TOWsMCy7JCe9E6n9bsAWmt3VvjXR1Fzdw7IBusTrjgNcVdwDrjC2Ayl6tpghBcHHG qYmbrwBnJw0ZLhCi+L19svndMgqcWaDb7467R6+hm+q/7jiV5ZOEcMHyPJdkuOmLD6 VE874eRdza4J7xgZJgf0rHc8u3zdsqS20Sa+Xs2/nuyZbXGk/iTWhWddrOXUxEMNKt v3XAZBsMguz5QfWPM7sPRlgRUHgj1McTmKmjr0Hs2Nv3AmagaTJLaLHUbNI+GsM6Qh KIxs3qVhtAvOtNOJuiFqWOeV9z1DWD9PmWGUNwqyh0BKiRX1f0/BYMFUlLWnYVQZa7 VWIaQO7IDCVmw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:26 +0100 Subject: [PATCH mptcp-net v3 09/50] mptcp: start close timeout on initial sf shutdown X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-9-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2601; i=matttbe@kernel.org; h=from:subject:message-id; bh=RgJwaWW1PfaKKNjalkD7LKS1JrMYSgMagVuVNS0UEwY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOP40XP9VJVWQE51uw3pysfhNn63XZzumpjYoJs1a6 Xr2YOvKjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlMWsDIcJXXoLhq2azF/Sqn Vrpezu5y11X8yfTlz5Zmj/+Vp+5N3MrIcKzjcV7RkQ1X9zPoc8x53rvhu3Q9328X+fKOezH/NIJ 0OQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When the initial subflow is closed while it is not in TCP_CLOSE, e.g. after a FIN without DATA_FIN from the peer, it is only shut down, and stays in the connection list. The check for an MPTCP socket without subflows then missed it: it only looks for an initial subflow in TCP_CLOSE, and when this subflow reaches this state later on, mptcp_close_ssk() ignores it, as it has already been processed. A socket still owned by the application then stayed without any usable subflow, without close timeout nor error, and with blocked send() or recv() calls, for good. When only this shut down initial subflow remains, start the close timeout, if it is not running yet. This issue has been found by an AI code review agent, while reviewing a similar fix, and also reported by Sashiko. It has been confirmed with a new Packetdrill test: the peer closes the only subflow with a FIN, without DATA_FIN. Without this patch, send() stayed blocked: subflow_fin_blocked_send.pkt:26: runtime error: exiting while a blocking = system call is in progress The check only looks at TCP_CLOSE since the commit below, and mptcp_close_ssk() ignores this subflow in this state since commit d82809b6c5f2 ("mptcp: avoid duplicated SUB_CLOSED events"), which is in all the stable versions having the commit below. Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent, and Sashiko Note (Clashiko on v2): in the accept queue, a new subflow can still join during the timeout, and the first subflow is then disconnected, as after an MP_FASTCLOSE received before accept(): checked with Packetdrill, no warning. In the other states, the subflow is only shut down: it can still receive data and the DATA_FIN. --- net/mptcp/protocol.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d1bbba582aa1..5d916c6b43f4 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2824,6 +2824,14 @@ static void __mptcp_close_ssk(struct sock *sk, struc= t sock *ssk, } else { mptcp_start_tout_timer(sk); } + } else if (list_is_singular(&msk->conn_list) && msk->first && + mptcp_subflow_ctx(msk->first)->closing && + !inet_csk(sk)->icsk_mtup.probe_timestamp && + sk->sk_state !=3D TCP_CLOSE) { + /* The initial subflow has only been shut down, and its later + * close will be ignored: start the close timeout now. + */ + mptcp_start_tout_timer(sk); } } =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557669; b=30FKgzl1bw6KhmDBV3CkpWRFSY6sftLPspjClcUoZlAy2R2nPyvL5VBcy+DbqCNxbqzl GeaxIHNaSwEKxyGVl0rgaUU9+Uk71V1Da7LBLQ/WhDCzCwLZYD2Frl5HWLPbe1zzEfb+J GTxGC1WeSY88hJ7w/Q3C5V2y+zVvkrkzGYZsAMki5oBWQCGHtjCWN5JBdpBFacV9NapVd SEdrFIu1gKghuu7sqLrdR1AaEo+sffkNhr+4uwnpUbBhdOGZPkR3xiiKnQMZV1/qo45TS EAfUGkHbh9oYM3SeHerrRIV1QbaLpsoQn5QK3gCXHdPyCD4rfcXL9pF9FCF5utjUZ0Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557669; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=5MXjjCYi0kU2V79M8/mlLVoULyEwG5FsbNe6gY2BWAI=; b=T1YLeID1aCozUhohsDYe/qmA769Gei/K3Io9iO5fggwFYvdBiKkGHqYrLwVMbYqUY3t4 dHgd2qhM3rIYwOFj/dxavUDjMO/xbau/SOKddM82lZOIv0r/IBFAAc1PS7n+xUU+LkrZA br0y5HNJm6eJ3p5ro1emLP7zUQWVvi/6JC//5jl23stjyNH6b0VJ1i++IB0AvOwk9IyZq 8WZmYi1egiVgqjADP1KPEfEcv1AymQLD0090SCiJTzlvs+EfYdJRkrHyKYu+uE61PmnLE kMe1iY1UyCMja4MGptc7icXYhif/FCOcaoKa0fzaY5yiZYhp5oBvM0zp9AahG+CE2jA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hD86A4Wn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D8CA6606A31E for ; Tue, 24 Nov 2026 22:01:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hD86A4Wn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4B6D81F000ED; Tue, 24 Nov 2026 22:01:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557669; bh=5MXjjCYi0kU2V79M8/mlLVoULyEwG5FsbNe6gY2BWAI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hD86A4WnnYNl071ZUPOZ0BgTE68kOICvWY1S2/DQpMNt6+0AlbYq/MIKePZsHhADv L3HPLKvHJLXCLCSP0D+Jr9tSIQ7tUOJXKWdaaGYxQfd9fDnqkUarWdGn3HiUYfCkTj 0HM6B0R/FsKwgW8g3O8XJ8AWfK7o3euVdRTPA00akEqL+jsDMRr/f3xk3W52DTFlJq CfdBj24jvhIFCb1BR7RVbNZjcnD6NaP0zqJdCx0iB1sd9o7DXLc0YitGVyiyeUYQP4 SB/GSsoRKdsu8uHWoHy+a8ex9dNrKWP5EktUPSjwLalCLYDU0NRcwA+dyBCQlmv1jg 2qbJzQ7Y8PjNA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:27 +0100 Subject: [PATCH mptcp-net v3 10/50] mptcp: process a DATA_FIN received with old data X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-10-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3770; i=matttbe@kernel.org; h=from:subject:message-id; bh=a9g9eGPIvFmUAgiGS0NsexER9+XsB2NR6/Rw/c7K7J8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOP68sHt5gZMh95n9XzfFOzL1XhfmTpuQ5XjllvMb8 cy583dO6yhlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZjIgQcM/9TfrGF+UzWNc+Uf hjbzmn/Ja7XnnP8bP/91ANtl8SWeztmMDHOPuTRF8Iaqt1gc+c4kUHPCLeVTaUt6fczX+HPajom 7GQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A DATA_FIN received in a DSS option with a data mapping, or without data in the middle of a mapping, is recorded by get_mapping_status(), but its processing was left to the code moving the mapped data to the MPTCP socket. If this data is old, e.g. the last data retransmitted at the MPTCP level with the DATA_FIN, it is discarded at the subflow level, and never moved to the MPTCP socket: the DATA_FIN is then not processed, while ack_seq has already reached it. Later retransmissions of this DATA_FIN are ignored too, as it has already been recorded: the peer might then never get a DATA_ACK for it, and the reader the end of file. This issue was causing a subtest from mptcp_connect_mmap.sh to fail, after a spurious MPTCP-level retransmission from the client (MPTCPRetrans on the client, DuplicateData on the server). The server had received all the data, its ack_seq being at the DSN of the DATA_FIN, which was retransmitted 9 times by the client, still in FIN-WAIT-1: 26 ns2 MPTCP -> ns4 (dead:beef:3::1:10023) MPTCP timeout (...) mptcp ESTAB (...) rcv_nxt:17234557033099169620 (...) (...) mptcp FIN-WAIT-1 (...) write_seq:17234557033099169621 snd_una:17234557033= 099169620 (...) retransmits:9 (...) (...) (duration 61384ms) [FAIL] client exit code 143, server 143 The root cause has been confirmed with new Packetdrill tests: data is received, then the same data again at the MPTCP level, with the DATA_FIN in the same DSS option, or in a DSS option without data, in the middle of this mapping. Without this patch, the DATA_FIN was never acked: dss_fin_after_old_data_server.pkt:23: error handling packet: Timed out wa= iting for packet dss_fin_mid_old_mapping_server.pkt:22: error handling packet: Timed out w= aiting for packet To fix this, schedule the worker when this DATA_FIN is recorded, as it is already done for a DATA_FIN without data outside a mapping: mptcp_check_data_fin() then processes it if ack_seq has already reached it. If not, it is still processed once the data before it is moved to the MPTCP socket. Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue causing a flaky selftest --- net/mptcp/subflow.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 054ee992904e..67a749643ad7 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1242,6 +1242,10 @@ static enum mapping_status get_mapping_status(struct= sock *ssk, bool updated =3D mptcp_update_rcv_data_fin(msk, mpext->data_seq, mpext->dsn64); pr_debug("DATA_FIN with no payload seq=3D%llu\n", mpext->data_seq); + /* The current mapping can be old, and then not moved */ + if (updated) + mptcp_schedule_work((struct sock *)msk); + if (subflow->map_valid) { /* A DATA_FIN might arrive in a DSS * option before the previous mapping @@ -1252,9 +1256,6 @@ static enum mapping_status get_mapping_status(struct = sock *ssk, return MAPPING_OK; } =20 - if (updated) - mptcp_schedule_work((struct sock *)msk); - return MAPPING_DATA_FIN; } =20 @@ -1266,7 +1267,9 @@ static enum mapping_status get_mapping_status(struct = sock *ssk, if (!mpext->dsn64) data_fin_seq &=3D GENMASK_ULL(31, 0); =20 - mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64); + /* The mapped data can be old, and then not moved to the msk */ + if (mptcp_update_rcv_data_fin(msk, data_fin_seq, mpext->dsn64)) + mptcp_schedule_work((struct sock *)msk); pr_debug("DATA_FIN with mapping seq=3D%llu dsn64=3D%d\n", data_fin_seq, mpext->dsn64); =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557671; b=NUvfmexg1cvQeo8eiBU/KC3FMezffKAKRjebC/qGROt9vxzd8FiFpitGPOm/akSAftyk 3cEUEPN2floeaB30weK6uFqjM96COdQATVF7B8L11l/m7jt4LUXpISGegsWM8u4dh+CIC 9UYKjaiYhxyJP10tryx4oMLtUCrkVodx+FX0vQshaMqPMF5PpefCG4TIW2eZGImqO0Jdv /BW9SUq7VyqX6HWtwWjFdpr7dIl2CgRfVty1ujG1caq9kh33kBu+rnhZJWxn5iJ+IQPyu yLwhKWFIj1wHpvPhv0w9xDrOP9OCxXofbckHLOPxlnP2PED4wrSTQjzcWjDMxBbHbOA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557671; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=rPxPQclKiW2EVNCZiqrq34x2rST1mhnPEAYFIGQVMYc=; b=Yfbbg+d7i5XxrSqZMTd+XTtb4HWTsR4DYBGxIbcjj/wnDrVDjdbW+iMhDRrLV3e7iYkp VHswhYKSX4eQCDOaGSYR4UVBKYPZb6hlGa68xrHVlYKqwl3GRgIdddD1kb1uSGcGH2WCN M44eUG9i7+pXwk5t3h4z16Ki4Eu/9+NewFQ0fCcNdLqD18RQ/onFPa31k4f7OJppKpAzS UDigVJW3O/M5Nkr45GNW5fD1KOtVHwsER+TB2iWKuOQOxnugK1gVCNfSoGUJE8XcvWnle jzZ3VhZzVLoHUIU8NhwJl5zsqfrudEUk/93O2Rk1VeHabflicvyLSmYKiwKsOZihGng== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jFIA3ck0; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9766B606A31E for ; Tue, 24 Nov 2026 22:01:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jFIA3ck0 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7CFE1F000D3; Tue, 24 Nov 2026 22:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557671; bh=rPxPQclKiW2EVNCZiqrq34x2rST1mhnPEAYFIGQVMYc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jFIA3ck0wLbClF9WL1UPm1W7OELN+OsZOrjVSz1ab6naSB5f03Ok4QvXgAgApTmF6 OUHUSSHnQLL0eXA3iI8dOpJcY7tPaUv67qtseA+iejzy3UCUDjv5/qFzZtcn0f1wJy h0ROxyRPvZbnWsiESYz6shlhDdHu1FzQFy62fE786Ifh3R/6bO/UUU4n5W51b0zsz5 NgMnfuH5PAIWbCUM0/hv98m/hgLZMs5DpKTvPh5ZV77J4UPgIcVk5yQQXLSBTqfiHo ZFzuWKX/6KMWSOaOu4FCVygBX3CA7qEWfnma8K4Rt/gicQIQvaNfrh66UQKVi146/2 2uuGskujWJJGw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:28 +0100 Subject: [PATCH mptcp-net v3 11/50] mptcp: no sf left: process pending MP_FASTCLOSE X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-11-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2933; i=matttbe@kernel.org; h=from:subject:message-id; bh=C0khbWlxGL96vW0fnBJpjSLxRBsgg0OWgwwimB7nmpM=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOP5WFK95ULbn7mZGnrubap6xzp7smH//vt57/pv1B uXvrpwX6ihlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZhI6AdGhp41dy3exBYcjLhw q8suzkss6Yt67b3J/pdzjldcPmRyxIXhn+qK1+e2zGIRipfhOhL5//Dxr/UBzj+un5C3cth/217 zHzsA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When the last subflow is closed while the MPTCP socket is no longer in the ESTABLISHED state, e.g. in CLOSE_WAIT after a DATA_FIN, the MPTCP socket moves to TCP_CLOSE. But this subflow could have been closed by a reset carrying an MP_FASTCLOSE, not processed yet: if this reset is received while the worker is running, after mptcp_check_fastclose(), and before __mptcp_close_subflow(). At the next run of the worker, the MPTCP socket being closed, the MP_FASTCLOSE is ignored, and no error is reported. This issue has been observed with the "fastclose test" subtest from mptcp_join.sh: after the DATA_FIN from the client, then its MP_FASTCLOSE, the server, still having data to send, was killed after the timeout: [FAIL] client exit code 0, server 143 Since commit "mptcp: wake up blocked senders when no sf left", this subtest no longer fails: SEND_SHUTDOWN is set in this case, and the server gets EPIPE when writing, which is expected there. But the reset is still not reported. This has been confirmed with a debug patch keeping the worker busy until the subflow is closed, and Packetdrill scripts sending an MP_FASTCLOSE in this window: in CLOSE_WAIT, SO_ERROR was 0 instead of EPIPE, and poll() did not report EPOLLERR; in FIN_WAIT2, read() returned ENOTCONN instead of ECONNRESET: fastclose_close_wait_race_err.pkt:26: runtime error in getsockopt call: B= ad getsockopt optval: expected: 32 actual: 0 fastclose_fin_wait2_race_read.pkt:28: runtime error in read call: Expecte= d errno 104 (Connection reset by peer) but got 107 (Transport endpoint is n= ot connected) To fix this, process a pending MP_FASTCLOSE before the close, if the socket is still in use. Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue causing a flaky selftest v3: msg: the subtest no longer fails since patch 7, and the remaining issue, checked with Packetdrill (Clashiko) --- net/mptcp/protocol.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 5d916c6b43f4..bcdad00d3573 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2705,6 +2705,8 @@ static void mptcp_cleanup_ssk_backlog(struct sock *sk= , struct sock *ssk) mptcp_data_unlock(sk); } =20 +static void mptcp_check_fastclose(struct mptcp_sock *msk); + /* subflow sockets can be either outgoing (connect) or incoming * (accept). * @@ -2817,6 +2819,9 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, mptcp_schedule_work(sk); } else if (sk->sk_state !=3D TCP_ESTABLISHED || msk->in_accept_queue) { + /* After the close, an MP_FASTCLOSE would be ignored */ + mptcp_check_fastclose(msk); + mptcp_set_state(sk, TCP_CLOSE); WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557672; b=X2TYFtgk3CIaAhJ0pQYhouoSUdbEjdLehdQHXLhPSZfOV/a38aUaE8yybpkNy1K9lWEr 2IBh0agddzXH8QavWpLa4nVgZdxAWfpCRULeUg9rqTp0jg1kuCWdYLg3sJ/+VlXt6iAf1 LdKSDnKFTmV1UK8v9tygYW1w8kk7j9loo9m1gqeqEHyT1j5etUrpYBeqzCAct9uTvbHbE wndaWWXOXRlfCpLPwEBBP4wBVxQRJyNU+VDUbN5J+180hxnozitbeW+0a7EAO/Opbeg+q KeZsJn/pTFz/NoFKi5tWxosDfAm4pvpXKPScs1VGvcAyKNFRu8xi1YZSO9ZvnnYGSUg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557672; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=WgH5XgY1Djciv5KFz4pWoYan53BwFSdZTREbmhskrPI=; b=jbI/Jg0rVBRjWiElTNr3ORyqUgrjkmVTfTvaDc4X+hPb5iFRcRLewfLG6I2gDIU46d8F kMGh7LY04kl5pkTYVzuAhPd9dYpyLS3YnQ6dvSAquuXeh8q9cUtjOKiziR8nLHzKbHvtu f4OrZC4UpCTBcKgVoI2FPggDgQ6lLPq7/6xwjUVXRR54qA4sDDqmLe+NlQCtvfXs5DPra 2MG4QalBOStEbWgTSvkdDgOY0p/R5TZIdlPUA4lXUmuO4pwSMlUxtPVq4cKL74xG7+5SG rUfIrMHAaqkWhvUY+Kgzp0gpi5UUPmrVkuu3EOj2eOi29wM9mtNlYZIaKTX9JHNe6RQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TgTvWMbF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B60C7606A31E for ; Tue, 24 Nov 2026 22:01:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=TgTvWMbF Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD8011F000C0; Tue, 24 Nov 2026 22:01:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557672; bh=WgH5XgY1Djciv5KFz4pWoYan53BwFSdZTREbmhskrPI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=TgTvWMbFNrWUpycdmOTnmvVWfMVdIsoJeIWEOXysTKXCtprHWXFdS8/oK0Tgxq8KU yj0DHjoyzXnvRDjCzB5bFziyPmB/cdIcuWt840mdl7x3CFwvvGbeyqRvt6RVizdbK7 4Ov8iCD23vXIotF+peW5OIdeScuInA/xymjBDNF/gERhWyPGsyxhO04NUeazslh4p2 c6XK1I1uFVtGGlWSrjkvtNIqTV4VWShPAgFmw0hKkOLGgG897fF5KnET2jg9TU6WVc fgai+vBCxitYuz5uZJgD7Zk5/MW9iVvSNjlE0kIo69AxeONUTexFFbKwLHXQHv2i3W gp7JNhl2QeCIA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:29 +0100 Subject: [PATCH mptcp-net v3 12/50] mptcp: no sf left: process pending DATA_FIN X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-12-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4393; i=matttbe@kernel.org; h=from:subject:message-id; bh=VGzsF4nB27A7cEMNCANNCJeD3maaX4yxvNjMnkdA6K0=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOP5NDXt5YK7FYS/ZxyI/Nn89+uveAaHEWbquPAFyc 6fF77nW31HKwiDGxSArpsgi3RaZP/N5FW+Jl58FzBxWJpAhDFycAjCROGeGv0JrC78VT5sXUDdf ebfJuSfNWqJzWyeyywm66K9qeM/Qe5Dhn9oKR9mpJzQWGWrNeTTxmFB6YvrU05bHJM/birDKyE4 IZQEA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When the last subflow is closed while the MPTCP socket is no longer in the ESTABLISHED state, e.g. after a shutdown(SHUT_WR), the MPTCP socket moves to TCP_CLOSE. But the peer's DATA_FIN -- or FIN, after a fallback to TCP -- might not have been processed yet: e.g. if the last data was received while the worker owned the MPTCP socket, this data is still in the backlog, and the DATA_FIN can only be processed once the data before it is in. When the backlog is spooled later on, mptcp_check_data_fin() ignores the DATA_FIN, the socket being closed. RCV_SHUTDOWN is then never set: after the remaining data, poll() reports EPOLLHUP, but neither EPOLLIN nor EPOLLRDHUP, and recv() returns ENOTCONN instead of EOF. Before the commit using the MPTCP-level backlog for the RX path, the data received while the MPTCP socket was owned was left in the subflow, and a subflow with data in its receive queue was not closed. This issue was causing the "Infinite map" subtest from mptcp_join.sh to be flaky: the server only got EPOLLHUP after having received all the data, and spun until the timeout: timeout (...) tcp TIME-WAIT 0 0 [::ffff:10.0.1.1]:10123 [::ffff:10.0.1.2]:5= 1790 (...) mptcp UNCONN 0 0 [::ffff:10.0.1.1]:10123 [::ffff:10.0.1.2]:5= 1790 (...) (...) fallback (...) bytes_sent:131100 bytes_received:131100 (...) (...) [FAIL] client exit code 0, server 143 The same issue was causing the 'peek mode' and 'full disconnect' subtests from mptcp_connect.sh to be flaky, in the MPTCP to TCP cases, so after a fallback at the connection: the client never got the end of file: 64 ns1 MPTCP -> ns1 (10.0.1.1:20002 ) TCP main_loop_s: timed o= ut (...) mptcp UNCONN 0 0 10.0.1.1:35046 10.0.1.1:20002 (...= ) <-- (...) fallback (...) bytes_sent:714380 bytes_received:714380 (...) (...) [FAIL] client exit code 143, server 2 The root cause has been confirmed with a debug patch keeping the worker in FIN_WAIT2 after a fallback, until the subflow is closed: the same failures have been seen in the "Infinite map" subtest, and in the 'peek mode' and 'full disconnect' parts of mptcp_connect.sh, with the socket closed before the DATA_FIN: (...) closed with a pending DATA_FIN, state=3D5 ack_seq=3D117846435202134= 19601 data_fin_seq=3D11784643520213452397 backlog=3D35484 To fix this, spool the backlog and process the pending DATA_FIN before the close, if the socket is still in use. This is done in a new helper, mptcp_check_rcv_close(), also processing a pending MP_FASTCLOSE: the next commit uses it at accept() time too. With the same debug patch, these subtests no longer failed. Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue causing flaky selftests Note (Clashiko on v2): after a fallback, the FIN cleared when the first subflow is disconnected is now handled by "mptcp: return EOF after a DATA_FIN, as TCP does". --- net/mptcp/protocol.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index bcdad00d3573..b57d0f82b416 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2707,6 +2707,18 @@ static void mptcp_cleanup_ssk_backlog(struct sock *s= k, struct sock *ssk) =20 static void mptcp_check_fastclose(struct mptcp_sock *msk); =20 +/* After the close, a pending DATA_FIN or MP_FASTCLOSE would be ignored */ +static void mptcp_check_rcv_close(struct sock *sk) +{ + /* process the DATA_FIN after the data still in the backlog */ + if (READ_ONCE(mptcp_sk(sk)->rcv_data_fin)) { + mptcp_move_skbs(sk); + mptcp_check_data_fin(sk); + } + + mptcp_check_fastclose(mptcp_sk(sk)); +} + /* subflow sockets can be either outgoing (connect) or incoming * (accept). * @@ -2819,9 +2831,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, mptcp_schedule_work(sk); } else if (sk->sk_state !=3D TCP_ESTABLISHED || msk->in_accept_queue) { - /* After the close, an MP_FASTCLOSE would be ignored */ - mptcp_check_fastclose(msk); - + mptcp_check_rcv_close(sk); mptcp_set_state(sk, TCP_CLOSE); WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557674; b=2Vcw2CvbAKzN1A1Kcb0CPcCPNxKtsPnAQF4oDRk1QkyoyRFj2v+AoXoGAz3H6PKp+LY5 Zffv6xHUwiujDeYfa0uE6ME0FneFTthrJcSfF3u1L+1kQJ7lRdg2YSGw2LLMKxfDn1iif 2S9AhohRYZCB42zU2/gqLtywwSm6Nsli9MKCkz4VvPvYvb3/b0BL9Mjf5eGOk+msGO7Fn pQzo+Vn5SgpiYddViPXFCkJfTotAvSbAKl3IaOFAUknrpetnrP8U4XY2a4em2Gl45LGm/ beBQXLxUTiNsvQ+FZV7wLBXdryFL7qbmcef7tfvEr2x1TcVmstx1yuLJQ6h6OPqBecQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557674; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=J2Pi9VeF/VYEu9eEthqrKh2elfEgGfDuPCcE+HSqs24=; b=2TxZEUebwNec4M3I64xsCs/0+KjQuOHoTnZwN3GVcc2ALz28ktNWuQEYbY3ZQV1V6PGL o9F/qttoFb2Bgf6CCTS3CwU0MMquccVb/5Wg5xp/Jgz0x3M9MkhalCkyIty7XvEkoDSnH HYuh0ZYSWVBfYNK6BjLtILZWpPVsx1+RAcmVXaTWxkcbecrPhMqdD/hpf8YjjKeVbXb7J nGLihMQmI57eMJCRGuIAf7lOtrA3Ce0Om31IhlDnY0753lVeL2XWQgz9aBGsZwysFHRu5 lqIG7G+Zd4Cj+4DS4leyisBXdi5e1lOxR+zJ3B1RKUU941yzwrPrV8GyZc0Ti3LmH+g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kvUEXLO7; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78760606A31E for ; Tue, 24 Nov 2026 22:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=kvUEXLO7 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AC051F000D3; Tue, 24 Nov 2026 22:01:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557673; bh=J2Pi9VeF/VYEu9eEthqrKh2elfEgGfDuPCcE+HSqs24=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=kvUEXLO7X8crew8j9z4FpAiUEWyGNLVTPHerGOoRadIMqAWBhx/mVwkUSN5d4sF3G MqXAmE6gWURa4jIGBRCSuXV4KmGD52C3dL+l1prpjB+duCExavahSoLkVlI8S7NHOe 758i3YeyfGhn6xlzEZDrbe3+imB1BbtMLAzBl4fnLBIBIUjuWt5zJ/MUUaB6Ptpig8 mYIapUOSeCK76Yqbhm3V1YOVF0gu1sUFpnYsJkvDTfBpbO5QvNPVTUZLyZ+YUz0dPo 2v6o7FJNRGIx2vORhu7m541kguoDlo0lN1F68vJQNKJ+g6qZ8+Ut+5aP280fHm5EZl XZ1woHjZS2dlw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:30 +0100 Subject: [PATCH mptcp-net v3 13/50] mptcp: process pending close events at accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-13-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2613; i=matttbe@kernel.org; h=from:subject:message-id; bh=4gz7rOE4zURxO/8snDfO1uDWyhvLGxiEqY9lK6qaKws=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOP6trIlcOiMn1kSgpdH89tdP8969ObQ5aHbs/xlOc 5rcXjjzd5SyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEzEwIuRYYvr9wuztD/JTOj/ O1FbZAfnyfk/7weEiaqtOiyz2f7uXmGG3+zLv4RPP5vrKbA2cb/1+wvvZqQ5e8/T29zTv01n84f wRGYA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When the only subflow of a new MPTCP socket has been closed before accept(), e.g. reset by the peer, mptcp_stream_accept() moves this socket to the CLOSE state, then closes the subflow. A DATA_FIN or an MP_FASTCLOSE received before, but not processed yet by the worker, was then ignored: the code processing them before closing an MPTCP socket without subflows, and the worker, skip a socket already closed. recv() then returned ENOTCONN after the data, instead of EOF after a DATA_FIN, or ECONNRESET after an MP_FASTCLOSE alone, as TCP does. This race has been found by a review agent, and confirmed with Packetdrill scripts and a debug patch delaying the worker of the MPTCP sockets in the accept queue: data, a DATA_FIN or not, then a reset with an MP_FASTCLOSE are received before accept(). Without this patch, the second read() returned ENOTCONN in both cases: With DATA_FIN: runtime error in read call: Expected result 0 but got -1 w= ith errno 107 (Transport endpoint is not connected) Without DATA_FIN: runtime error in read call: Expected errno 104 (Connect= ion reset by peer) but got 107 (Transport endpoint is not connected) To fix this, process them before moving to the CLOSE state, with mptcp_check_rcv_close(), as done when closing the MPTCP socket without subflows. Note for the backports: before v6.19, this helper, added by the previous commit, is not available, and mptcp_stream_accept() closes the subflow before moving to the CLOSE state. Fixes: 63740448a32e ("mptcp: fix accept vs worker race") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent Note (Clashiko on v2): after a fallback, a reset received before accept() was not reported when the worker processed it before accept(): pre-existing, fixed by the next patch. --- net/mptcp/protocol.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b57d0f82b416..8edff68ec650 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4703,8 +4703,10 @@ static int mptcp_stream_accept(struct socket *sock, = struct socket *newsock, * deal with bad peers not doing a complete shutdown. */ if (unlikely(inet_sk_state_load(msk->first) =3D=3D TCP_CLOSE)) { - if (unlikely(list_is_singular(&msk->conn_list))) + if (unlikely(list_is_singular(&msk->conn_list))) { + mptcp_check_rcv_close(newsk); mptcp_set_state(newsk, TCP_CLOSE); + } mptcp_close_ssk(newsk, msk->first, mptcp_subflow_ctx(msk->first)); } --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557675; b=r5L7VWI0GJ1/6+JM+6Y+UMAzRzvjguFVo+H/P/3e9OWhHk5GFFd9C5X1k0HagK6aTtNy jwqPPadIW/ea2IGji1wzOAHiQpYbZQTjAA+mnhHVde1rAjVtbVwFmrfLXiiRA8by3qKOt d4erJjzFSrsV2MeMzA4OW2F4eyOXpGANyItjhNWCOe45Qnn88eD58hZPrDFoavP0GpfF1 AXpVNRekfuYnBMlOZ5oQ3kWncJVzgKdRXa80wQTorHhIG7zNsVVMEw8/MzQbkILZUWO4l IzQFXQ/o1zL6P7c5Dw0wrrOF27+P/3JNX70u5mEWV7jsg3HpTgc6lCG1EXaxBg1ag8g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557675; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=CHg6cLp9gikE6OWNrdw5FOnL2uaA/b4N6CHoNbIqYUw=; b=Ge9slqfdrOdQ1e4DFKt/snMU8zCE9l1KXuMWKG5dUtvAf7pWqaYRFpPEug/hDyQjSK2a xH9E5NffBzjTAPwNeNGn6Z+u22wTfoi45f3HFCWckRx6iHyBVD0EOIFpqlrtkVxVVExg8 TQO15uw5XUAcHmfRcMyat/WSrVKXHB7o4yvG2YiHODgmuUjkKSxXGSVKtnRyY4ZeJJMCl mkQZ4VB8cPOj0Nn/7txNE261V56Kbe5UmDPMLldM3f3RktHISHo1RSm+fVloj43aQD+zz rCAUXK00zTDnxZeC5KTE3JyGM9xj27B4S1QROy42WiC2LRWaaQEhnf9sCiPPPF9fArw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b="KukCRA2/"; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 37CB5606A31E for ; Tue, 24 Nov 2026 22:01:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KukCRA2/ Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7E7991F000C4; Tue, 24 Nov 2026 22:01:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557674; bh=CHg6cLp9gikE6OWNrdw5FOnL2uaA/b4N6CHoNbIqYUw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=KukCRA2/0WW+Z8qInkywQmR3FrnZ4HlJMsdZF1n536W6pYxX4nFAebz5990UYyEEw mKQvEEtq2+cGMyaHlVWVNc7gUsV5McaO0KeA0psN7n1t+2ceghLdZDGd6cjb15R0s5 MRxIY9hvOZZ0nG5lylu6W7QCQlInCwXbyaCuBOrIdKbTUfEEu69kv0db1XD/hnx57f uUzgAropFKCPnelNb8w1YjiGDD69n2TqrVJGlvraKr15Yg5woRDkXvkjaPLjP9AKZH dEKcSlfYwVv5QnwznIK0apYd9J5dU92KPvd0w9lKsbsCqEVCc12XtZAZGgqRvO6yev jwPIesEO0DM0Q== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:31 +0100 Subject: [PATCH mptcp-net v3 14/50] mptcp: report errors received before accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-14-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2089; i=matttbe@kernel.org; h=from:subject:message-id; bh=upYA94QCv2rfxVoknOZtjnkazkiF2LkfrOCX4cuvMaI=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOP6f11BdcNLkTpCqsxnrYaODl2elXP3maCgxU0lLO /QR18bXHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABNJM2L4Kz95W+GH+8kSK9Yw tbOp/04/d4V5kYTH5LL8FxWRMzevz2f4p3lk8kb+tT2fs3ReLQ8992nJjKwCtt0VC0+evX+/I8X JmB0A X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After a fallback to TCP, when the subflow of a new MPTCP socket has been reset before accept(), and the worker processed it before accept() too, the error was lost: read() returned EOF after the data, instead of ECONNRESET, and after a FIN followed by a reset, SO_ERROR was not set to EPIPE, as TCP does. subflow_error_report() skips the MPTCP sockets in the accept queue, without a socket attached. Before v6.19, the error was then reported when accept() closed the subflow again. Since the commit below, mptcp_close_ssk() is used there, which skips this subflow, already disconnected, since commit 280d654324e3 ("mptcp: avoid dup SUB_CLOSED events after disconnect"). At accept() time, when the subflow has already been closed, report its error, after having processed the pending close events. This issue has been found by an AI code review agent (Clashiko), while reviewing the previous commit, and confirmed with a new Packetdrill test: after a fallback, data and a reset are received before accept(). Without this patch, the second read() returned EOF: v1_bind_tcpfallback_reset_before_accept.pkt:21: runtime error in read cal= l: Expected result -1 but got 0 with errno 22 (Invalid argument) Fixes: 48a395605e08 ("mptcp: do not miss early first subflow close event no= tification") Signed-off-by: Matthieu Baerts (NGI0) --- v3: new, for an issue spotted by Clashiko --- net/mptcp/protocol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 8edff68ec650..ff1dcf306723 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4705,6 +4705,8 @@ static int mptcp_stream_accept(struct socket *sock, s= truct socket *newsock, if (unlikely(inet_sk_state_load(msk->first) =3D=3D TCP_CLOSE)) { if (unlikely(list_is_singular(&msk->conn_list))) { mptcp_check_rcv_close(newsk); + /* not reported in the accept queue */ + __mptcp_error_report(newsk); mptcp_set_state(newsk, TCP_CLOSE); } mptcp_close_ssk(newsk, msk->first, --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557677; b=Et/QqPHNLb2LPEfmsBCUZGFSKsLgRKGRuhzwxqjPo92nROUt0Gg6XlGpFOK8KnzpJXIB 4Z+5Is6/OdSbKuKB3qa6lfkse9TWe2zNNjahNSpdYxfwGv+qTPDqtSg8ebNHIfjpI9RAj uWRTnDV0YXROBtswnlbBU2s1+lgmIc7b72jbZgMhrke8jvsvLRaTXD5x72Lh4/Cc6BrnQ Xl9Y/Sfpi9tGEragj+3FeBXT82qC4WiEXRNk2IneLAUPV2hPZrs4tVKWEnfyrIAQf6vm3 vQ0wfxqnu+CsVtBG0kXQ9WBLXSQtKcbyPm3Lq+iHiYSCkbmP38CsTo+hgl0mDNDVFFg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557677; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=iThpyjHhC9bRvx/ExA9uRJM2Xp0zww57/Y1d7HPCC+4=; b=xveydBdVaiQYzkWBECS67+f38r1MAbqmWT4SNAFIL4LDZkLUViu+HS9XgYuCemWHF3Cp AdHaTU2fhzH8gWCt55GYphb6a50GVEgUA/74SfZBvyQEdGdeM/phRdsKRv42PWwCAe2HK 82h5hDSVeovPBqKq46uzKtR6NfXanpLvOSNQb3L5QYLtaB3fLfgaov1sJ2EPoynE48nhl h37ayoEGmAzygymEjXDt1nsP1YiFHbP831OHgFSd876/UETNj9GyizJt1yalwd3FZxFU9 xokIuUm9yPfH4CH5cOWJEj6E4imP3tTx2JmLAwS4LzBwFQJ5thYv+iR7J98G3WG7jbg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FxKCYJmd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 158CA606A31E for ; Tue, 24 Nov 2026 22:01:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=FxKCYJmd Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1B8F1F000D0; Tue, 24 Nov 2026 22:01:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557676; bh=iThpyjHhC9bRvx/ExA9uRJM2Xp0zww57/Y1d7HPCC+4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=FxKCYJmdYSslldGdu2FCYjj3dE/j64FD3Y+gMKFIejYwA4kIgBc8NyySAMfu1W60a rxBxN++anRkHBENn4+3DEkv5V1bSNKIrDf2EBoNpfJvD2rrSZfBbU0vhU9+lyNM9vk KWtOKASAzo/NcrYPAVd+YgOeXXHIM9b5lW3u1f4ub1XHwWVytPjDxXgnbPvjqetRjD ZmX9b2W35UinjKMa1aEZTBC0F3rzZ7UY4XV7Xq5jdZoSRhUxNxVqPHp+zSHEBGtapw eRxlFjtbqYKjj2V+iTX5OHnST7erpnjfyFpiydEFIBSgEM0crEwT1zx7CmtvJ4rFSD Zs4jwjBzvlvUg== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:32 +0100 Subject: [PATCH mptcp-net v3 15/50] mptcp: clear sk_err on connect(), as TCP does X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-15-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1425; i=matttbe@kernel.org; h=from:subject:message-id; bh=7CFFHnE2xbqFIqvskUo2gO4jn36RtJRg6RBmro2spLQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOBl2rM0++Tsl65vU+3WxSfHRPTZLK2V/B9/dyPNOy nPyEu5jHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABMR/MrIsL9lnqFYZSWrudVd ifrHm1QOC1V0fjrN9cf24HqlW3+Pf2FkOP7v376dC1K+1nKrXd3pxsx5r/jNviLHTRraB49MmuL xjBcA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After a disconnect with connect(AF_UNSPEC), an error from the previous connection, e.g. a reset not reported yet to the application, was still reported for the next connection, by poll(), SO_ERROR, and the first send() or recv(). TCP clears it in tcp_connect_init(): do the same, once the subflow connect() succeeded, so an early failure keeps it. This issue has been found by an AI code review agent, while reviewing other fixes, and confirmed with a reproducer: the peer resets the connection, the error is not read, then the socket is disconnected and connected again. SO_ERROR then reported ECONNRESET each time, while TCP reported no error, as MPTCP now does. Fixes: 3d1d6d66e156 ("mptcp: implement support for user-space disconnect") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent --- net/mptcp/protocol.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index ff1dcf306723..6328815ad273 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4452,6 +4452,8 @@ static int mptcp_connect(struct sock *sk, struct sock= addr_unsized *uaddr, if (err < 0) goto out; =20 + /* as tcp_connect_init(): drop an error from a previous connection */ + WRITE_ONCE(sk->sk_err, 0); inet_assign_bit(DEFER_CONNECT, sk, inet_test_bit(DEFER_CONNECT, ssk)); =20 out: --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557678; b=l/FyFlhA5Ap5Zk7pKK0b9sr7Z2y3gijcAVsgP6cXuVMlqWWCu9RUcoS3Ad8ioBhEEYtz VxyOiZTwv9EsyJQ/i92lFVNIc8pex/kS9xHuGF9R0iSxAzq2uyieor8G7RLHQS6jdQDGk OpOy1mZVjKKHxlFZhE0Ia+svRp2PKvFjglneqfSSYH8gl2b+BF1tiofCPOtqLCLPz9P+U HI908pypyWjiJIP8zgNRJfs5Hb8ZMPQFZiF0Lt8kyh7WM5QqH704pu96bEcamlMEG3UU6 /v69Hblxo+P38VNTN+x+NRMLInCFCFTukbdogby1vH8D7MLQPQknpa5B9bYbBY+7X0A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557678; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=A2WKkWuXfehR+p/MU356k3jOwQIB5NV8XuJQ+feAN78=; b=tonjaaUjmEyKFcmQGCIRgx9ojkmfh+aoSAKb9o9/pr+qnJnWCa9FWnjWaOWgpgo5DilG Wecx/hwrrdn1FjGBsVd7Oan7tO43W00m5XRfq1eOg3x/D1Skc1vmBxxb2hrbMmMVLSLOx 6fW7CCZm3maSH9IJAAJAYB6Ac+Ag4HrIpwPMtW5pZH+wnv2/LnHamm92cGj2P1acEsXjb yjFUse532ky3pg5M7P8feh58Z8r+59uIhzbcir24jpxitgCZ8+VsYE5YNuHrGqCUFmBOU VH9OXxexALGVaZh4F9GPtgKZzeD58EFJj0N2G/WJshYes3mClGxk+/QRQ3OZh5toQww== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hlwaH7zD; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EF4A0606A31E for ; Tue, 24 Nov 2026 22:01:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=hlwaH7zD Received: by smtp.kernel.org (Postfix) with ESMTPSA id 129051F000D4; Tue, 24 Nov 2026 22:01:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557677; bh=A2WKkWuXfehR+p/MU356k3jOwQIB5NV8XuJQ+feAN78=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=hlwaH7zDzC6uzT0wJNjQuPRqpKFD7oiwQsR8I40PMt+JlosAJaj7XbCVZ+aYc0tHB j97tXPhAgyTUYkp7V88P8Ze36xjscekUjnPTIWxnxOYlhiJZJ7VodEMOXibJYFko2e 4fS5Q2ECBccgyLlgf42tB7BFoaoxwuusMDbaHWyN29IZffjBIIKp7GBRVRxn7st9Rr MoiUyoPw/U5cTmsucaHyUL6mAXenszQHLfac5ofLK8sk7hm+96QJhEGKvqNdOvzYT7 dDg+tBgBl/SCLSOb8+mOn3XWbBlfRlPd3B0HcC5Aic7FqsQOmURVzZ/gtm5GK/CX5C UoBACJGzxT43Q== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:33 +0100 Subject: [PATCH mptcp-net v3 16/50] mptcp: clear DEFER_CONNECT on disconnect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-16-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1900; i=matttbe@kernel.org; h=from:subject:message-id; bh=5uaPhZ7sansISqHTJ2wvo/7sy4bspCLfVkYMZRBTRdA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOBneazz4fbPD4uVy5isfJq410P4gI5dxt6Cvr7V7N YvdHXXLjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlU/GZk+Kmdwbh8FS//9/0f AjLUyjv2Js1vU5UtXRF81PZNzZFbkYwMU/WrlyofKOmLq8u666CzuZp9pcWlbsVt2SztTzU/t6b xAwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 With TCP_FASTOPEN_CONNECT, mptcp_connect() copies the DEFER_CONNECT bit of the first subflow to the msk. This bit is cleared on the first write(), but not when the msk is disconnected, e.g. with connect(AF_UNSPEC) before any write(). tcp_disconnect() clears this bit on the subflow, but mptcp_disconnect() leaves it set on the msk. The next write() then goes through mptcp_sendmsg_fastopen(), and tries to connect the msk again with a NULL address: mptcp_connect() moves the msk back to SYN_SENT, possibly allocates a token and increments the MPCapableActive counter, before the subflow connect() fails. -EINVAL is then returned, instead of -EPIPE. The stale bit is also reported by the diag interface. Clear DEFER_CONNECT in mptcp_disconnect(), like tcp_disconnect() does. This issue has been found by an AI code review agent, while fixing a similar issue, and confirmed with a new Packetdrill test: a deferred connect, then connect(AF_UNSPEC), then send(). Without this patch, send() failed with EINVAL: client-TCP_FASTOPEN_CONNECT-disconnect.pkt:35: runtime error in send call= : Expected errno 32 (Broken pipe) but got 22 (Invalid argument) Fixes: a42cf9d18278 ("mptcp: poll allow write call before actual connect") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent --- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 6328815ad273..257c851c8a76 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3828,6 +3828,7 @@ static int mptcp_disconnect(struct sock *sk, int flag= s) =20 mptcp_check_listen_stop(sk); mptcp_set_state(sk, TCP_CLOSE); + inet_clear_bit(DEFER_CONNECT, sk); =20 /* The later subflow close can not kick again the tout timer, * as the msk is already in closed status. --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557678; b=wA36g/+ekcWEewc6ikqR2a8nymZO0Ke6RE9b6hQhZYKz1elM4m4vszgp+7N9nDBUFfyl bA1MbCs/dPp19pGijJ9AbnL+oBLZyMPOptvBN8bGNkSE5U9xsQjC/ESKCNdaefmf6zHjN mtGySMT4Nxn9pbQLf9bSnGhxvzeYSfDZp6aJXtg3t59NwarERCn64TG6T/bcVO8Qr3kvl 0LKZX83g5ZToYY4ca8aAZEZw3MmPn568/FNdB5N+543N2wu36I6PCq9dNFO/UyK895iL6 MSGwGmORimSJ8ettdMwp0ogygytmGZWgI+MlOkqEeb76xKm35WhDXb8Bms6KMpSBQ5w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557678; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=IUgGOpysbTOEziieM2X3tGQbL6K6Uw7HbwzTMwuc+Xs=; b=QWCGIASiZ81xCJ4/ejNqST3716rHgzqcHBAErX2hbzjSCD99ZYCa4pQFafHG9KUa1ZVw iaOydEaGrTqOfIvz1jjZ9UvSxZURDEuF3i4fsacGy9aWpDnBWRhqymkCTZdZV7CIGdTwf RTIA01ChRST/SPrzhiGMFx+UX65XjLy913vB48jxy/yORRfXGOpoeWWUdR52bXRRKM8z0 z7bojXbHe8Kr7k9PiEzRiReNOX3hIN3aw6m8G7ElxtkqRSvwbEjIs+Ww1CanV+hBVz96v 5P3BYlE7Gt5slFAdLXkV1J3CjYWjIL2n8fRSK9fxuRPcNUDhne4/eRP7ocfiLTl6CIA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jJ92sUnA; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA3EB606A31E for ; Tue, 24 Nov 2026 22:01:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jJ92sUnA Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3954F1F000E1; Tue, 24 Nov 2026 22:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557678; bh=IUgGOpysbTOEziieM2X3tGQbL6K6Uw7HbwzTMwuc+Xs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jJ92sUnAO/ISDNvj5AB3H7Pc7Toso9LS02+QIngG3ZZf2vUBUsKmVy+9+AUrP3VQq 3cb/OTk3b+hJtMtqGx3Ugr2aQ1MZnDn5JWCNcBs9iUMUegaiQ17EOZW1SG5LNRqYCe NomkpQt2iCEBCgm8Z/j2Dn8XCKYSlFxBMqlDcPlrLye1XZykQ78jr8hlDTbFwDNXg6 XLW5ZWAdatE+JwR33OxDsfKxdGKvmvSQ24OH8zzbmdLZZZGWaDkrP0SZitVgY14MU6 tjvejsAxvn/jE4pEy4btpiXFgcgpHcsd5HiiPeUCwUrUUt0je6IjGxv8PC/pB2Kduf hzPQlC0V6BP8g== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:34 +0100 Subject: [PATCH mptcp-net v3 17/50] mptcp: report sf aborts during deferred connect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-17-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=4320; i=matttbe@kernel.org; h=from:subject:message-id; bh=bhtVu3TjvWCT3TuBvU5Xhp7ILbUH9r7lfcLejtyHhg0=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOBkvl1QKHH3ecDPlqcXi0zvczBtUjqg8eHXQTXt7A We6xWeOjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIksnsnwz6rge2pC9P753bd/ ek90z+AWEs7vUn0qfq6eYc48gz7r44wM32Yv0+GTe3Qms7VF+uzmV/x6nfzmq+bXq0X4Td3GeeA kDwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 With TCP_FASTOPEN_CONNECT, connect() on an MPTCP socket only sets DEFER_CONNECT on the first subflow and on the msk, and the first write() sends the SYN with data via mptcp_sendmsg_fastopen(). If the first subflow is aborted by tcp_abort(), e.g. via a sock_diag destroy request or the bpf_sock_destroy() kfunc, while mptcp_sendmsg() already owns the msk socket and is waiting for the subflow lock: - tcp_abort() clears DEFER_CONNECT on the subflow, and moves it to TCP_CLOSE; - subflow_error_report() can only set MPTCP_ERROR_REPORT, because the msk is owned by the user: the msk stays in SYN_SENT, with DEFER_CONNECT still set. tcp_sendmsg_fastopen() then skips tcp_connect(), and calls __inet_stream_connect() with the msk socket, the first subflow being grafted to it. Because DEFER_CONNECT is set on the msk, -EISCONN is returned to userspace, on a connection that has just been aborted. Detect this case once the subflow lock is held: if DEFER_CONNECT is set on the msk, but no longer on the subflow, the subflow has been aborted, or disconnected. Propagate the subflow error to the msk directly, instead of waiting for the msk release callback. mptcp_sendmsg() will then report this error via sk_stream_wait_connect(), like plain TCP after tcp_abort(), e.g. -ECONNABORTED. The deferred error report is then a no-op, so the error is not reported twice. Without the race, the msk is already in TCP_CLOSE with the error set: the same check also avoids going through tcp_sendmsg_fastopen() and __inet_stream_connect() in this case, except with MSG_FASTOPEN. As TCP does, write() then reports the error without disconnecting the socket. With MSG_FASTOPEN, the socket has to be disconnected, as with TCP, for the next sendto() to connect again, and the race cannot happen: __mptcp_nmpc_sk() requires an msk in TCP_CLOSE. Clearing DEFER_CONNECT on the msk from tcp_abort_override() instead would not be enough: tcp_abort() is called on the subflow without the msk lock, and mptcp_sendmsg() checks the msk bit before taking the subflow lock. The abort can then happen in between, and write() would return -EALREADY, followed by a disconnect of the msk dropping the deferred error. In this path, only mptcp_sendmsg_fastopen() holds both the msk and the subflow locks, and sees a consistent state. This issue has been reported by Sashiko, while reviewing the commit below. It has not been reproduced: the abort has to happen while write() owns the msk socket, and waits for the subflow lock. Fixes: 93723db43e51 ("tcp: Clear DEFER_CONNECT before tcp_connect() and in = tcp_abort().") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue spotted by Sashiko v3: comment and msg: also after a disconnect, and what write() does without the race (Clashiko) --- net/mptcp/protocol.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 257c851c8a76..87f6da0f6cab 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1960,8 +1960,6 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, st= ruct msghdr *msg, /* on flags based fastopen the mptcp is supposed to create the * first subflow right now. Otherwise we are in the defer_connect * path, and the first subflow must be already present. - * Since the defer_connect flag is cleared after the first succsful - * fastopen attempt, no need to check for additional subflow status. */ if (msg->msg_flags & MSG_FASTOPEN) { ssk =3D __mptcp_nmpc_sk(msk); @@ -1974,6 +1972,19 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, s= truct msghdr *msg, ssk =3D msk->first; =20 lock_sock(ssk); + + /* subflow aborted or disconnected: its error report may be deferred. + * With MSG_FASTOPEN, the socket is disconnected below, as with TCP. + */ + if (unlikely(!(msg->msg_flags & MSG_FASTOPEN) && + inet_test_bit(DEFER_CONNECT, sk) && + !inet_test_bit(DEFER_CONNECT, ssk))) { + inet_clear_bit(DEFER_CONNECT, sk); + __mptcp_subflow_error_report(sk, ssk); + release_sock(ssk); + return 0; + } + msg->msg_flags |=3D MSG_DONTWAIT; msk->fastopening =3D 1; ret =3D tcp_sendmsg_fastopen(ssk, msg, copied_syn, len, NULL); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557680; b=KrVEPbMsfysvrJvjG7Fkq3tfr5Jh89qSwi0eMCw9hcLWNn+GEvIuymx9GUWRjFlcZ21H vxlQR0QeATPTmld/oaEn5yqAOEHpZwTAqex2dxNfHz6rPsPvbSry2aPazhWeQVPGZf27+ 9yKkT3eysaKnXfJ/XQ5k9kvPUMV0f3V7kbgCY3WdbKLllYJ/O66JcSmPXsgjqoW+3zh6h tfGisnEiZ3YJoy2sEbF6U+BmJoAZrqVtAm4iGT9strluq8emsqhVvhdtz1Wq0+ODKJxDi MUcGWiyKvZUz0CKMT1ie2B4P5LRQawBEAsmL2WNArCk30cdAhtYJXJn8aSEmYvE6tmw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557680; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=zBGah4EmGUH3pDG2nlvhXDiNZ2Gmxwj0IOr8CwyevVw=; b=Q/rQHkQJ9R5nN0pYRXgdkVhHSju6ACSptSWx/kRBSnJhJZbC+pXkQJI1ymt7b7+7Cjiz sLaW1caODpKaOtybFE4wwc6Fk5PcjgrAr67UnzKpt/G2u779wnbeViFgNIGT3P5B9clUd traB5Hoz03B9BRpbs2ICGFW6I71nXleYktsG89Vg1uuS4Jh1KaSsdUIMKl8btqkFCdfbo faRGjHwGRqpixqvkiACZcSmfMy32jg6/uTefz4QxzO9QQPHWuCqS3ZeusrYNEXGSaa8Q2 cN9PY0eE1Z7+QqGSjsx2Q47iAiMcLZh0xUGbJm8luFP0JkhA2JghJt0UpaD1XwMBgsg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=b4lzEhVD; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 09D6B606A31E for ; Tue, 24 Nov 2026 22:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=b4lzEhVD Received: by smtp.kernel.org (Postfix) with ESMTPSA id 147C21F000C0; Tue, 24 Nov 2026 22:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557679; bh=zBGah4EmGUH3pDG2nlvhXDiNZ2Gmxwj0IOr8CwyevVw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=b4lzEhVDQ/oTk+oiRe0S0JLZvHicHtsZlTiqkbgzHveH+57hRBCQojX3CFhLHLa0W 0FwXL0cQ/15+NfeOa6QeecsOrXROeJlAoxGOSsxq+VUU3xeC7E5GVyyztnV2QU5Ycu EwIAy4lzK7LN3k7cUfYrkgRuMIf0X1nEOF4esr/w53d74LFvMRyasfvuiLHygSlgmY ZJYCanqmaarCadkMJdBEI5PgFOhqlq4mi/FAy/eeTUf2UsHa6dN+KJTLUwc+GDG71s wmkGn7G5rGXWyixipXeb5QXqetqRmCgPMbicSo5y4+c5yj7nNhuQ/zcH97l9vCv3Co sKqrBqy4Unqwg== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:35 +0100 Subject: [PATCH mptcp-net v3 18/50] mptcp: no fastclose reset from SYN_SENT subflows X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-18-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2185; i=matttbe@kernel.org; h=from:subject:message-id; bh=DRtfIxZFihaTl/+OPHDFWHSAXRjs2KpkNXgrn/k5jyk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOJlWlnfeVq3TdnvhmbbnkaNsYe6ddrn3iqpuxstrW X7pX/nZUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMJHbxxgZjqYuiGgIWBW2UfPZ 549b8iQ1ElnrBR6ysgulVXP/v3+mieF/reGBXUf6buzZu5k/8ddW9el8qzdIWfTzmejt3rPJx1S dDwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 mptcp_do_fastclose() sends a reset with an MP_FASTCLOSE on each subflow not in LISTEN or CLOSE, also on the ones in SYN_SENT, while TCP sends no reset in this state, see tcp_need_reset() used by tcp_disconnect(). On a disconnect in SYN_SENT, e.g. with connect(AF_UNSPEC), an MPTCP client then sends a reset with an MP_FASTCLOSE carrying an unknown key, 0. With TCP_FASTOPEN_CONNECT, this reset is even sent before any SYN. Before the commit below, these resets were sent by tcp_disconnect(), so not in SYN_SENT. Skip them again in this state, as TCP does, but move the subflow to TCP_CLOSE at once, as tcp_disconnect() does: a SYN-ACK received before the end of the close cannot complete the connection, and a later one gets a reset from the stack. This issue has been found by an AI code review agent, while reviewing "mptcp: clear DEFER_CONNECT on disconnect", and confirmed with a new Packetdrill test: a disconnect in SYN_SENT, then the SYN-ACK. Without this patch, a reset with MPTCP options was sent at the disconnect, before the one replying to the SYN-ACK: disconnect_in_syn_sent.pkt:16: error handling packet: live packet field i= pv4_total_length: expected: 40 (0x28) vs actual: 56 (0x38) Fixes: ae155060247b ("mptcp: fix duplicate reset on fastclose") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent v3: move the subflow to TCP_CLOSE at once, not to complete the connection with a SYN-ACK received in between (Clashiko) --- net/mptcp/protocol.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 87f6da0f6cab..6c712f677220 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3321,6 +3321,12 @@ static void mptcp_do_fastclose(struct sock *sk) =20 subflow->send_fastclose =3D 1; =20 + /* no reset in SYN_SENT, but a close at once, as TCP does */ + if (ssk->sk_state =3D=3D TCP_SYN_SENT) { + tcp_set_state(ssk, TCP_CLOSE); + goto unlock; + } + /* Initialize rcv_mss to TCP_MIN_MSS to avoid division by 0 * issue in __tcp_select_window(), see tcp_disconnect(). */ --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557681; b=rane3VVRLCQplBeJ0sgIRPh8/PJr7hvoy9KTUjoIDf/H6mVi/ocFX2lYc7BVRx8TeiJX abeakSC2GVDmW5EmCta3AELIm4Yp0asRf3XDKJgoluNcLUGWvXdarpWwQ9BXyyDB15y1R qK1w9u85h/5Y40ZQYrw0liAppMNI2h46vvILW2E3n24+xdVZwF2QUGnomb9dL3eE0JeNF 3UmegOaD3+aix8wMz5GqjLbu8WJctN8LJ/LD+VUt9uwkC+PJAqNuwttrV373WsEnukp3N HY9aTJ7uuRptkHt1wOLIyv3iJNwNABKtWaYfO6tTVNG8HbtdkogmvrSCJo0kAc0Ig/Q== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557681; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=b83vJJ70vpcs6EzZe6QVugxjvk8LHtBIsLrG0HUDeo8=; b=P0vHIzmOeYE5BWWSGalDJBLZyMOiN4/UGjAmfmQBdvAq36/Ql79qE9UUDSAJKzLFlbnd dWaHp2rkN6VQNioBRcozMpdRQOYSJTp0zcBHo1+c6TxQpb6dvx/wjriFdX6gLRVmnzBId 6bPD9LnjORaQ1xhShC30ZCIvfBY47bWe8wYu6ronfUI+RRVshEDzmawezA5PhfPFlLqHT OYjQCEXYZR2OWJTCitibx35CbxnRAR9v0CdYtPAmdG94YDS0BvJ7JWUVoGXU2Sbxhoemr hxZ07NBOUfeSVqBagWgdImZSF7LsI7SNXgf8fZTFcMgPYJf3ibxwAw8mhxW+6VBA6Tw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XjR3o6l9; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7EE1A606A31E for ; Tue, 24 Nov 2026 22:01:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=XjR3o6l9 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DB801F000C6; Tue, 24 Nov 2026 22:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557680; bh=b83vJJ70vpcs6EzZe6QVugxjvk8LHtBIsLrG0HUDeo8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=XjR3o6l9JGgwwnrPcIqH15dihtH1o1bBU5w0Kjv0hteUOpnm9cbBofDdQnu0a7vfm IOB/tLRhNLAgYIIfp/hnEPpz0Uws+0A142u/H9IWsxD0LlkQaeH/Ql7P40bTuT6bUs Iy3IwUrNWuvIwKl7Z/d7AYSPFKCysneZE9K+1p6QUd/9MQi6moHuu8SVrStNPbTSVc a99QBHIYur1p/cn5o1QXn9kqv7SW8ebPRRWhQ2iev8dB8I9UU4ROxHzZ9TLkEccpbp cWlE/97YkbaYB7Rpw7Qc6tEbcCbNwmz0hPiwMYcTos0KLj/tBe4gzSC4i+y6wdfZxU NFkQwq8Pq1I7A== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:36 +0100 Subject: [PATCH mptcp-net v3 19/50] mptcp: fastopen: keep listeners and connections X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-19-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3052; i=matttbe@kernel.org; h=from:subject:message-id; bh=Q7TK+NFZ5u1s2IPhVTeYesNtcJHHUxaR/O0EwSY38Og=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOJmOby+O/XAtV7toepGU9O/r03ur23v+Bwl76T1iP ctwUeRZRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwES0mRgZJhsy8fEzv02bG2ru JB4g6ORfFBfg6MPErdmzrU629WQQw19hl+qC3fUsfqadj9XnNjHOPiNwKF+lp2bK245dQr4Ht3E AAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A sendmsg() with MSG_FASTOPEN on an MPTCP listener fails, e.g. with EISCONN, as with TCP, but it also closes the listener: after any error, mptcp_sendmsg_fastopen() retries the disconnect that could have failed in __inet_stream_connect(), while there is nothing to retry for a listener. On a connection closed by both sides, with data still to be read, the same retry also drops this data and the end of the stream. Skip this disconnect for a listener and for a connected socket: __inet_stream_connect() returned without trying to disconnect them. They are then kept as they are, as with TCP. This issue has been found by an AI code review agent, while reviewing "mptcp: report sf aborts during deferred connect", and confirmed with a new Packetdrill test: sendto() with MSG_FASTOPEN on a listener, then a SYN. Without this patch, the SYN got a reset instead of a SYN-ACK: listen_sendto_fastopen.pkt:14: error handling packet: live packet field i= pv4_total_length: expected: 60 (0x3c) vs actual: 40 (0x28) The case of the closed connection has been found by an AI code review agent (Clashiko), while reviewing a previous version of this patch, and confirmed with another Packetdrill test: after a shutdown(), data and a DATA_FIN are received, then sendto() with MSG_FASTOPEN fails with EISCONN. Without this patch, the data could no longer be read: closed_sendto_fastopen.pkt:30: runtime error in read call: Expected resul= t 1000 but got -1 with errno 107 (Transport endpoint is not connected) Fixes: 7d803344fdc3 ("mptcp: fix deadlock in fastopen error path") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent v3: also skip it for a connected socket, not to drop unread data (Clashiko) Note (Clashiko on v2): only retrying a disconnect that failed, with SS_DISCONNECTING, would leave a deferred socket stuck after an early error from tcp_sendmsg_fastopen(), DEFER_CONNECT being cleared on the msk: then, the disconnect is still retried, as before. --- net/mptcp/protocol.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 6c712f677220..d529cfb582a5 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2004,11 +2004,14 @@ static int mptcp_sendmsg_fastopen(struct sock *sk, = struct msghdr *msg, */ if (ret && ret !=3D -EINPROGRESS && ret !=3D -ERESTARTSYS && ret !=3D -E= INTR) *copied_syn =3D 0; - } else if (ret && ret !=3D -EINPROGRESS) { + } else if (ret && ret !=3D -EINPROGRESS && sk->sk_state !=3D TCP_LISTEN && + sk->sk_socket->state !=3D SS_CONNECTED) { /* The disconnect() op called by tcp_sendmsg_fastopen()/ * __inet_stream_connect() can fail, due to looking check, * see mptcp_disconnect(). * Attempt it again outside the problematic scope. + * A listener or a connected socket is not disconnected there, + * as with TCP. */ if (!mptcp_disconnect(sk, 0)) { sk->sk_disconnects++; --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557682; b=EvSGIHK/zgs9U/Be0vDJS4dkJ+6fAcJSaoCYxxSa3zrRr5WlGtwFZf2vFSPC8lk0uuwt fOCH6KcJtpaYYQ8xeWS8au9bMMVFv6meQQM9QS5QUmioLoUToytFxlJryutWemjZRBLvj +nxH+qm3C2ZXLBm8MJAqHzBNNqpKFw74Y20xB67vbmHavaLA9RCnHPztl8BgN7AQK+Ncm z6l4KA7QIuIBSdhLz/TtXUA2EDAkKZXI8TiTW67rfh/zG7HOoqOkfAxKW/DlUCSWn+n5c XMIW/U2Uv0DekXT+O7w9cVY7+6gXZEFY9O8ER1+w4FymcabfgpQ4u8Q6jnbSl3SExtA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557682; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=e9JXBbhIbo8LlQy6Rs1KEK8liXyNWPi7ANv5yEPdfVo=; b=3XjU8gkv0K6t21pTS1JM07WUVAfnbD0C2YI75FRZIxN0O4m5DHeUyvMtTyL0Ks5kz8vb 2kka0rlJLA5sGjdufAxv91l3+DWe1/zcedK0QBuKoS1RQHOqCqcYxXHehD92a1yuq7Dgl Ho5aMpZjE4OAO3VAmBF1wu414oz/t5F7Xo06e/FJ01oVRpbB1478HYHQq3gnEC4aWfYhc BZvPdbnibWRSffNIfzfpd05+2cfMViwtN3ccEgWa9TOTiPCN4NqNWJa3kXFlvCvEyLkEt 8D0zSkGcevDKikb0ilV+F9HvkGvFbbO/+QQme+598h6mSMCsOMM6DA0t5WA6FGDLMhg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d51V5aAd; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A94C606A31E for ; Tue, 24 Nov 2026 22:01:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=d51V5aAd Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90C4A1F000D3; Tue, 24 Nov 2026 22:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557682; bh=e9JXBbhIbo8LlQy6Rs1KEK8liXyNWPi7ANv5yEPdfVo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=d51V5aAdm4WrY4VAFpQkrLmC4B6R7GgvPn2P/f+I/xVntXelnKuXAZG7GBONhEKgh wEAFF1+QS69rNsd5PlY/1brmbiyq0hGHVykR8tUk5LvStVuuYeB6hvYFa5NBawVxP9 58DkEvUu64EhveJIm1BJOiPcn1DdZwembu/0OjJV5ft/faXQuew+XLn0GVGqmZgDDr q1XlX6ZTLdU1dQRNJRUKgRt+9qgPYmnRlb0lyan7I6DLgPfTIF05DQxypcS8qaC1Z9 on50nruuj7M/zUc6cP4ysXJOmYGajU8XStz9GGUqxbDYnRliGwLrIj+4UGTu3xjm25 9N18BHwcFlroQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:37 +0100 Subject: [PATCH mptcp-net v3 20/50] mptcp: don't inherit fastopening from a listener X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-20-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1729; i=matttbe@kernel.org; h=from:subject:message-id; bh=Do50zQzc5z/BiN0ccFcAYRcFzymPHXMl0/+Lw91A+jE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOJmj/B0cOl44+dWf77KuMq5M3/DeNmtK1vOMza6Jr AWfJDd3lLIwiHExyIopski3RebPfF7FW+LlZwEzh5UJZAgDF6cATOTqEoZ/FkuT1TYz9ia9bhHf pvXMQPzlaYX8M0kvaxa+Fdp3rfnTM4b/hVKOT4MiXb+nT1oY17x267SIL/Z7E+Z7tNQXn1wd4pr MAwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A new msk is a copy of its listener, made without the listener's lock: if the application calls sendmsg() with MSG_FASTOPEN on the listener at the same time, the new msk can inherit msk->fastopening, only set during tcp_sendmsg_fastopen(). mptcp_disconnect() then fails on this socket: connect(AF_UNSPEC) returns EBUSY. Clear this flag when creating a new msk. This issue has been found by an AI code review agent, while reviewing "mptcp: fastopen: keep listeners and connections": before this other fix, these new sockets were mostly reset with the listener. It has been confirmed with a Packetdrill test, and a debug delay added in mptcp_sendmsg_fastopen(), during which the handshake completes. Without this patch, connect(AF_UNSPEC) on the accepted socket failed: runtime error in connect call: Expected result 0 but got -1 with errno 16= (Device or resource busy) Fixes: 7d803344fdc3 ("mptcp: fix deadlock in fastopen error path") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent v3: msg: the new title of the previous patch --- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index d529cfb582a5..b1072123397f 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4005,6 +4005,7 @@ struct sock *mptcp_sk_clone_init(const struct sock *s= k, WRITE_ONCE(msk->local_key, subflow_req->local_key); WRITE_ONCE(msk->token, subflow_req->token); msk->in_accept_queue =3D 1; + msk->fastopening =3D 0; WRITE_ONCE(msk->fully_established, false); if (mp_opt->suboptions & OPTION_MPTCP_CSUMREQD) WRITE_ONCE(msk->csum_enabled, true); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557683; b=DeXvieGWg1PUaCfNkO9H1OLOu1GbosNUU6xWsJ3diRYGdV84mQ5SKwcJGgffTuPPvAuG t+awNVSp+xrmYopL9g6ttOdMSes0/r31ceaakmxWortC/G+d+7/cgf4JH65mXAnZYEuEO qlZD44apvLdfF7TrXmN4aUhl+rRPHCvdK1ECTWCw4QnxLlp7hpWa70l60ujFvGqeI2rUo nKKg0+cQr0d8aDlM2mNFKagGrH4vVs8g32hlhk/JUASVyV1WsQN8cvOvrcRDiU+1EsS+q YTqpF1Jz6z2JJcDC+9eqsxaNoTgAvw4NvfIq9toO09qMXIKRzW85qPyzRgdtFhPaUSQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557683; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=vQCImdFitGpbWIKf0MA1uvRp2nUKPsjiELXLQrrfI2g=; b=EyVVarnpD6HC4z01jrRGRvLMCr8BNwnZ0UjV+a82n4eSxHgtQ0UP4XpjgHhuywJLfGPM 5yOvgzserMdNtF8c6KFv42TSB2zmCvMs+mdNrvzvXG1O8WxysafZqZ4Kl4MQ9ZEW98rX4 wHbpGPPk2WNuYs8fa0J6NV7BQq0DwfXL35wb2E6q78chrNEoopqVT4GTlWSE3gAwHDC2J g61Ub/diX79A6NZF88hpQBnb/mf3Dm8H7kOx64XmxCtlU2xqmJ/VP/q9Fa9hF0mOeDH/J syYa57rfqvPje8ecDIDJkUCqnLzIPhOqhmuRu2T1vpftNYy0yAdIeYqjNExmB6NPaEA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JYkBDToP; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7C59B606A31E for ; Tue, 24 Nov 2026 22:01:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=JYkBDToP Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6345F1F000C6; Tue, 24 Nov 2026 22:01:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557683; bh=vQCImdFitGpbWIKf0MA1uvRp2nUKPsjiELXLQrrfI2g=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=JYkBDToPbKfKLoT5D/11WtXUNwWWmm/NGFIoMZ1Kou8sINQ0Bm3HPDB8rjDZAPIYF hdtCRXVPFonYx4gcLhMZaf/oqszj7ciz67YbYM6MyCwo4TlHlazKR94qs7Ar1G73hc RcISS5khXTv16t/tCQH+A6qj/oSF2dedkjj7nyrcQnFWIvHg8454yNSA/7cPTVdiUo 2qCbSqiAJxnI7Ks62mCDYFBxSM6zC2u9JSLWxjo2AXK3i42caDh1fC64Ao53t6R/xn ttByNOA4CK2WVXG1lz8PnyNyfXxUncc4hkfVrlIiE6IR3DZxXLcB5VI8CwftQx9pPT bPV2SAAIu2F+w== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:38 +0100 Subject: [PATCH mptcp-net v3 21/50] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-21-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3455; i=matttbe@kernel.org; h=from:subject:message-id; bh=sjK3TzczKwFnRy3Th9jpJkZdKQpZKzSTaIOKeS++4FQ=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOJndK2a6uLdMX3DD4oFJhrC8klVe1ZaG6tywtVtnM FW8dxXsKGVhEONikBVTZJFui8yf+byKt8TLzwJmDisTyBAGLk4BmMgiV0aGCRG79mQt/3h5oyRT 4arWa3/OXO+2LizjE3J/Hff5Nsv8qQz/k+6Jv39kGHo4MOB/Rmiozmn1C87+9f8W5S/Xf2jJruf JDgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason With SYN cookies enabled, a port-based MPTCP signal endpoint can stop accepting new subflows until it is deleted. Nobody calls accept() on the listener that the in-kernel path manager opens for such an endpoint, so it must create only MP_JOIN subflows, which never enter the accept queue. The listener is marked pm_listener, and since commit 3d041393ea8c ("mptcp: prevent MPC handshake on port-based signal endpoints") subflow_check_req() refuses a SYN with no MP_JOIN option on it. But a SYN cookie does not record the MPTCP option of the SYN, so mptcp_subflow_init_cookie_req() picks the kind of child from the options of the ACK, without looking at pm_listener: ACK with a valid cookie and no MP_JOIN option creates a plain TCP child, or an MPTCP one if it has MP_CAPABLE which stays on the accept queue until the endpoint is deleted once the queue is full, the listener drops MP_JOIN SYNs too These children also hold a reference on the netns: since commit "mptcp: pm: don't let listeners pin their netns", they are what keeps it alive for ever once its last process is gone, unless somebody deletes the endpoint, as noted by Clashiko on that commit. The fix used here is to refuse an ACK with no MP_JOIN option on such a listener in mptcp_subflow_init_cookie_req(), so that the request sock is freed and the ACK is dropped. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch: a client sent 1025 ACKs with valid SYN cookies and no MP_JOIN to the listener of such an endpoint. Without this patch, its accept queue stayed full, and another client could not create its additional subflow, even 130 seconds later: TCP: request_sock_subflow_v4: Possible SYN flooding on port 10.9.0.2:6666= . Sending cookies. [...] C2 4.007 [130 s after C1 has gone] RESULT: subflows established = 1, in SYN_SENT 1, the service works --- V, after that try of C2 listener 10.9.0.2:6666 Recv-Q 1025 Send-Q 1024 With the same reproducer, adapted to delete the namespace of the listener after a few of these ACKs, this namespace was not freed: srv: listener of the endpoint: Recv-Q 4 srv: deleted, then NOT taken down after 60 s Fixes: 1729cf186d8a ("mptcp: create the listening socket for new port") Signed-off-by: Chris Mason [ Shorter comment, the details are in the commit message. Commit message: how the issue was found, its symptoms, and the netns pinned by the queued children. ] Signed-off-by: Matthieu Baerts (NGI0) --- v3: commit msg: the netns pinned by the queued children (Clashiko) --- net/mptcp/subflow.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 67a749643ad7..91698d154c40 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -315,6 +315,11 @@ int mptcp_subflow_init_cookie_req(struct request_sock = *req, =20 opt_mp_capable =3D !!(mp_opt.suboptions & OPTION_MPTCP_MPC_ACK); opt_mp_join =3D !!(mp_opt.suboptions & OPTION_MPTCP_MPJ_ACK); + + /* PM listeners only take MP_JOIN, like in subflow_check_req() */ + if (unlikely(listener->pm_listener) && !opt_mp_join) + return subflow_reset_req_endp(req, skb); + if (opt_mp_capable && listener->request_mptcp) { if (mp_opt.sndr_key =3D=3D 0) return -EINVAL; --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557684; b=WWyrisw8FWtzZ4GdEXnlD+0kCK3Qa+yNZDV+ebRLPMhXgXwMEhJAA2K9GKN1MtTb0brG MrCTaAc7I58tt801JaD7jCxykmzJhggFGICkQybYp6f4cnhxj2WQ1ymjyoBjuZ6yLBE6m C669KM4fGzK3oeK1IIEm2Droe4mU/tcj0durG4o91KGMTLNoKUkOa/HPEonGRV6JikM0b hmn+QEYDD0TwWdqPi6CQTSlkhEPjkK3BgtA0RAY5/IZBcdqiM61MxRrLYCSN66VyGsZxJ Ub1Kcp97y0oRPcOcplfMK045kU5YgAd5BWogkxgXwjxHXNEkpeDtqmC6ctFFzscGvRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557684; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ACdOpzli2hAJck7wLWoXpCFORkP8HXDrXOSuZKiRKb4=; b=a0e3aPHRvJVsSzxeYNp/cYlxMTa6DorA1gHfCs7VqOki8VHDzRTZc9FotJsxna1Oh/tI CJwOB3RFKXCECuKCGm/JngfL7QX9ttbxoYiC0FowdOT3uzh6qcVkmzL9cH4lGIHTue5rD 3wDUtxOdeHdCiVfDFVKpj1dF+oA2m3/OAiRKtI9q4WyS7sDaT+U1+W9E/dWNrFQq2aqI7 JDFWQH8Yyxbdg8p40jSgO94CExzAP9aUk1DwHegiv8x7f5/ZkuZdR5QeyQKaHkZlnjXeb RnniYjxUTMoos45iMMAktJb6U1uxtpr8ptLW9dE46PP6+W2Wdy7IvA8U0OTM4SZPOWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NjO2VYgw; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C54C3606A327 for ; Tue, 24 Nov 2026 22:01:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=NjO2VYgw Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90BCA1F000CA; Tue, 24 Nov 2026 22:01:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557684; bh=ACdOpzli2hAJck7wLWoXpCFORkP8HXDrXOSuZKiRKb4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=NjO2VYgwUfnv636Q2w+F69b3OGUhN/pShWoTKqYk6xtti2Qn42/zp3Qhs20sauNZj eEjxaLG/bMObaE4ecjcyqNgQFiKoUTKzzHmLHZCtu7rdSLAh4L/eOqclLEQjgjA0Qe 7dZMYVyEsXRcOrXLnWjzP3Ya0dlerxn1mP/CnydyImqwqO//iT1UrZPnvvjpTX98Se duPbk8DRxR8NAyVjayeQHJRMbWdYddWcT/8tdAS6WrsZgoxgEQeQ49Xl8MBp3lGSrx pqVWMbC+lFTfsISpLhXh4tgXMmCdAEF2U9v8dPhCHPDAINg3oxvxoKzNa6CJQ1WiG+ w/s9fRAEPRuUw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:39 +0100 Subject: [PATCH mptcp-net v3 22/50] mptcp: close a subflow reset for a bad mapping X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-22-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2949; i=matttbe@kernel.org; h=from:subject:message-id; bh=3LxmFeGM2amj88vfcrVoUccXI2tbsiD/vhieWyNYcKE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOFm2F1xzVrn5I5yNkX9tjanX7bNGwbKNCoyiRtOq/ H7+aN7YUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMJG3Pxn+GenHsvycbfvV/ffE 4N32bZsqd8T/37rz42SLa+cOiDguE2f4xaTLzS/m8SN4xvdVmbcEJqqyXfy26gGritW1+EyhwMo yNgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason An MPTCP socket can stay in the ESTABLISHED state after MPTCP has reset its only subflow because of data with no valid mapping, and recv() and send() then block with no error. If data arrives with no valid mapping and a fallback to TCP is not possible, subflow_check_data_avail() resets the subflow: it moves the TCP socket to TCP_CLOSE with tcp_set_state() and sends a RST. The MPTCP worker then has to close the subflow in __mptcp_close_subflow(), and closing the last subflow starts a timer that moves the MPTCP socket to TCP_CLOSE. But the worker only calls that function if the bit MPTCP_WORK_CLOSE_SUBFLOW is set, and this reset neither sets the bit nor schedules the worker. The fix used here is to call subflow_sched_work_if_closed() after the reset, which sets the bit and schedules the worker. This also covers the reset done after a bad checksum, when MP_FAIL cannot be used. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch, and with a new Packetdrill test: data without DSS while the fallback is not possible, here because of out-of-order data at the MPTCP level. Without this patch, the subflow was reset, but the MPTCP socket stayed established, with no subflow: read() returned EAGAIN and send() timed out, for good: dss_drop_ooo_reset_server.pkt:30: runtime error in read call: Expected er= rno 107 (Transport endpoint is not connected) but got 11 (Resource temporar= ily unavailable) Fixes: 40947e13997a ("mptcp: schedule worker when subflow is closed") Signed-off-by: Chris Mason [ Add a Fixes tag. Moved before "mptcp: continue the last mapping after a fallback", which makes this reset path reachable in more cases. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- v2: commit msg: the reset after a bad checksum too (Sashiko) --- net/mptcp/subflow.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 91698d154c40..a216d88d35ee 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1505,8 +1505,8 @@ static bool subflow_check_data_avail(struct sock *ssk) } =20 if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) { - /* fatal protocol error, close the socket. - * subflow_error_report() will introduce the appropriate barriers + /* fatal protocol error, reset the subflow and let the + * worker close it */ subflow->reset_transient =3D 0; MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_DSSRESET); @@ -1521,6 +1521,7 @@ static bool subflow_check_data_avail(struct sock *ssk) sk_eat_skb(ssk, skb); mptcp_send_active_reset_reason(ssk); WRITE_ONCE(subflow->data_avail, false); + subflow_sched_work_if_closed(msk, ssk); return false; } } --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557686; b=SJTvTNuCUgb0IjuQ4rZQYbEUjC5a0vkU95QPnSGYGO6qWyhoC7M1LK6jTuwMbsX+Jdqf AnB9t+8IDZbkqFSaz1lU4bee/sMemWQ/c9qOzl2qjccfZSPccWgu+9CW8xKLimern31lG ao0XtahJSN4o9gtwPR2XCNmNmRAKhVKFSlOg9isolv0stPA6Ai960V1PVamqgUfbWcbM3 UFqIo8m8PG7peWppkUbvmh0RAHdl7FtWj7vOKhpYtCBouSkzMCgt1KegRMjgisLJ6kvpq P+2vUQtIn9guCPp7ijoLH87SHXlUNedBMfE/WB/4B2+MiUm7Pd/BW/Z7Jt+d1wxDcvQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557686; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=CBbmcC3SquL/sUh0/0abO4UmG3Cbv//EVoTMLeRnei4=; b=PatqXcdRnJq5ENTdnPuK6DZ5B6CPNTi5+LXAtWG5w82wokIjZq/+f92ZezzmUev0a6oZ cq0e/OymAK9offz1E0IdROijlSB7w9F0ICkSNinbBPvhmGZydFw4R48Lr5LJCq3jFeNpw zt1Xk3/hW3QllQNkahYRU6cvWn4chaV3HK1wYo3nhKyFFwYMVeE12oMl2REmlnybvSt/4 DTU+knUFPQchM5hAs/eue7K2G51Scq3eKn3Zmen/Y36g4LsARAyBZ5X/JIMEl/KSrRyO9 JZsAO/JQZ9/HJie1MDMs7u6qmDctB5fn7mfTXmTfF261ABJrwpKHlq7L1bxQCPUVIvQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YfMYa7Xk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4DAEE606A31E for ; Tue, 24 Nov 2026 22:01:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YfMYa7Xk Received: by smtp.kernel.org (Postfix) with ESMTPSA id E83111F000C4; Tue, 24 Nov 2026 22:01:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557685; bh=CBbmcC3SquL/sUh0/0abO4UmG3Cbv//EVoTMLeRnei4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=YfMYa7XkG3WPtH31c/p8U3jRi6hli6ga7S+6FRUvDcjpSHOufdD2viwotNTPdFR3R 7NwjjnWwjxak8cYSUQAzYFG8DYoGRII83iGVZgo/6/KPHF8lkdDWUuQX4GY1AeVI3P YvyVQyHAK9T4zNw/KDUGJVnjiYNf9QhOFwYFy36z0OdKQYrSQkSGzWsdfHsa56pfiW tyFA25oEGolMD2WlholoxiHgVBDzbJSrV0P5xr6wXpuiS2saSiJXcxwYztqWUhwfQm SFd6LHhsXX9nd4USLlF3zjHpPQzTqTilP0O2p7Xj9WjZZZOKIsfhWLICq+yVTlfBwH r9d9rblvQd4zQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:40 +0100 Subject: [PATCH mptcp-net v3 23/50] mptcp: pm: kernel: count endpoint listeners as sockets in use X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-23-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Kyuwon Cho X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3964; i=matttbe@kernel.org; h=from:subject:message-id; bh=OPRvotvx8HNkyVDGOs6cqb6T0ZZWlYYOMAuy5o5R+7w=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOFnzt0j3WLI9n60dPYH1uk7os1c1EWf73lTtmGfH/ W7J6x0XO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACZyvZ3hf9wzg4z65uViS81y X5UHnJ5SeMbJOVb0g/zhiS2H3rJIuDAyfF8+Wdn5t5GdeZjQVcVjrnJfQ8wWB771vZLawhUxV6a YDQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The listener that the in-kernel path manager creates for a "signal" endpoint with a port is not counted in the "sockets" column of the MPTCP or MPTCPv6 row of /proc/net/protocols, but it is uncounted when it is closed. Each removal of such an endpoint then hides one MPTCP socket of the same family from this column, for the lifetime of the netns. mptcp_check_listen_stop() decrements this counter for any MPTCP socket closed in TCP_LISTEN state, and mptcp_listen() increments it when listen() succeeds. But mptcp_pm_nl_create_listen_socket() sets its MPTCP socket in TCP_LISTEN state without incrementing it. This socket is closed when the endpoint is deleted or flushed, when adding the endpoint fails after the creation of the listener, e.g. because its ID is already used, and when the netns is dismantled. Nothing depends on this counter, it is only displayed. But it is wrong once such an endpoint has been added: its listener is not counted while "ss -Ml" lists it, and after its removal, the total is one below the number of MPTCP sockets of the same family in use, a negative total being displayed as 0 by sock_prot_inuse_get(). The counter was introduced by commit c558246ee73e ("mptcp: add statistics for mptcp socket in use"), when only the subflow of this socket was in TCP_LISTEN state. Commit 57fc0f1ceaa4 ("mptcp: ensure listener is unhashed before updating the sk status") then set this socket in TCP_LISTEN state too, without counting it. The fix used here is to increment the counter when __inet_listen_sk() succeeds, as mptcp_listen() does. If it fails, the subflow is back in TCP_CLOSE: move this socket back to this state too, also as mptcp_listen() does. It was left in TCP_LISTEN, which triggered a warning when it was released, e.g. after a socket in TCP repair mode had been bound to the same address and port in between, as reported by Sashiko: WARNING: net/mptcp/protocol.c:3542 at mptcp_check_listen_stop.part.0+0x4f= /0xb0, CPU#0: ip/2816 Call Trace: __mptcp_close+0x2bf/0x310 mptcp_close+0x23/0x80 inet_release+0x43/0x80 sock_release+0x24/0x70 mptcp_pm_nl_add_addr_doit+0x266/0x3b0 This issue has been found by an AI code review agent, while reviewing the code of the commit "mptcp: pm: don't let listeners pin their netns", and confirmed with a new Packetdrill test, and with a shell script adding and flushing such an endpoint 3 times in a new netns, then creating 3 MPTCP listeners. Without this patch: kernel_listener_inuse.pkt:15: error executing `test $(awk '/^MPTCP/ { n += =3D $3 } END { print n }' /proc/net/protocols) -eq 2` command: non-zero sta= tus 1 inuse: endpoint 1 present: 0 (expected 1) [...] inuse: 3 user listeners: 0 (expected 3) Fixes: 57fc0f1ceaa4 ("mptcp: ensure listener is unhashed before updating th= e sk status") Reported-by: Kyuwon Cho Closes: https://lore.kernel.org/mptcp/179502042942.2742790.1788799442428253= 6144@gmail.com Signed-off-by: Matthieu Baerts (NGI0) --- v2: count the listener once listen() succeeded, and restore TCP_CLOSE otherwise, to avoid a warning (Sashiko, then reported by Kyuwon Cho) --- net/mptcp/pm_kernel.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 2680d4672d58..73261685ae4c 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -915,7 +915,14 @@ static int mptcp_pm_nl_create_listen_socket(struct soc= k *sk, if (!err) mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED); release_sock(ssk); - return err; + if (err) { + /* the subflow is back in TCP_CLOSE: like in mptcp_listen() */ + inet_sk_state_store(newsk, TCP_CLOSE); + return err; + } + + sock_prot_inuse_add(sock_net(newsk), newsk->sk_prot, 1); + return 0; } =20 static int mptcp_pm_kernel_get_local_id(struct mptcp_sock *msk, --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557687; b=q4IvdDohJo/aQfaqajkz/qnU/k9d4QBi7x60r2P9rSOfjp9Tmhym7tCLVX34rpPPg8LX IiSiCwIeJ1bv0kxPbQFekezDDRrCMTQoWVZOJWYD3Z/mg8m90YZSmGZTk4m7Q6Uy6VlX5 lTJ236ZI0SviMgkL7uSI5MR8QdasH2Jq1ty882rafsZ4aKvxutU+UevfBDY7AVLl9CVHn kM8DffoJP+WGKrP4a24YICtdvrtZdIpYQIsUM6v/yRtMMFXomVsYfqTm9Y4djp+g3pS21 Td+FZ1iA1819rpFqkDuKjjvf1W/pwkBRMGCSule5hb5/8iyrNI7/yIVV23yqCKvWFPg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557687; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=cbHJpgOooJOguSJAWRQ2CKVQOBY8X4T6m783R0TGyis=; b=BeZYVBG1kMIj9vrqZ3RsjzAruhNGAxLiZcjQcCVq559Y2DZa9dfZftzPBBJZ9K/RNk7T f3gosItb+inhTahoyhSX5ZoL+jdkGXnLwL4y6mQrdsYCF5ylS7XWiGmjRbL57pcL/21Wf dcQmaOA0kb+OEHKO/rFCPcRHtvr06ZFQ3myTbtmlvaDnLY7DZnd3bqrFeKsN45bflXypT W/wuPIERA1iSSax8LUq7o+hOf0X73bZwwUPbY/KpKAyPAYZPAJfPkX/05ia+epkN8vlX5 cgMIN2BLKF8g/+YCvmAtV7QIKZz0F8QBstA8ujkR53PcHqq5O32bW8dx9vqK6MBiqRA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kp6XRyvX; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6CDCE606A31E for ; Tue, 24 Nov 2026 22:01:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=Kp6XRyvX Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F5F01F000E6; Tue, 24 Nov 2026 22:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557686; bh=cbHJpgOooJOguSJAWRQ2CKVQOBY8X4T6m783R0TGyis=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=Kp6XRyvXCqclR10VV1Ao8GNxm9vPsiF7rQKWfjCU5z8247zMG16NHXKc4EyqJ+y89 lsJ6MauNolCHs12Jx8l+KTBhKMDQOfn5gtQ8womzAZQd2uuE+TLnYvR2x7fg40XWt/ OHxbeHZ0lDMzbZaBoAGuqJyKknnfJ/cREkkVQNUo8x/btCxbtNxGQWqmjGjSDFHOP/ CdgDoatzyNVI3rVsdh691fY4I80MSVyRQw8tAe4QOOXeKg+EZXBeARDLk3yJCgRayr xGAIPpBRKJ/cjEFr3ziVGKRmJjDuyW9Gwn1e4QqJAP3h2TykBRwZQp1Sn+Iw/Q2idu KowAn59+UuUPw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:41 +0100 Subject: [PATCH mptcp-net v3 24/50] mptcp: count a listener once when listen() is called again X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-24-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2837; i=matttbe@kernel.org; h=from:subject:message-id; bh=k8aJr5YHDlsRkiaK+5wHnKasKWSA4Fz2iZIpeK6eDno=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOFkV9vyw2dfDv/P1y1ymkNy3/DMudwrI7zt+4IRUJ udRx92nO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACYiv5uRYaF3FquQMntl2Jze Vw953z79z1xtvH/rHY/a3JIt02ya/BgZlqkc5zvye5fgq3mXGpQPuM0sYNhzvOnU6rcbVs28mcf kxAgA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 listen() on a listening MPTCP socket only updates its backlog, as with TCP. But mptcp_listen() then counts this socket once more in the "sockets" column of the MPTCP or MPTCPv6 row of /proc/net/protocols, and sends a new MPTCP_EVENT_LISTENER_CREATED event, while only one decrement and one MPTCP_EVENT_LISTENER_CLOSED event are done when it is closed. Each extra listen() call then leaves the counter one above the number of MPTCP sockets in use, for the lifetime of the netns, and a userspace path manager can see two listeners created for one closed. With TCP, the socket is only counted when it is hashed, which is not done again for a listening socket. The fix used here is to only count the socket, and send the event, if it was not already listening. This issue has been found by an AI code review agent, while reviewing the code of the commit "mptcp: pm: kernel: count endpoint listeners as sockets in use", and confirmed with a new Packetdrill test, and with a script calling listen() twice. Without this patch: listen_listen.pkt:12: error executing `test $(awk '/^MPTCP/ { n +=3D $3 }= END { print n }' /proc/net/protocols) -eq 1` command: non-zero status 1 inuse: relisten: listening: 2 (expected 1) inuse: relisten: closed: 1 (expected 0) The extra event comes from the commit below, and the extra count from commit c558246ee73e ("mptcp: add statistics for mptcp socket in use"), which is in all the stable versions having the commit below. Fixes: f8c9dfbd875b ("mptcp: add pm listener events") Signed-off-by: Matthieu Baerts (NGI0) --- v2: commit message: explain the two Fixes tags --- net/mptcp/protocol.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index b1072123397f..c57bfedc86a8 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4568,6 +4568,7 @@ static int mptcp_listen(struct socket *sock, int back= log) struct mptcp_sock *msk =3D mptcp_sk(sock->sk); struct sock *sk =3D sock->sk; struct sock *ssk; + bool listening; int err; =20 pr_debug("msk=3D%p\n", msk); @@ -4584,6 +4585,7 @@ static int mptcp_listen(struct socket *sock, int back= log) goto unlock; } =20 + listening =3D sk->sk_state =3D=3D TCP_LISTEN; set_bit(MPTCP_RTX_ENABLED, &msk->flags); mptcp_set_state(sk, TCP_LISTEN); sock_set_flag(sk, SOCK_RCU_FREE); @@ -4598,7 +4600,8 @@ static int mptcp_listen(struct socket *sock, int back= log) release_sock(ssk); mptcp_set_state(sk, inet_sk_state_load(ssk)); =20 - if (!err) { + /* only the backlog changes when listening already */ + if (!err && !listening) { sock_prot_inuse_add(sock_net(sk), sk->sk_prot, 1); mptcp_copy_inaddrs(sk, ssk); mptcp_event_pm_listener(ssk, MPTCP_EVENT_LISTENER_CREATED); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557688; b=1pYlKM5ku+rklS7/Z7DU3rkHvHV7j2RgP/DGcUX0SAcig7PPBvET86PwpFPtnup/09gE QaC9XlamIVrvql5QPAtehVDAx2o34yfwU7QWRINbEce8cjOcc8aQAqCWAkbsBUFJD4vn+ nTkYz8moifc4zC0fJ4GeHo74hHLrAdeRYPEUA6jf992+bDuqAjYwYAM8sIbtTU1Tf6dxW xARw2M4srnCdqQ1ykDl8HUzXIPpbVPL2dhXcYJuG1l7xN9CkBBPfo7LcNI3TxJsGxKsUv O7qt7HVBKFtQY0U/P8Ch4UU1IrwLdyJtPlI2Zumvqg9fbdheFCcam86r5XLF8s9d2QA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557688; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=arqzmrvd1T+g2nEXvt51rYEAE+C52HVLZgf+lMA1aSU=; b=ES6y20+AwaVDj2275Co7ELmCC1Il7u04zWIf9cESKqQfFjVdTqep60a29Ky19TEOBQmn LAQG7xUouRQiLO4y2fQcdnKGwgdrMcN855ynGl/Czkq3plELT3oUCvBCZ3GF+dneClpfx ZBZF6m8tB2ZxvfpHdwhVj3nArxqr/2fuUXx8zWWIG/dM7W/N6BJgxkZhF0pvBPeMQMlaa IFmAzTwy118/ZmxHzy/mtsLSzIJEeCG6uK3vU0c53SJn9m0SeM3OVBAxPXilkAi37ShX9 p+KSp9fszlbv3j+kmO1aUmr8qMn3aM86F2XysYAXgKUkREo0u2AinzK+Dh58TY/RBoA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EWrmSYdH; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2FC51606A31E for ; Tue, 24 Nov 2026 22:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=EWrmSYdH Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8826F1F000D0; Tue, 24 Nov 2026 22:01:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557688; bh=arqzmrvd1T+g2nEXvt51rYEAE+C52HVLZgf+lMA1aSU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=EWrmSYdH+k68xeIkdEUQF92AhcxWXXr2TMoW3o+ghogTbpjeaR27cTUqkySwXwvq1 1/DHOIkD3wIZ+E/JRv+rzai8zHfGpD1TgBx/+VrMmceL8JTufuzlexwwvVFhDKFXyY Y86u/+1jqqMJ3WGzaJLRw/oY25HQ9lj2RDljFzDUE4kJlrxWJ2Xi1d9NKQQnAxj+Yp +4U7jnSBAPEdxgF6uIWfr/zlPwWoISMdkVwJKC6N8cGHNuWvsbQXUkKOCCaWyrjWRU MEO4fTcDdIKzmu86UwTs1SrZQ5EZc4fg+xEcdgyUiQZg0VP6YjoB1mq1kDBIDg9pb0 uaF5At4Lyj5qQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:42 +0100 Subject: [PATCH mptcp-net v3 25/50] mptcp: send the infinite map in a single segment X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-25-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3564; i=matttbe@kernel.org; h=from:subject:message-id; bh=4w0vMAjClJ+ZgNpCHoNEhS1gzESFbtrKibc9SIZJNeE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZONmyLX48VHxj8GBKsLJ+1eXw9105W4LuJVycns935 LTtqv06HaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABPpnMTwz9zkzpK4049vztiT s+NUp75+2qW96578clBbuvfF65JbLp8YGRp274vdzN/qoRB4Kik+7ybjWf1nr3a//lZ194ZYTI7 EHyYA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After an MP_FAIL with a single subflow, mptcp_sendmsg_frag() puts the infinite mapping on the next skb with new data, then falls back to TCP. This skb can be bigger than one MSS: it is sized with the size goal computed before the fallback, from an MSS reserving the space for the DSS option. After the fallback, this space is no longer reserved when the MSS is computed, but this skb still carries a DSS option, which is copied to each of its segments: with the new MSS, they are bigger than the MTU. The new MSS is used for the next transmissions, e.g. when only a part of the skb can be sent at first, or for a retransmission, and it can also be used for the first one, when more data is pushed in the same batch. The IP layer drops such segments, as DF is set, and sends an ICMP "Fragmentation Needed" to the local host, which doesn't change the PMTU: the transfer stalls. This issue was causing the "Infinite map" subtest from mptcp_join.sh to be flaky, with the client counting these ICMPs as OutOfWindowIcmps, and its subflow stuck with unsent data: copyfd_io_poll: poll timed out (events: POLLIN 1, POLLOUT 0) (...) TcpExtOutOfWindowIcmps 134 (...) tcp FIN-WAIT-1 (...) timer:(persist,21sec,7) (...) notsent:98333 (...) (...) infi rx server [FAIL] got 0 infinite map[s] RX expected 1 The root cause has been confirmed with a Packetdrill script, a variant of the new dss_infinite_map_mss_server.pkt test from the MPTCP Packetdrill tests, with an MP_FAIL received before any data, and a cwnd of 1: without this fix, the rest of the infinite mapping, after the first MSS, was never sent: IpFragFails 2 0.0 (...) timer:(persist,305ms,1) (...) cwnd:2 (...) notsent:1564 (...) infinite_map_stall-v4.pkt:27: error handling packet: Timed out waiting fo= r packet To fix this issue, limit the skb carrying the infinite mapping to one MSS, as computed before the fallback. The segments of this skb can still be too big if the MSS decreases before it is acked, e.g. after a PMTU drop, but this is unlikely right after an MP_FAIL, and this connection would then stall as with a PMTU black hole. A side effect: when the last unsent skb is bigger than one MSS, the infinite mapping is now put on a new skb. This unsent skb is then sent without DSS after the fallback, as it was already the case for the ones before it, and the peer falls back before receiving the infinite mapping. Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue causing a flaky selftest v3: commit msg: why an MSS decrease before the infinite mapping is acked is not handled (Clashiko) --- net/mptcp/protocol.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index c57bfedc86a8..39490ff40aa4 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1483,6 +1483,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, info->mss_now =3D tcp_send_mss(ssk, &info->size_goal, info->flags); copy =3D info->size_goal; =20 + /* After the fallback, the MSS no longer includes the DSS option of the + * infinite mapping: send it in a single segment. + */ + if (unlikely(mptcp_subflow_ctx(ssk)->send_infinite_map)) + copy =3D info->mss_now; + skb =3D tcp_write_queue_tail(ssk); if (skb && copy > skb->len) { /* Limit the write to the size available in the --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557689; b=U1XaUlBMa0rA34aQNSYFsmqzcpeOSJ0Iz77hTOF6nhF8F8JLk3WSwM4TAUUbMSoKTTW+ UQeOB5L28zCMaIIBa7AFRxYOMEJKdRYhs0ilGMB7xpt7oB1OxBPdAs/X1id4CiHzG31ak y3yKsqwtyyTLS0/vMmV8C411ASGGxYDyFGMz/qu9fZDg/hlhXLQoWIk6e9AqKrv4lHirC ArMUxXoGhS7kCHdilRKAAmw8O8ERcT3z6/sSRoabbBSrhFMTEJSW4oPdQMdnL0pBg/wTM sRGPWq8Sv677ezNJddAYGesHhFme/3ZXtAaf7Y6V7BYHiaQtHCPzePY3xb7S9bccVbg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557689; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=RJprxeXxyucQuy5lqkBXvIeEc+aUniQtjNH6khMRghI=; b=0Xz2ct2Avv+Ijzb8hrVScARKdHtRq0o2ZyVP/In1E04MECqjZSavkPy42gdncsum8aZ7 Qg0wmXpSoYReGZlAG+0sB0J7aQkE4an1maPqcZGq28Lovt5n3njWgceQTsp3/d30knAIK G+br/Lo2kSABitK3N/+bAvZmXRNKgoQWuaXw65/acJqK39IIDFSk/QIEMj35lewiHm976 b7pww/NC4fm6kFNCeTnPZQyyzNMJ3YfAoFy3Zj9kRnBYk5NcniGcCAk0FnNtx0Ww6Y+HL ZB9lQTfdbbSLzCEM8VtuplNrgR6J6lwiRWdJB1chAY0KVmssBWn6kHDJ39VNeotKReA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ljtTZRAy; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CC630606A32A for ; Tue, 24 Nov 2026 22:01:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ljtTZRAy Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0093D1F000D2; Tue, 24 Nov 2026 22:01:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557689; bh=RJprxeXxyucQuy5lqkBXvIeEc+aUniQtjNH6khMRghI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ljtTZRAy1QgxHftEamQDxbdd7ADxzYRB8Iy2pXwBx8wuUeoze313c2dR/pP3PYeXw gLxVrNvCx8dUvfZGnFEykBC09drPEXIIwrWci4r7dRKMvf8JjI5uzALe+1Nw72kIdr 32hWaDAw+kBCIR80UW+6NJlUixSmH+y/ljssg9txbFQddzfDJupzRnTnHM9KJv0x3l 5YrgTdW8ASYIJ7j0ugWXq7kdeGRcFzdNoDUwz0Ol57NCM44uAhqlEHQ/YZ0s9MZPTa F8k/LAD/YbLB50LWmALbqPz6zqXfn+hNFjILaC5g/CEPrc/8RjfjzWehb6gzUXLlZn gTyS+4Nbm9n2g== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:43 +0100 Subject: [PATCH mptcp-net v3 26/50] mptcp: keep room for infinite map after fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-26-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2331; i=matttbe@kernel.org; h=from:subject:message-id; bh=8j1aeXy1DDB0f43SBFOhenjCy1aW8DKuxdgYIOVGjzs=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZONk4T9caL8t1ZU35oxtkbPD0z3aHKsstH7Z3WMi+S Zst9eRYRwkLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwERmujIybF6bbOextTozWnnP yT/s3t/+btHbpcZ0N31BxMdiDZeuJww/nvnEMNuX+ibHzqp0rEmqSFQJafqTs/tSba3SpnLnJEY A X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After an MP_FAIL, the infinite mapping is sent with the next data. If the MPTCP socket falls back to TCP in the meantime, e.g. after having received data without DSS, the size of the next skb is computed without room for the DSS option, as no MPTCP options are sent after a fallback. But this skb still carries the infinite mapping, with its DSS option: its segments are then bigger than the MTU, and dropped, while the next ones wait for them. The connection then stalls. Keep room for the DSS option while the infinite mapping is still to be sent, when computing the MSS. This room is only kept until the skb carrying the infinite mapping is created, not until it is acked: an MSS decrease in between, e.g. after a PMTU drop, is unlikely right after an MP_FAIL, and this connection would then stall as with a PMTU black hole. This issue has been found by Sashiko, while reviewing "mptcp: send the infinite map in a single segment", and confirmed with a new Packetdrill test: an MP_FAIL is received before any data, then data without DSS. Without this patch, the infinite mapping was never sent: dss_infinite_map_after_fallback_server.pkt:27: error handling packet: Tim= ed out waiting for packet Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue spotted by Sashiko v3: commit msg: why an MSS decrease before the infinite mapping is acked is not handled (Clashiko) --- net/mptcp/options.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 736e55532296..6b1a3994fb49 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -891,9 +891,11 @@ int mptcp_established_options(struct sock *sk, struct = sk_buff *skb, opts->suboptions =3D 0; =20 /* Force later mptcp_write_options(), but do not use any actual - * option space. + * option space, except for an infinite mapping still to be sent. */ - if (unlikely(__mptcp_check_fallback(msk) && !mptcp_check_infinite_map(skb= ))) + if (unlikely(__mptcp_check_fallback(msk) && + !mptcp_check_infinite_map(skb) && + (skb || !subflow->send_infinite_map))) return 0; =20 if (unlikely(skb && TCP_SKB_CB(skb)->tcp_flags & TCPHDR_RST)) { --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557691; b=Izvk55Alm3p1z3fFd+IGtTN653vrIc0CSmtb3AXRalxwy4NTR06/3PCHNyP78DfDOTFy HCoZP6z5GvnfY4+Nn7T3RJvDXn1h74XWMrXaGzzhA7jpHFg+so3KUbCnDlgm+faLxKpmQ /pXit4pO9kZXJ/uI23JrDlPYoqq/Xg0tOzyCbArKrfSuYiN9eoqjSPYvRiDyv6vteQjSa wHSKhstTmQTBrPe7fKrO7TG1f0BHXsRl0uT13BZNihVNBKAhEFDzz61gzc/SOXh8GA39g Cfyu7gFG+K4fH/MKCqcwr5D3Yo6aGP7LpfjCLu7HY5zJrJ/3V2KiVbaYzU6rEzI75TA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557691; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=8rGcvMb/ci9H+FeLt1r90ebY+DfeaHXwhwvO3CL7YsI=; b=qDY64tjahHSE1sF12rxzqUZFULWFyOcCHWdSyv9GbJrnWCT00HCy0DJR2eEpLoOnSMri 3BV3hsFeL+VIb3nmvOs9UXNdAouxMJquYn9xVAY5watJdbqgYBkC7hnS9oXZqsv+AKAyK myaWgnsxMamsF+ioDZsjSscMCuGkNWgewfk2LyqHvC+3TGrLEzTZvgF/v/5sfNd+9y8li 8KS2pxDCi9YK4+qvBgODSh8YHY1sI0o7gggAQpQAthF62xBDNpFj8Shy+z+Lck8NmsZ2j Fab4C2Ks1FDCgbzabXBfjK2CnBpwwRcF89EFQH6rK6lTuTRuiXsL2vaKTOrLAdIyAhQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bxbh0PZE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB147606A32C for ; Tue, 24 Nov 2026 22:01:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bxbh0PZE Received: by smtp.kernel.org (Postfix) with ESMTPSA id 375151F000D2; Tue, 24 Nov 2026 22:01:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557690; bh=8rGcvMb/ci9H+FeLt1r90ebY+DfeaHXwhwvO3CL7YsI=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=bxbh0PZEHEyjlL2y/UoOd4FCh230kwmQV3G7nVAxkssJX/U1g64g3G5dujgNBNS6d TFVwg9Idtqk+bFzL/TLJyPVl7qkjNVy3LeBlS28C1dLbc2zNiPqwFbYdf3pLzvq8CO mxq8JUcfOTefPc35u7pUGn5Y+tbTI9aIb/DieNlKYKnofH/U3A1cb9UAuHYlsIEiIf 8R5Dt+G7kuT0z/ff3aX7pg3rHQg29ioiuGPW8fTSj60hXSXZLJd4ofF5gCEQ69KST7 A86xhOA/Ku+1nOa+LUmM239Reecma7HKMgTUJ6hjZDAjkhG2MWOWRK1gES7ArqVfus I0PNCo8o5n2yA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:44 +0100 Subject: [PATCH mptcp-net v3 27/50] mptcp: do not fallback while old data is in flight X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-27-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9121; i=matttbe@kernel.org; h=from:subject:message-id; bh=OeXCnNe7JxwjJWiMcirJ+96Z1LyJat0vWuQbRMlA8YY=; b=kA0DAAoWfCLwwvNHCpcByyZiAGsGCQfIU7TowPB++rO5BXPpetoHj7DEPLwB12FgcxOlPLXva oh1BAAWCgAdFiEEG4ZZb5nneg10Sk44fCLwwvNHCpcFAmsGCQcACgkQfCLwwvNHCpcYEAEAwi5A 99GO8B71sp9kxXV5pUAuQroPcmgodhUKDJWSOAABALHp9jtWrtET8FU5RXl+/89d8Nm929b2DMb 9YxAL7usB X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason If an established MPTCP connection falls back to TCP while a zero window probe or reinjected data is queued or in flight, recv() can return data twice with no error, so the stream is silently corrupted. After a fallback mptcp_established_options() writes a DSS option only for an infinite mapping, so an skb that mptcp_sendmsg_frag() queued with a mapping to data sequence numbers (DSN) is sent without that mapping. The receiver treats the bytes of the subflow, in sequence order, as the rest of the stream, so a fallback is only correct if the subflow carries each byte of the stream once. But allow_infinite_fallback, the flag that permits a fallback, stays set in two cases in which old data is queued again on the only subflow. First, a zero window probe is a copy of the next unsent byte, mapped to the last acknowledged DSN so that the peer drops it as a duplicate. Second, when a subflow whose MP_JOIN handshake has failed is closed, __mptcp_retransmit_pending_data() marks all data that has no DATA_ACK yet as unsent, although no second subflow has joined. If the sender falls back while such bytes are queued, they are sent without their mapping and the receiver delivers them as new data, as here for a probe: sender receiver =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D queue a probe, a copy of byte N get data with no DSS, fall back read, open the window send the probe with no DSS no DSS: fall back deliver byte N send byte N as data deliver byte N again /* corrupt */ The fix used here is to refuse the fallback while old data is in flight: - when mptcp_sendmsg_frag() maps bytes to a DSN below snd_nxt of the MPTCP socket, set the new bit old_data_pending of the subflow, and store the TCP sequence number after these bytes in its new member old_data_end - clear the bit in mptcp_incoming_options() when a segment with a DSS, other than an infinite mapping, acknowledges that sequence number - make mptcp_try_fallback() fail while the bit is set, so that its callers reset the subflow - delay the infinite mapping that answers an MP_FAIL, and the fallback that comes with it, to the first data that is queued with the bit clear, and send plain mappings until then - after a fallback, skip data below snd_nxt in mptcp_sendmsg_frag(): a reinjection that has not reached the subflow yet does not set the bit This only prevents a fallback of this side: if a middlebox removes the DSS of these old bytes, the peer can still fall back on its own, and deliver them as new data, as it cannot tell that they are old. The next commits limit this case, but cannot prevent it entirely. A consequence: if the old data reached the peer with its mapping, but the DSS acknowledging it is still on its way back, or lost its options, a fallback attempted meanwhile resets the subflow, although it would have been safe. This window lasts about one round trip, or as long as the acknowledgments lose their options. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch: between two unmodified Linux hosts, nftables removing the MPTCP options, e.g. while a zero window probe is pending, or after a failed MP_JOIN. Without this patch, the reader got some data twice, with a regular end of file: the stream was silently corrupted: receiver 4.692: READ-TOTAL outcome iii-repeat-or-gap bytes 8388609 of 8= 388608 missing 0 twice 1 [...] end: eof [...] receiver 8.611: READ-TOTAL outcome iii-repeat-or-gap bytes 26000 of 140= 00 missing 0 twice 12000 [...] end: eof Note for the backports: this patch depends on commit 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data") and commit f8a1d9b18c5e ("mptcp: make fallback action and fallback decision atomic"), two fixes which may have already been backported: they allowed the fallback in the reproduced cases, once data has been acknowledged without checksums, and after a failed MP_JOIN. Fixes: 1e39e5a32ad7 ("mptcp: infinite mapping sending") Signed-off-by: Chris Mason [ Shorter comments. Move old_data_end to an existing hole, after subflow_id. Commit message: mention the reset that can now replace a safe fallback + how the issue was found, and its symptoms + note for the backports. Moved before "mptcp: continue the last mapping after a fallback". Commit message: the peer can still fall back alone. ] Signed-off-by: Matthieu Baerts (NGI0) --- v2: commit message: the peer can still fall back alone (Clashiko). Only clamp to one MSS when sending the infinite mapping (Sashiko) Note (Sashiko on v1): an infinite mapping can stay pending, but nothing waits for it: an MP_FAIL is only accepted before any join or MPTCP-level retransmission, so TCP retransmits the data in flight. --- net/mptcp/options.c | 6 ++++++ net/mptcp/protocol.c | 20 ++++++++++++++++++-- net/mptcp/protocol.h | 9 ++++++++- 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 6b1a3994fb49..9133e3d6e5d9 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1333,6 +1333,12 @@ bool mptcp_incoming_options(struct sock *sk, struct = sk_buff *skb) return true; } =20 + /* DSS acking the old data, not an infinite map: no peer fallback */ + if (unlikely(subflow->old_data_pending) && + !(mp_opt.use_map && !mp_opt.data_len) && + !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end)) + subflow->old_data_pending =3D 0; + /* we can't wait for recvmsg() to update the ack_seq, otherwise * monodirectional flows will stuck */ diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 39490ff40aa4..7df5a2863555 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1486,9 +1486,16 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, /* After the fallback, the MSS no longer includes the DSS option of the * infinite mapping: send it in a single segment. */ - if (unlikely(mptcp_subflow_ctx(ssk)->send_infinite_map)) + if (unlikely(mptcp_subflow_ctx(ssk)->send_infinite_map && + !mptcp_subflow_ctx(ssk)->old_data_pending)) copy =3D info->mss_now; =20 + /* after a fallback, the subflow got all data below snd_nxt already */ + if (unlikely(__mptcp_check_fallback(msk) && + before64(data_seq, msk->snd_nxt))) + return min_t(u64, msk->snd_nxt - data_seq, + info->limit - info->sent); + skb =3D tcp_write_queue_tail(ssk); if (skb && copy > skb->len) { /* Limit the write to the size available in the @@ -1569,6 +1576,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, TCP_SKB_CB(skb)->end_seq +=3D copy; tcp_skb_pcount_set(skb, 0); =20 + /* old data mapped again: no fallback until acked with a DSS */ + if (unlikely(before64(data_seq, msk->snd_nxt))) { + mptcp_subflow_ctx(ssk)->old_data_end =3D tcp_sk(ssk)->write_seq; + mptcp_subflow_ctx(ssk)->old_data_pending =3D 1; + } + /* on skb reuse we just need to update the DSS len */ if (reuse_skb) { TCP_SKB_CB(skb)->tcp_flags &=3D ~TCPHDR_PSH; @@ -1599,7 +1612,10 @@ static int mptcp_sendmsg_frag(struct sock *sk, struc= t sock *ssk, out: if (READ_ONCE(msk->csum_enabled)) mptcp_update_data_checksum(skb, copy); - if (mptcp_subflow_ctx(ssk)->send_infinite_map) + + /* the infinite map implies a fallback: wait for old data acks */ + if (mptcp_subflow_ctx(ssk)->send_infinite_map && + !mptcp_subflow_ctx(ssk)->old_data_pending) mptcp_update_infinite_map(msk, ssk, mpext); trace_mptcp_sendmsg_frag(mpext); mptcp_subflow_ctx(ssk)->rel_write_seq +=3D copy; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 888ee9d66967..6dbd912e08d8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -605,7 +605,8 @@ struct mptcp_subflow_context { is_mptfo : 1, /* subflow is doing TFO */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ resetting : 1, /* subflow is resetting */ - __unused : 9; + old_data_pending : 1, /* old_data_end not acked with a DSS */ + __unused : 8; bool data_avail; bool scheduled; bool pm_listener; /* a listener managed by the kernel PM? */ @@ -633,6 +634,7 @@ struct mptcp_subflow_context { */ =20 u32 subflow_id; + u32 old_data_end; /* TCP write_seq after the last old data */ =20 unsigned long fail_tout; =20 @@ -1346,6 +1348,11 @@ static inline bool mptcp_try_fallback(struct sock *s= sk, int fb_mib) struct mptcp_sock *msk; =20 msk =3D mptcp_sk(sk); + + /* queued old data would be sent without mapping after a fallback */ + if (subflow->old_data_pending && !__mptcp_check_fallback(msk)) + return false; + if (!__mptcp_try_fallback(msk, fb_mib)) return false; =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557692; b=0DM74wjjNrVbJ/CMt5ibVeljvRkKQ8wqJLjg7pxGYOt5rJFeZHp7USTx6fvzC1n49Ly0 XSzSDN5DC3Lj19bWkHGAlhw0fBxrCync2seMTmkuu5HIaeAeL29P0KsnHD2hPwOzIAK2G e4rZ0HkTJlk4qvN8DtlrD6eDyPdd12Qza0Sk0V4uTTXa9LEdWMauiSABMAKOqXhceU82V ATY2AxMGB84vvRurb8nTAlJSvITqJ9VSlpth/gIQ6lovr2vlOrH9theqUF27P21lj2SE3 l2BK70Kvny7q5QxPHKFK3S2l+BekLD487mJWZFCWnjj6HJxgtP9nHVYq0kwyodaP36g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557692; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=Ejs34/aeaKW6GH/ZfrQ2RXtxbeWYo7WwaUXzenlhXis=; b=EFMfZiDLJOCKz5V2min8gCUKNgSyaVWkuOlfFIGkZn8PPkSvCQ7NI3YDNurusDR/YFE1 /qkvxO0cAEppMmx/081LiXIhcTztPIbZhwDgQAwcv/yK+PTAYmpyWjtCzxu4uyf4nSdAK P3XX9Pg/Yn19yrUQ0J1YvKm1E6vsiXNhMpS/W0SeNCsn3YKL+n//o/7Y84zTfozAVl+8m o0Gelx1pMoMQdV+FQElg183u4HqSed2p6Bud9/D7+iCotiN7svgPEar1SyQzJZVJgl7c0 nOXDdE5kqpe1gLngK47CLjUZoGonCBBpaegKU/oWDnue+btRsVbVznti2mQSf6LeZpw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oahh6yRI; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A79A0606A326 for ; Tue, 24 Nov 2026 22:01:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=oahh6yRI Received: by smtp.kernel.org (Postfix) with ESMTPSA id A33381F000C0; Tue, 24 Nov 2026 22:01:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557692; bh=Ejs34/aeaKW6GH/ZfrQ2RXtxbeWYo7WwaUXzenlhXis=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=oahh6yRIAvQy1dO73Ul4zsA4IIJ9YuPby3v+0UOvGNUgUqsixpNvxhwEyUmChvtLv pDpIa7zy6HaiaYaszOINZNjDc6J9lC9TM9qsyoE+mHgQ0dfZkNOoaqPlDzwvyFKKvg S4R3g3FH44ADxFUvn4Zm1CBs7oMx5vV6ODuPXX50wbV5MpmL22xSukb2FVxOpAPUhn Z4A6PtYhhOBsmEJk1C80kfZp3+cXu/MqZzCrnPJedpbLmTAPL+O7X/waM12+w7H+3Y EGhiFFXrMy+TLwDBqLSF+GAl9paOWh0UOY5mILx7CQbfHLvLpNOHDeehQfpO37PWtL kGym0RdEviAYA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:45 +0100 Subject: [PATCH mptcp-net v3 28/50] mptcp: stop resending data to a peer that fell back X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-28-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9462; i=matttbe@kernel.org; h=from:subject:message-id; bh=nT1g/O+nYYGBWeFOd26UmVAPsfy6LRAxK5eSzPy75yk=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZODnWrj+ck1rpcGHlqXa/x66Pr+0z+TX5evOCcnM2t 4NtIWvFOkpZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbCEcnw31fPP8fj962F3Isy ba/99pUIrGM66md4ys7whOe8xj+JhYwM3cFcX+6bcPmmB91SfP7zUtlvkblPojdWWxukL5zckfW LGwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason recv() on an established MPTCP connection can silently return data that it has returned before, again and again, if the receiver falls back to TCP and the sender does not. While no DATA_ACK arrives, the MPTCP retransmit timer makes mptcp_sendmsg_frag() queue old data on the subflow again: either fragments from __mptcp_retrans(), or a zero window probe. That is only correct while the receiver reads the DSS mapping of these bytes and drops them as duplicates: a receiver that has fallen back to TCP delivers them as new data. But mptcp_incoming_options() ignores a bare ACK, one with no MPTCP option, on a fully established subflow, so a sender that gets only bare ACKs from that receiver stays in MPTCP mode: sender receiver =3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D send bytes N to M (a middlebox removes the DSS) no DSS: fall back deliver N to M, send a bare ACK no DATA_ACK, the timer expires send bytes N to M again deliver N to M again <-- wrong send a bare ACK The fix used here is to: - reset the subflow, with the reason "middlebox interference", when mptcp_sendmsg_frag() has more old data to queue and only bare ACKs have acknowledged the old data queued so far. The test reads old_data_pending, which the earlier commit "mptcp: do not fallback while old data is in flight" sets when old data is queued. That commit clears it when a segment with a DSS, other than an infinite mapping, acknowledges old_data_end, the TCP sequence number after that data. The reset is counted in FallbackFailed: the peer has likely fallen back, but this side cannot - clear old_data_pending for a segment with any other MPTCP option too, in mptcp_incoming_options(). An infinite mapping stays the exception - skip a zero window probe while the TCP retransmit queue of the subflow holds data: the MPTCP retransmit timer, armed when a push leaves data behind, tries again later - drop the segment in mptcp_incoming_options() if the push done when processing its DATA_ACK resets the subflow: it is not queued on the closed subflow then, as with a reset done earlier This limits the repeats, but does not prevent the first one: data that was new when it was first sent does not set old_data_pending, so its first MPTCP-level retransmission is still delivered twice by a peer that has fallen back. After a failed MP_JOIN, more of the reinjected data can be. The same is true for a zero window probe whose DSS is removed: a peer falling back on it delivers it as the next byte, then this byte again, when it is sent as new data. A consequence: a peer still in MPTCP mode, whose options are removed on the way back for a while only, recovered once the options came back. Its subflow is now reset as soon as more old data is due. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch: between two unmodified Linux hosts, nftables removing the MPTCP options in the middle of the transfer, so that only the receiver falls back. Without this patch, the reader got the same data again and again, here 65 MB more than once in 120 seconds: receiver 127.514: READ-TOTAL outcome iii-repeat-or-gap bytes 68255744 of = 8388608 missing 0 twice 65650688 [...] [...] took 120.0 s end: limit: still data after 120 s Fixes: 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st= data") Signed-off-by: Chris Mason [ Shorter comments, also in struct mptcp_subflow_context. No timer arming when a probe is skipped: "mptcp: arm the rtx timer if a push leaves data behind" already does it. Commit message: the first repeat is still delivered, and a peer that loses its options for a while only is now reset + how the issue was found, and its symptoms. Count the reset in MPTCP_MIB_FALLBACKFAILED. Drop the segment if the push resets the subflow, update comments, and commit message: the zero window probe whose DSS is removed. ] Signed-off-by: Matthieu Baerts (NGI0) --- v2: drop the segment if the push resets the subflow, update comments, and mention the probe case (Sashiko, Clashiko) --- net/mptcp/mib.h | 2 +- net/mptcp/options.c | 16 ++++++++++------ net/mptcp/protocol.c | 21 ++++++++++++++++++++- net/mptcp/protocol.h | 2 +- 4 files changed, 32 insertions(+), 9 deletions(-) diff --git a/net/mptcp/mib.h b/net/mptcp/mib.h index 1ebdb55e9534..34a065b9e8dd 100644 --- a/net/mptcp/mib.h +++ b/net/mptcp/mib.h @@ -93,7 +93,7 @@ enum linux_mptcp_mib_field { MPTCP_MIB_DSSFALLBACK, /* Bad or missing DSS */ MPTCP_MIB_DSSRESET, /* MP_RST: bad data mapping */ MPTCP_MIB_SIMULTCONNFALLBACK, /* Simultaneous connect */ - MPTCP_MIB_FALLBACKFAILED, /* Can't fallback due to msk status */ + MPTCP_MIB_FALLBACKFAILED, /* Can't fallback: msk/subflow status */ MPTCP_MIB_WINPROBE, /* MPTCP-level zero window probe */ MPTCP_MIB_BACKLOGDROP, /* Backlog over memory limit */ MPTCP_MIB_RCVPRUNED, /* Dropped due to memory constraints */ diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 9133e3d6e5d9..f9b65d0c6290 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1287,6 +1287,12 @@ bool mptcp_incoming_options(struct sock *sk, struct = sk_buff *skb) if (!check_fully_established(msk, sk, subflow, skb, &mp_opt)) return sk->sk_state !=3D TCP_CLOSE; =20 + /* MPTCP opt acking the old data, not an infinite map: no fallback */ + if (unlikely(subflow->old_data_pending) && mp_opt.suboptions && + !(mp_opt.use_map && !mp_opt.data_len) && + !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end)) + subflow->old_data_pending =3D 0; + if (unlikely(mp_opt.suboptions !=3D OPTION_MPTCP_DSS)) { if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) && READ_ONCE(msk->local_key) =3D=3D mp_opt.fc_recv_key) { @@ -1333,12 +1339,6 @@ bool mptcp_incoming_options(struct sock *sk, struct = sk_buff *skb) return true; } =20 - /* DSS acking the old data, not an infinite map: no peer fallback */ - if (unlikely(subflow->old_data_pending) && - !(mp_opt.use_map && !mp_opt.data_len) && - !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end)) - subflow->old_data_pending =3D 0; - /* we can't wait for recvmsg() to update the ack_seq, otherwise * monodirectional flows will stuck */ @@ -1359,6 +1359,10 @@ bool mptcp_incoming_options(struct sock *sk, struct = sk_buff *skb) return true; } =20 + /* the push from ack_update_msk() can reset the subflow */ + if (unlikely(sk->sk_state =3D=3D TCP_CLOSE)) + return false; + mpext =3D skb_ext_add(skb, SKB_EXT_MPTCP); if (!mpext) return false; diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 7df5a2863555..61cc4ae2a7b8 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1455,6 +1455,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct= sock *ssk, struct mptcp_data_frag *dfrag, struct mptcp_sendmsg_info *info) { + struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); u64 data_seq =3D dfrag->data_seq + info->sent; int offset =3D dfrag->offset + info->sent; struct mptcp_sock *msk =3D mptcp_sk(sk); @@ -1545,11 +1546,29 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, return 0; } =20 + /* a new probe would move old_data_end: one at a time */ + if (!tcp_rtx_queue_empty(ssk)) { + tcp_remove_empty_skb(ssk); + return 0; + } + zero_window_probe =3D true; data_seq =3D snd_una - 1; copy =3D 1; } =20 + /* old data acked without MPTCP opts: the peer may have fallen back */ + if (unlikely(before64(data_seq, msk->snd_nxt) && + subflow->old_data_pending && + !before(tcp_sk(ssk)->snd_una, subflow->old_data_end))) { + tcp_remove_empty_skb(ssk); + MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_FALLBACKFAILED); + subflow->reset_transient =3D 0; + subflow->reset_reason =3D MPTCP_RST_EMIDDLEBOX; + mptcp_subflow_reset(ssk); + return -EAGAIN; + } + copy =3D min_t(size_t, copy, info->limit - info->sent); =20 /* like TCP, allow some progress up to tcp_wmem[0] */ @@ -1576,7 +1595,7 @@ static int mptcp_sendmsg_frag(struct sock *sk, struct= sock *ssk, TCP_SKB_CB(skb)->end_seq +=3D copy; tcp_skb_pcount_set(skb, 0); =20 - /* old data mapped again: no fallback until acked with a DSS */ + /* old data mapped again: no fallback until acked with MPTCP opts */ if (unlikely(before64(data_seq, msk->snd_nxt))) { mptcp_subflow_ctx(ssk)->old_data_end =3D tcp_sk(ssk)->write_seq; mptcp_subflow_ctx(ssk)->old_data_pending =3D 1; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 6dbd912e08d8..dfeabe03180b 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -605,7 +605,7 @@ struct mptcp_subflow_context { is_mptfo : 1, /* subflow is doing TFO */ mpc_drop : 1, /* the MPC option has been dropped in a rtx */ resetting : 1, /* subflow is resetting */ - old_data_pending : 1, /* old_data_end not acked with a DSS */ + old_data_pending : 1, /* old data not acked with MPTCP opts */ __unused : 8; bool data_avail; bool scheduled; --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557694; b=0RiqQrZVcx0Z0MjhAhM2gyD4KSMwEqHIwjni5TS/A2d69hAC4c8kQ/be6KwwIE6BUeFq XouOn6agcplDQ9xvzd7h0roWbthzENTqIBd4ZnzVwDc6tV1t5mAh1a4GvnHclH2nOUtJW +ARzH2Vw9+kgXZhTnPixorsWIwfI9HlLLv/kcaTwB0IRATaykR0kgdoURFsGDz2KsOSfv l0bxizyLC2rhQD6cQKY4tUxQ2t/bsXieDMaEqrUwrhnWDvGaL0+3VnkUv/j4c/tH8JJXN yS1ptMJuGN1whldgh/e4SxiGzy4c25zjWlVonaafudsgYAjQA6T6/P4DwmA1BsVSyBw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557694; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=SbaFXsGT7fuPHR5UWWmCiDZfgmps0HkqJ+MfFP3I9xc=; b=kR0W1IOc+o0zvrVJ8Y8AHqv4RzPagCZKvPZT7ib01J7yMQrfZFwjuUTUhtHdMOLFblH9 GQDAgtFoeyCxOWLnINUST17I4m+czgRyfD9z+Nm+3SrcGQwdGR2xBkMmdFrjHUPkQ0ew4 YzdMb+AdjL1KHZSwNuhV1i+avTr2rcK4sY73yxw9l398LmV5TXL+foghT8otopW5Jw7uc q4THJbTB94joPTeLG+o34u3POQhm188FRNomqQoC4yhmyBuSRfuiOK611lJYFmqq7W2bl wfXtySWbHRFJy4I8e5cOvSLblFN/DoFp7xUWnrajbCE6KKZV+UUMhQs3ez9IMDVSNZQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YOLluSiW; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CBFE606A321 for ; Tue, 24 Nov 2026 22:01:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YOLluSiW Received: by smtp.kernel.org (Postfix) with ESMTPSA id 22DD61F000C0; Tue, 24 Nov 2026 22:01:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557693; bh=SbaFXsGT7fuPHR5UWWmCiDZfgmps0HkqJ+MfFP3I9xc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=YOLluSiWqK4LbcUBySL8mnePbSQHpQjCcUeMS9DhJtXDu0nYyUDJYL9y6G1XXb7TN 59ZRAnMD2oqtmjuspucOXoD4VX6yBYhseWdPRq9Tr3nWtbmC3gACUsCqMXbJZ9yhoy hU7hKDnXRGhFGvCRjvxAJqQFFTSjzxqmSCo40MFxkxQSZqcGj8vOn/2ToN+7H/hv/+ pWsSU/ejUCnA57gYudXmqLD/ijmNZZqibWoM1AUawupVcV99Xg8fxr0AUrR4rWNFTP IkK2j2tRfzgja0J4uEsqIgG3vOUM19zFCBFixa+Mx2PRGLzaoDmmxUfSq4vkuucdML /BMzlTup8qU9Q== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:46 +0100 Subject: [PATCH mptcp-net v3 29/50] mptcp: don't resend data acked without MPTCP opts X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-29-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=6292; i=matttbe@kernel.org; h=from:subject:message-id; bh=b0sbObVPUklcRlQb2fyz6cha546UixdHB43nZqU4gXI=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZODkOeKxRjgv+1mEVU2bP/uqi0vyf0z0eMvVxSN8TX rTsa7JtRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwESeZTAy3NjVx+lmYFN3l7vr Umb8vv7gBi7RZG/NN3ZPW8wfbJV+xvBXOMhkAqvQ1y2b2FR8rMwWyD6eZCvYtmG1jODSiBtu2+2 ZAA== X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The previous commit resets the subflow, instead of resending data that has been acked without MPTCP options, but only if this data had already been resent. Data acked without these options the first time was still resent once: a peer that had fallen back to TCP alone, e.g. because a middlebox removed the DSS of new data after a zero window probe, delivered it a second time to the application, without error. Track the TCP sequence number acked with MPTCP options, to also catch data acked without them the first time. Only before any MP_JOIN subflow has been established: after that, the peer can no longer fall back to TCP, and the Data ACK can be omitted when its value does not advance, see RFC 8684, sections 3.7 and 3.3.2. On a single subflow, a peer omitting the Data ACK like this can then see its subflow reset if this Data ACK is lost, as before at the next resend, or if it drops data after having acked it at the TCP level. This issue has been reported by Clashiko, and reproduced with a new Packetdrill test: data acked without MPTCP options was resent at the MPTCP level, instead of a reset: dss_resend_after_bare_ack_reset_server.pkt:28: error handling packet: liv= e packet payload: expected 0 bytes vs actual 1000 bytes Two other new tests check that this data is still resent after a join, but not after a join rejected by the peer. Fixes: 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st= data") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue spotted by Clashiko --- net/mptcp/options.c | 19 ++++++++++++++----- net/mptcp/protocol.c | 11 ++++++++--- net/mptcp/protocol.h | 2 ++ net/mptcp/subflow.c | 2 ++ 4 files changed, 26 insertions(+), 8 deletions(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index f9b65d0c6290..05b9c66aaed6 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1055,6 +1055,10 @@ static bool check_fully_established(struct mptcp_soc= k *msk, struct sock *ssk, WARN_ONCE(1, "bogus mpc option on established client sk"); =20 set_fully_established: + /* the peer can no longer fall back to TCP */ + if (subflow->request_join) + set_bit(MPTCP_JOINED, &msk->flags); + if (mp_opt->deny_join_id0) WRITE_ONCE(msk->pm.remote_deny_join_id0, true); =20 @@ -1287,11 +1291,16 @@ bool mptcp_incoming_options(struct sock *sk, struct= sk_buff *skb) if (!check_fully_established(msk, sk, subflow, skb, &mp_opt)) return sk->sk_state !=3D TCP_CLOSE; =20 - /* MPTCP opt acking the old data, not an infinite map: no fallback */ - if (unlikely(subflow->old_data_pending) && mp_opt.suboptions && - !(mp_opt.use_map && !mp_opt.data_len) && - !before(TCP_SKB_CB(skb)->ack_seq, subflow->old_data_end)) - subflow->old_data_pending =3D 0; + /* MPTCP opts, not an infinite map: the peer did not fall back */ + if (mp_opt.suboptions && !(mp_opt.use_map && !mp_opt.data_len)) { + u32 ack_seq =3D TCP_SKB_CB(skb)->ack_seq; + + if (after(ack_seq, subflow->opt_ack_seq)) + subflow->opt_ack_seq =3D ack_seq; + if (unlikely(subflow->old_data_pending) && + !before(ack_seq, subflow->old_data_end)) + subflow->old_data_pending =3D 0; + } =20 if (unlikely(mp_opt.suboptions !=3D OPTION_MPTCP_DSS)) { if ((mp_opt.suboptions & OPTION_MPTCP_FASTCLOSE) && diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 61cc4ae2a7b8..f3dd15293bc8 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1090,6 +1090,9 @@ static void mptcp_subflow_joined(struct mptcp_sock *m= sk, struct sock *ssk) { mptcp_subflow_ctx(ssk)->map_seq =3D READ_ONCE(msk->ack_seq); msk->allow_infinite_fallback =3D false; + /* an active join is added once fully established, see options.c */ + if (!mptcp_subflow_ctx(ssk)->request_join) + set_bit(MPTCP_JOINED, &msk->flags); mptcp_event(MPTCP_EVENT_SUB_ESTABLISHED, msk, ssk, GFP_ATOMIC); } =20 @@ -1557,10 +1560,12 @@ static int mptcp_sendmsg_frag(struct sock *sk, stru= ct sock *ssk, copy =3D 1; } =20 - /* old data acked without MPTCP opts: the peer may have fallen back */ + /* data acked without MPTCP opts: the peer may have fallen back, only + * possible before a join, see RFC 8684 + */ if (unlikely(before64(data_seq, msk->snd_nxt) && - subflow->old_data_pending && - !before(tcp_sk(ssk)->snd_una, subflow->old_data_end))) { + !test_bit(MPTCP_JOINED, &msk->flags) && + after(tcp_sk(ssk)->snd_una, subflow->opt_ack_seq))) { tcp_remove_empty_skb(ssk); MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_FALLBACKFAILED); subflow->reset_transient =3D 0; diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index dfeabe03180b..d0ae782c9ade 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -118,6 +118,7 @@ #define MPTCP_WORK_CLOSE_SUBFLOW 3 #define MPTCP_RTX_ENABLED 4 #define MPTCP_ORPHAN_COUNTED 5 +#define MPTCP_JOINED 6 =20 /* MPTCP socket release cb flags */ #define MPTCP_PUSH_PENDING 1 @@ -648,6 +649,7 @@ struct mptcp_subflow_context { int cached_sndbuf; /* sndbuf size when last synced with the msk s= ndbuf, * protected by the msk socket lock */ + u32 opt_ack_seq; /* highest TCP ack_seq with MPTCP opts */ =20 struct sock *tcp_sock; /* tcp sk backpointer */ struct sock *conn; /* parent mptcp_sock */ diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index a216d88d35ee..3590c1207e88 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -587,6 +587,7 @@ static void subflow_finish_connect(struct sock *sk, con= st struct sk_buff *skb) =20 msk =3D mptcp_sk(parent); subflow->rel_write_seq =3D 1; + subflow->opt_ack_seq =3D tcp_sk(sk)->snd_una; subflow->conn_finished =3D 1; subflow->ssn_offset =3D TCP_SKB_CB(skb)->seq; pr_debug("subflow=3D%p synack seq=3D%x\n", subflow, subflow->ssn_offset); @@ -2161,6 +2162,7 @@ static void subflow_ulp_clone(const struct request_so= ck *req, new_ctx->tcp_state_change =3D old_ctx->tcp_state_change; new_ctx->tcp_error_report =3D old_ctx->tcp_error_report; new_ctx->rel_write_seq =3D 1; + new_ctx->opt_ack_seq =3D tcp_rsk(req)->snt_isn + 1; =20 if (subflow_req->mp_capable) { /* see comments in subflow_syn_recv_sock(), MPTCP connection --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557695; b=JNN1AmbINKfd1KDex5lRlYCs/J2qN3+IqhR8W7BxPzt5JtoZVzC9iPq3KEDq7rk9iNFU S3u81WevRRlyErnXLJHAD9SLxNO2pICW6fs4tuO0YgaalukSxwj1BHLtUyKWzFgd2JxcX uqIAMkyrPyUmry39FJJK59sGUmafSNvpvq5vlyiwwryoDt/LNIQ7SOf1tJazv8/V0Ka92 hjAaoALv3NJVLhv9Uu74NfaoBzimHqvRWbVxek0qmont0Zx9+Jif4JLLK5rTrGcvg4zpm Tant2dMVKKs5U4ARkdsgtwZQnlFY/b+bxKYqgz2eX6T7D8hi1y1RAA6xa4LXQjsbbsw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557695; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=JGna/U+3lUN2A873tE+UyJObLaKT7mtIxa9mi776ucs=; b=t7sewCxNaq6CsLQnZ3pWBIRvKY1IRbkt1KDIgSEdEFTvgmiSMynNuJTSFLyrMMjkspMV ckX9PhLwSb0RJVR9hl1IApldm60wNnpr5068NKvOXzJ3OisGZbto4c5mZ5bGSRrGhOlHX WFOp39wsoWbCckKOzu0UEvOyIrEG/opZhulHzweQVl9KIisF0+CMAHHTc0hjfush6KJEq V7SP6RseAKyvOGn7EgrH/QK207VzIzajQZ6ieAf4CbP/QFqxwaCqNZP8HLDWlASO61WSs yCHh0gs1EY0FXN57BrPug7g1KVqO2ZEhRQzYfQsQKoR/H3/HapMzZUfh//1S+hlcNFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyCHbF+A; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78AB2606A321 for ; Tue, 24 Nov 2026 22:01:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CyCHbF+A Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6319D1F000D1; Tue, 24 Nov 2026 22:01:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557695; bh=JGna/U+3lUN2A873tE+UyJObLaKT7mtIxa9mi776ucs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=CyCHbF+ASGPQiqEJDC0hbCasv7bCkRV0xJnT52mQVYK+2oIxHxO9wlXVrUbd81wlD n4DSGRHDuuERHT92v/gwAZepXEQfblEMVgNqks7STjM5Qc3OCeiYD06bD6Jd2fwA/w XyLoXfKAZAmkxYr6dgTN6SxURxwdn0XsoP5qfko5F7g6obEs719+bDNhjNNHlfoDxu 4/nILyBF8CF3GrYyE+oIbRJXMofwmc/HjBplaQX/pUoR4n1UeU8IhgE3yV8CB1hQzZ +VOPgidZ4Zi8OWqW6JPvRseMAA251Ogbqyz9SmQfWIipde7tVUdSjp4c1GmROXtTh8 ugEkaltxsfZkw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:47 +0100 Subject: [PATCH mptcp-net v3 30/50] mptcp: pm: kernel: don't count signal+subflow ID 0 endp X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-30-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Josef Bacik X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3093; i=matttbe@kernel.org; h=from:subject:message-id; bh=5aj4X1VngcnbQopcabjUhJtSELjGQkg8VtpA8/I8OX4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZODk1BV0jG7Vtluds2imXatdn5Poy79bSnk2zdliWG tZZdPN1lLIwiHExyIopski3RebPfF7FW+LlZwEzh5UJZAgDF6cATORzGcN/j6my759KS8X/XjLJ bvuEr6e63kmK2/71OdvVzK/H5DfhH8Mf3uIz2mx9M1ov3/Pds4K97uZrHuF/mXIn5s/gaupy2xX DCAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Josef Bacik local_addr_used must not be incremented for the endpoint of the initial subflow, because __mark_subflow_endp_available() does not decrement it for ID 0. mptcp_pm_create_subflow_or_signal_addr() tells that endpoint by local.addr.id =3D=3D msk->mpc_endpoint_id, in the loop that creates the subflows and after it. For an endpoint with both the signal and the subflow flag that comparison comes too late: the part that announces the address has replaced local.addr.id by 0 already. So the counter goes up each time such an endpoint is removed and added again while a connection that started from its address is alive, and never comes down. When it has reached the number of subflow endpoints, the connection does not use any new endpoint: after four rounds local_addr_used was 5 instead of 1, and an endpoint added then got no subflow. ID 0 can't be the ID of any other endpoint: look at that, after the replacement. This issue has been found with the help of an LLM. It has been reproduced with the modified "delete and re-add" subtest of mptcp_join.sh, from the next commit: without this patch, the subflow of the ID 0 endpoint was not created again at the third round, local_addr_used being above local_addr_max: # 002 delete and re-add [...] # after re-add id 0 (3) [FAIL] got 2:2 subflows expec= ted 3 [...] [...] subflows:2 [...] local_addr_used:4 local_addr_max:3 [...] The check after the loop comes from commit 579a752464a6 ("mptcp: pm: in-kernel: always mark signal+subflow endp as used"), which is in all the stable versions having the commit below. Fixes: 9366922adc6a ("mptcp: pm: fix ID 0 endp usage after multiple re-crea= tions") Signed-off-by: Josef Bacik [ Keep the original one-line comment. Commit message: 'behind it' -> 'after it' + how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/pm_kernel.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/pm_kernel.c b/net/mptcp/pm_kernel.c index 73261685ae4c..47c6ccb0a29e 100644 --- a/net/mptcp/pm_kernel.c +++ b/net/mptcp/pm_kernel.c @@ -411,7 +411,9 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct mptcp_sock *msk) /* Special case for ID0: set the correct ID */ if (local.addr.id =3D=3D msk->mpc_endpoint_id) local.addr.id =3D 0; - else /* local_addr_used is not decr for ID 0 */ + + /* local_addr_used is not decr for ID 0 */ + if (local.addr.id) msk->pm.local_addr_used++; =20 nr =3D fill_remote_addresses_vec(msk, &local.addr, fullmesh, @@ -432,7 +434,7 @@ static void mptcp_pm_create_subflow_or_signal_addr(stru= ct mptcp_sock *msk) * case. This avoids issues later when removing the endpoint and calling * __mark_subflow_endp_available(), which expects the increment here. */ - if (signal_and_subflow && local.addr.id !=3D msk->mpc_endpoint_id) + if (signal_and_subflow && local.addr.id) msk->pm.local_addr_used++; =20 mptcp_pm_nl_check_work_pending(msk); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557697; b=KV6PpTr6YxSWIj8G8Rdm/T8d/milkIc3DdawcBCaxDfiNzYn+W7J1dn3Hz+8tA2+5e/X Tz0Vo2awpgD7XRM3gelD2PAJBWzzN34goYyu19F3HwEjClspeB8cPPJmd/aOM+E5zcrxB 8HFyr++1Pd/z6ZLI5KgqEABrvfWE0vmemA+cIjSFIaUEpz/IznA6UqBgC40S9MX3q/u9Z YA5M63/XbwZNs9KuCZbFMf9/9zzF56rc+gRHsbQ8neQuzraMyP5qDS7OtLp3Pb099flGx 4yagdw0gJSVHjcp6qKHudmiGy2bWJQT4GYCwYG6CwxYF6BkYwYWHHEYUfqDnmESR2rA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557697; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=wbAbnYLs2apZxN093TzfpkoYrML8/18qG1jS6EmpIZs=; b=LECRhGRTFfB8Ufg6tzeS1POCGG8z80YyPEpO3FvIc+JuA1k6iyK3UsrwPyT/P+qCF8a7 +4kHg2G2lQd6Dh2gizW8uv4Iqka5QX/ghLjlR7ctUgHVLhCy+a8TbGogG/e/bX4gpD8pB QmHv88My1opeiuf5OZ7MROXPjZ9PpSQd5j+wx0Ywr8PjGcNxUoLHUHmqX95JWNIn+Rf5z yTbsclVaPcwaWT1rYb56YNUVjNh44PADji2jbqYAvXB6Sk8kPVzBJRtqKuTqPQwHoDYQT aEmDdECGIIZgdWn4ertgYrtPASHDDYnRrwTvBPtbCfhyxfq1NS9XpXUs/wM9aYlec+A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YxKtxGrs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00773606A321 for ; Tue, 24 Nov 2026 22:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=YxKtxGrs Received: by smtp.kernel.org (Postfix) with ESMTPSA id B7EB81F000D1; Tue, 24 Nov 2026 22:01:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557696; bh=wbAbnYLs2apZxN093TzfpkoYrML8/18qG1jS6EmpIZs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=YxKtxGrs7/DpqWBMi7zA+nZKQlBOI7pYoXf0Hx9xZBQXeUgkEeOX8kLonRoae/dg4 Whk5DFWDYYoT47MIJK6X/DToJ3IPziLQMCgjwya+mX1NW3E/OwVUPTIHri5efJOhj8 /JlyeTaLnzkZovuMkFUzd0+cImbpL87at+R4ZB7fhf12clpv7JOavdgKmXOKO03yoe inqLpqajI4iATm15Txl1kmg8OSQ1HPG/x9WdFZr1rZpgNd6LIJVP+55Zqy5+v9qPZL GT5/d8rC8JQmUsCmBhayf3taOMD5oGYr3dL5X1WITDt8ItL5i6dGZwauldEkOEjDGO vrvvPt8ArHpnw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:48 +0100 Subject: [PATCH mptcp-net v3 31/50] selftests: mptcp: join: check re-adding signal+subflow ID 0 endp X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-31-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2981; i=matttbe@kernel.org; h=from:subject:message-id; bh=gTxHTW3EiHcEbebTLKtci6ohXctGsjdpDOtO1WTEqRo=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOLm+1c7sben4sVn+5F4lx4v93lXKd39bvtLX1Q5e1 vig8uznjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlIpzD8D/StmveBN+f8uke8 BwUnds108ZJds++22dLNyVoBi5NL8xgZzt6b80/HqIIjLvjOBAfBbZ92Hnw3UUvc7GzF3OVvJM9 MYwQA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 This test extends "delete and re-add" to validate the previous commit: when the endpoint linked to the initial subflow (ID 0) had both the signal and subflow flags, it was counted as used each time it was re-added, while this counter is not decremented for this special endpoint. Once the counter reached the number of subflow endpoints, no more subflows were created. From the second round, this endpoint is now re-added with the signal flag too: without the previous commit, the subflow is not re-created at the third round. The ADD_ADDR sent at these two rounds are dropped, and not retransmitted: if the server received them before the new subflow, it would try to connect back to the address and port of the client, and fail, which would change the counters. If they cannot be dropped, e.g. with an older version of nft, the signal flag is not added, and the subtest is marked as skipped. The 'Fixes' tag here below is the same as the one from the previous commit: this patch here is not fixing anything wrong in the selftests, but it validates the previous fix for an issue introduced by this commit ID. Fixes: 9366922adc6a ("mptcp: pm: fix ID 0 endp usage after multiple re-crea= tions") Signed-off-by: Matthieu Baerts (NGI0) --- v2: skip the signal part if the nft rule cannot be added (Clashiko) --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index c3ccce96b45b..4c045532f137 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -4387,17 +4387,26 @@ endpoint_tests() ip netns exec "${ns2}" nft insert rule ip filter OUTPUT \ ip saddr 10.0.1.2 meta l4proto tcp \ "${RM_ADDR_OFFSETS}" drop || nft=3D0 - local i + # No ADD_ADDR to ns1: it could try to connect back to ns2's port + local i flags=3D"subflow" signal=3D"signal,subflow" + ip netns exec "${ns2}" sysctl -q net.mptcp.add_addr_timeout=3D0 + if ! ip netns exec "${ns2}" nft insert rule ip filter OUTPUT \ + meta l4proto tcp \ + tcp option mptcp subtype add-addr drop; then + mark_as_skipped "unable to set the 'add addr' rule" + signal=3D"subflow" + fi for i in $(seq 3); do pm_nl_del_endpoint $ns2 1 10.0.1.2 sleep 0.5 chk_subflow_nr "after delete id 0 ($i)" 2 chk_mptcp_info subflows 2 subflows 2 # only decr for additional sf =20 - pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags subflow + pm_nl_add_endpoint $ns2 10.0.1.2 id 1 dev ns2eth1 flags "${flags}" wait_mpj $((3 + i)) chk_subflow_nr "after re-add id 0 ($i)" 3 chk_mptcp_info subflows 3 subflows 3 + flags=3D"${signal}" # ID 0 not counted as used either done [ "${nft}" =3D 1 ] && ip netns exec "${ns2}" nft flush chain ip filter O= UTPUT =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557697; b=ERw7Kq7tqhWCCv4gztyMSm4oiJk80un3S4P1yFHtN0SnuFAVLvEZaYCvipm9gbi6yWou suL90vdglzDutgPGnNmafghj7clL4TyzbhINXbTl10tyctzaH8ierfAuVhqpz7UnOC3tw oeK2VTsbB4j1lJyuu56DpqiH6kr8OLManlfk0z/TCTugnLSh6Z+6JqZzj6yruR4wrOJfx NrkFHxNAen215f9H3LbFUK6z+YZSCuQB6EuORCnByXGdIZCSBj6C+73BLoMiCMBkJIe2e BVhrqgA66qre2qc2bbkohORI3j5A4UBSKp/tGBU5Qm16PnPxpXyQ53YfsK/gz2qwCbQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557697; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=MSb2J0ZqhG2VmwfH23ZJbs/41OHMAOYAQLojgljwPa4=; b=fQGDKKATwmsRr0Ij2Yl2g3fLbk9wIFIefmFdGvMsHUk2BwQv8dm9WMjY7/Ex/Fuc8xJf Frf7J/O65Fh9CP1zL3cGnFWbTgLMB++dPwO0H5896HdfnMvNm0EmPEiEnEFTw1VT6ppaR aKplrwkGRuizpOkAl90oavxifACNAY9uctPlFcswCLAZ3fhrJI2EvbU+2vzVWPll9V4hP 5UBgdRmsFRX3JVmP1174K4NECaXws65viuThP/sSyTio2eKVPJmb91T50nCwttHm8soLV jVqzrFJocV+YtwsfDG7TTBoVIRp2N06XwXdfrPKMCMoa4ikCOUxN2aMgUZNYX5AxpWw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HMRHk11Z; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D0414606A31E for ; Tue, 24 Nov 2026 22:01:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=HMRHk11Z Received: by smtp.kernel.org (Postfix) with ESMTPSA id 008601F000E1; Tue, 24 Nov 2026 22:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557697; bh=MSb2J0ZqhG2VmwfH23ZJbs/41OHMAOYAQLojgljwPa4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=HMRHk11Zuc9jqAzq5epRJodI0ypq1Zq9gQQOADzv4MN8Z0qvsGoqu/A1j5uzhiGj6 Su/WIbq4vEFMtIb54abcTMKZ/C9cs9xo9FTVbeh8oAT0ziORfQ8ZZrS69FK+KQhqX7 uy26mMWVLbMA75mQBl+QlaxNX+D3gMUQ9n30WxRjofnakGGEUptrNEht40+jCmCI9A DKhl4VrNtUjRVbh2YRGFbULcff1KakcYHyvbXpCGA71z/2BV87krhdL6h5XBh0PuD/ s9xK5glVzx3BnJcCRBm0bbjSQcqrvO9/dQfg4EuVRd9mFWoNoO9UWYxgupoP+qLdxn tQZFl4in0z6xw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:49 +0100 Subject: [PATCH mptcp-net v3 32/50] mptcp: reclaim forward memory after coalescing skbs X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-32-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3133; i=matttbe@kernel.org; h=from:subject:message-id; bh=kI2nu9d4O553MYbh4Xf7mn+DNy11OkedNos71ZehiQY=; b=kA0DAAoWfCLwwvNHCpcByyZiAGsGCQqhK6TAuy45gPcd1ft/Ou6W5kaaU2fN8cu94eCuldkfL oh1BAAWCgAdFiEEG4ZZb5nneg10Sk44fCLwwvNHCpcFAmsGCQoACgkQfCLwwvNHCpfZmwD/fSod 25AVwCMc4dd4FbjBcAZiBMLbQerdQ+stY5O9RzAA/3dcBj1eSSuX/V0vJzxwTk1e/bM8n6xLERx OlnnW9nAP X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason If MPTCP sockets receive many small segments whose data stays queued, TCP can stall on the whole host, and an MPTCP server can be OOM killed in its memory cgroup, although almost no memory is in use. When the MPTCP socket (msk) takes over an skb from a subflow, mptcp_borrow_fwdmem() adds skb->truesize to the sk_forward_alloc of the msk, and the subflow reserves new memory for the next skb. Both sk_forward_alloc and sk_rmem_alloc count against tcp_mem and the memory cgroup, but only sk_rmem_alloc has a limit, sk_rcvbuf, so what queueing the skb does not move to sk_rmem_alloc has to be released. But mptcp_try_coalesce() moves only the increase in truesize of the skb that receives the data, and skb_condense() in mptcp_data_queue_ofo() can lower skb->truesize, so the rest piles up in sk_forward_alloc. The fix used here is to return every whole page of sk_forward_alloc with sk_mem_reclaim(), in mptcp_try_coalesce() once the merged skb is freed, and in mptcp_data_queue_ofo() once the skb is queued. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch: a remote peer sends 33000 segments of one byte after a hole in the data sequence, which are merged in the out-of-order queue. Without this patch, the memory forward-allocated by the MPTCP socket -- msk_f -- grew with each merged segment, above 29 MB, versus 3200 bytes with it: SNAP label=3Dstage1-1-connections tcp_mem_pages=3D7168 [...] msk_f=3D2944= 5248 [...] [...] OFOQueue=3D33000 OFOMerge=3D32862 [...] With more connections, the original version of this patch reported that the TCP memory went above tcp_mem[2], stalling the other TCP connections, or that the memory cgroup went above its limit. Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow") Signed-off-by: Chris Mason [ Shorter comment. Commit message: the rest of the borrowed amount has to be released + how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- Note (Clashiko on v2): with an owned skb, the new reclaim is a no-op, sock_rfree() having already reclaimed: the comment is for the borrowed skbs, the ones needing it. --- net/mptcp/protocol.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f3dd15293bc8..f8cb585da0b3 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -197,6 +197,9 @@ static bool mptcp_try_coalesce(struct sock *sk, struct = sk_buff *to, sk_mem_charge(sk, delta); kfree_skb_partial(from, fragstolen); =20 + /* release what is left of the borrowed 'from' truesize */ + sk_mem_reclaim(sk); + return true; } =20 @@ -422,6 +425,9 @@ static void mptcp_data_queue_ofo(struct mptcp_sock *msk= , struct sk_buff *skb) end: skb_condense(skb); skb_set_owner_r(skb, sk); + + /* skb_condense() can shrink the truesize borrowed from the subflow */ + sk_mem_reclaim(sk); } =20 static void mptcp_init_skb(struct sock *ssk, struct sk_buff *skb, int offs= et, --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557698; b=jHfUCNfzoMSZMQ7a+2XKjfhPSVZoSAf+E1i9/92kdC/45CduRmZdtLvvcRWCwqNWXi86 uv2IhHH85Yzz3s6FDmPlZoPsODJsJjcKH8SYvQXAAJd7XHo+jK8B8twqy0JzGVjpZZ62F j7synGmZmlaV+nPFIOVE6mLE8qODRV4tVLOc+rh8mmynJ/z9F4agieC2wo2ijXb0UULDN OT52Zp4f4uNVu3B5jSrf8TvkbG6rERetGuA0C3tf3s77qk/k//QJDXvGfy/ll3dZdiw4Q 5tapEy2neqiKhL/AgFF7tV6jFOJVeCV6ISfep6PhSrVGT+5LlGwsLUGwDT47z+38vlQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557698; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=tqIiU8oA3Ea6GzOf3YO9Deukk0xTiDwg/VILq8hG/NQ=; b=DZiR4y7RtkKf7BuYCqnmjt9GM8RDO0tZZM5lMMJ/4B5lhZCKdmHbRb6Km1dunyzBTFYH qPsbRtHakuFRUpnDAhm/6iW0TM1zayHDm1+DtaiYbwT9BFZPLM4V01H/PV1cAIDk9aphr GLuYuZs8q4tlkGR39OPmPP6LmEQqeF3NGHrLxrhEuge2BFbz2DuV1KrILq7v5Hxmc+sci /qgjg2v5gY0f3+evs9fa1Zx0hcXXzuPBGxG/EcBSON2z2hSpNGFL/YOcwu/XS5EyCTBJu FLQXsTzZECJUOwKZ7EK3YMC7GBXvsImAJWH8VchdmSdPi18Ci1zZw0Eq+hiZ3bQbDXg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D3X1fbfL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D895B606A31E for ; Tue, 24 Nov 2026 22:01:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=D3X1fbfL Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE3281F000C0; Tue, 24 Nov 2026 22:01:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557698; bh=tqIiU8oA3Ea6GzOf3YO9Deukk0xTiDwg/VILq8hG/NQ=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=D3X1fbfLsIBGw7lHnxOBg4BjcTrXVh4zuP7BppHhNGTndFR2ZhIHG3z57zLwF5+Fw ZQ8faAc00MEQ5XL40eCukMOdQf9u5JWDylNHsVqIykyWRTX5dqC7f9VCd7IojNaBFO WEJk27WMF/bECXNPO6HvdOcgHebfgFu0QtSM+cgjmaSM+XhCN7nIdzt5qeWYOUsLVx P88WL+VLoyklo3Q7LsEqHP/zbVrPmhkx16eeX+5jkU0nk46P6qT8pugq/TKxOPZPuk 07hL/ad2cky4IkIqAnQByxY8FOAm9lRcdOSQ33hzop/rDqtCBDVg5pF/cZeusjIbCm AVU5O04dYYokA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:50 +0100 Subject: [PATCH mptcp-net v3 33/50] mptcp: don't charge a shared page twice at accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-33-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3830; i=matttbe@kernel.org; h=from:subject:message-id; bh=3M+uO3msi9DlDnR0ux8zXB1gpWarWZ39JrK6SLoroH8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOLktOk494b0935zNYYqxDXubskFQ6uc683XVtmynn x56lq7UUcrCIMbFICumyCLdFpk/83kVb4mXnwXMHFYmkCEMXJwCMJG7kYwMH/L/d7SpT82afuFL 3J83ky6xXM16bqtjYvOr/c9kuWd74hkZ5on/0hZZ2xLxWlv1h9Tle+sbPd6tKrOdoy2j8P/csaJ 6fgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason accept() of an MPTCP connection that has already received data can leak one page of memory cgroup charge, and the leaked charges can get the server OOM killed. At accept(), __inet_accept() charges the MPTCP socket (msk) for the memory that it holds, rounded up to whole pages, and mptcp_graft_subflows() does the same for each subflow. A page is uncharged only once, when the socket that holds it releases it, so rounding up each socket on its own is only correct while each page belongs to one socket. But for each skb that the msk takes over from a subflow, it borrows skb->truesize bytes from the pages that the subflow reserved, so the two can share a page: reserved by the subflow 4096 bytes 1 page now held by the msk 896 bytes charged for 1 page still held by the subflow 3200 bytes charged for 1 page The fix used here is to keep a running sum of what the msk and its subflows hold, and to let the new mptcp_charge_subflow() charge each subflow only for the pages that it adds to the rounded-up sum. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch: an MPTCP server in a memory cgroup, the first byte of the client arriving before accept(). Without this patch, 4096 bytes stayed charged to the memory cgroup for each connection, after its end: SNAP label=3Dafter-1000 rounds=3D1000 sockets_left_in_srv=3D0 [...] c_soc= k=3D4096000 [...] SNAP label=3Dafter-5000 rounds=3D5000 sockets_left_in_srv=3D0 [...] c_soc= k=3D20480000 [...] With a memory limit, the original version of this patch reported that the server was killed by the OOM killer after about 14,400 connections. Fixes: 9db5b3cec4ec ("mptcp: borrow forward memory from subflow") Signed-off-by: Chris Mason [ Shorter comment. Commit message: how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- Note (Clashiko on v2): the backlog can still be charged twice here: this is fixed by the next patch. --- net/mptcp/protocol.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f8cb585da0b3..504fe4a9954f 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4664,10 +4664,26 @@ static int mptcp_listen(struct socket *sock, int ba= cklog) return err; } =20 +/* The msk and its subflows share pages: charge their rounded-up sum */ +static int mptcp_charge_subflow(struct sock *sk, struct sock *ssk, int mem) +{ + int new_mem =3D mem + ssk->sk_forward_alloc + + atomic_read(&ssk->sk_rmem_alloc); + int amt =3D sk_mem_pages(new_mem) - sk_mem_pages(mem); + gfp_t gfp =3D GFP_KERNEL | __GFP_NOFAIL; + + mem_cgroup_sk_inherit(sk, ssk); + if (amt > 0) + mem_cgroup_sk_charge(ssk, amt, gfp); + kmem_cache_charge(ssk, gfp); + return new_mem; +} + static void mptcp_graft_subflows(struct sock *sk) { struct mptcp_subflow_context *subflow; struct mptcp_sock *msk =3D mptcp_sk(sk); + int mem; =20 if (mem_cgroup_sockets_enabled) { LIST_HEAD(join_list); @@ -4685,6 +4701,9 @@ static void mptcp_graft_subflows(struct sock *sk) __mptcp_flush_join_list(sk, &join_list); } =20 + /* What __inet_accept() just charged for the msk, before rounding up. */ + mem =3D sk->sk_forward_alloc + atomic_read(&sk->sk_rmem_alloc); + mptcp_for_each_subflow(msk, subflow) { struct sock *ssk =3D mptcp_subflow_tcp_sock(subflow); =20 @@ -4700,7 +4719,7 @@ static void mptcp_graft_subflows(struct sock *sk) goto unlock; =20 __mptcp_inherit_cgrp_data(sk, ssk); - __mptcp_inherit_memcg(sk, ssk, GFP_KERNEL); + mem =3D mptcp_charge_subflow(sk, ssk, mem); =20 unlock: release_sock(ssk); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557700; b=o94CgrADci/i65iADhUn6g9GULf7APT93pHSYRcElsd34Gh9jQXuJ1Mc19+KE5ZMkOXg 47fgRywX+h+D1g3VOt9uQ3i3sS4ecR40JZ37oByk2szRCH0HEJA2ZyCbZCx3VDGMiTZzS x50ltRqIh+EFseG4IW6vrXVWLMPlWDkwS+zJZyze3Sc//voGRSrqwYaKLVxKYWYyCIbIC DNKBVoWt0uKKCtxz/ltgtbRvGveCKWSarF6VwIDgbU0cv+ckvtfWCHuoXVF5IUURQXQUB tIHPjnFJJeXV39qKt35vNx5Ebo7m1RRhbw6fUcGScC1Ow7/II8BXhn43zCBBT+r6Xxw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557700; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=7pRhur8ZGxhqu3F51REZblc0i0b68VtaqNjP9V5f5K8=; b=xfIt1DPrzxKhv1skKfoM+6abeMCskAykL3mEUjxSxc3p48d7lU+YKm+dL/wURzV85MZ+ bF19fY9o8mb86OnL+CB1K8/Zsr53ezEiEQOYfeBOplx+W+uklAHItgnELgIgbgt0+1W0m CevxUws7BNiup2lAnK7O28V2hnKOrV4MFV7V48siKUXMvPMxCw6fLFWG3N8OTWMtqdkfD dD6SEAFVr8APtOFzODRIc0Y7TGuyRxin6r/3rIzG1RWH/cWNTKni8ajU+vYG4UrIxGiPW S7Ui01OexRN/zLSZp+lQkFMi93aIRRmIJJAd/muq/HaIyUoMyB3LkKaSVlfOyJvAPQg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WRSSI9Nz; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 21EC2606A31E for ; Tue, 24 Nov 2026 22:01:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WRSSI9Nz Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1F0E71F000C0; Tue, 24 Nov 2026 22:01:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557699; bh=7pRhur8ZGxhqu3F51REZblc0i0b68VtaqNjP9V5f5K8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=WRSSI9Nzn1/0MNF5jZUN4Zdh8HohQ8w/PrV+ieeg3Iv35iJ1kWEaAvErB8chGwcmD PsDLLLP7TgKnXhzmXNz0LSQ5kydtF/bq5ax+K3/g7ZqYcO4X2niIsz85aacUc5ZNj2 +3NEKOd3hrXukwmxDSdRwJiCCDrryfwhXVuIv0do/4Sfa6wL+7P9gt1k2XyhaSJ8hU GTFxGvbbEvNS8MR9kIBs53m1hIwVV4jDlsHtVuGg/FgpCXCItWPbPeDtS+s1JQtxVM e7kdONikCCX39W254zWkIF6Pq3o6RpqpyWM/5QoUoQ8x6NMAbfA6xIrwS7Z7AWJzNA 7Ab8CK3a+vmDA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:51 +0100 Subject: [PATCH mptcp-net v3 34/50] mptcp: don't charge the backlog twice at accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-34-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=5181; i=matttbe@kernel.org; h=from:subject:message-id; bh=ViU/v4vjAFCtLCIc8A18W+U8OR1e85ZfOGtR/5xOMWA=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOHnmv9dLX1h/0G6mh06aT2jVBCfRZcePZL7judFy7 uDqTyr8HaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABPxmM7I0PUk7d6uZRKy6+wO bLzMoWJkLyW07MDtrP69767Y905508jIMC/zOF+zeVhU86p/oQvLlq25kXWl3C7igCtLT4SYy5n jTAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason accept() can permanently overcharge the memory cgroup of an MPTCP server, so the server can be OOM killed, if the new connection received data while its MPTCP socket was locked. The sockets of an MPTCP connection have no memory cgroup before accept(), which then charges the sk_forward_alloc and the sk_rmem_alloc of the MPTCP socket (msk) and of each subflow. mptcp_graft_subflows() also charges msk->backlog_unaccounted: the truesize of the skbs that __mptcp_add_backlog() queued while the socket lock of the msk was held and their subflow had no memory cgroup. But the first charge already covers each of these skbs that has not been freed, in the sk_rmem_alloc of its subflow or of the msk, so no later uncharge matches the extra charge. The fix used here is to remove msk->backlog_unaccounted, its charge in mptcp_graft_subflows() and the warning that tests it in mptcp_can_spool_backlog(). An RFC patch [1] removes the same lines, as part of another approach. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch, on a kernel with the previous patch: 100,000 connections to an MPTCP server in a memory cgroup. Without this patch, about 63 MB stayed charged to this memory cgroup once all the connections were closed, and to its parent after its removal: SNAP label=3Dafter-100000 rounds=3D100000 sockets_left_in_srv=3D0 tcp_mem= _pages=3D0 [...] c_sock=3D63295488 [...] [...] SNAP label=3Dc-removed rounds=3D100000 sockets_left_in_srv=3D0 tcp_mem_pa= ges=3D0 c=3Dremoved [...] p_sock=3D63295488 [...] And about 12 MB with only 50 connections, each getting 20,000 duplicates of a byte before accept(), beside bare ACKs with RM_ADDR, which make the MPTCP worker take the socket lock: SNAP label=3Dafter-50 rounds=3D50 sockets_left_in_srv=3D0 tcp_mem_pages= =3D256 [...] c_sock=3D12881920 [...] Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing") Link: https://lore.kernel.org/all/20260924080219.1036588-4-caixinchen1@huaw= ei.com/ [1] Signed-off-by: Chris Mason [ No comment change: the commit message explains why the backlog is covered. Commit message: refer to the RFC [1] removing the same lines + how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 35 +---------------------------------- net/mptcp/protocol.h | 1 - 2 files changed, 1 insertion(+), 35 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 504fe4a9954f..c9ef23276399 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -802,12 +802,6 @@ static void __mptcp_add_backlog(struct sock *sk, =20 account: WRITE_ONCE(msk->backlog_len, msk->backlog_len + delta); - - /* Possibly not accept()ed yet, keep track of memory not CG - * accounted, mptcp_graft_subflows() will handle it. - */ - if (!mem_cgroup_from_sk(ssk)) - msk->backlog_unaccounted +=3D delta; } =20 static bool __mptcp_move_skbs_from_subflow(struct mptcp_sock *msk, @@ -2456,12 +2450,6 @@ static bool mptcp_can_spool_backlog(struct sock *sk,= struct list_head *skbs) { struct mptcp_sock *msk =3D mptcp_sk(sk); =20 - /* After CG initialization, subflows should never add skb before - * gaining the CG themself. - */ - DEBUG_NET_WARN_ON_ONCE(msk->backlog_unaccounted && sk->sk_socket && - mem_cgroup_from_sk(sk)); - if (list_empty(&msk->backlog_list)) return false; =20 @@ -4691,8 +4679,7 @@ static void mptcp_graft_subflows(struct sock *sk) /* Subflows joining after __inet_accept() will get the * mem CG properly initialized at mptcp_finish_join() time, * but subflows pending in join_list need explicit - * initialization before flushing `backlog_unaccounted` - * or MPTCP can later unexpectedly observe unaccounted memory. + * initialization by the loop below. */ mptcp_data_lock(sk); list_splice_init(&msk->join_list, &join_list); @@ -4724,26 +4711,6 @@ static void mptcp_graft_subflows(struct sock *sk) unlock: release_sock(ssk); } - - if (mem_cgroup_sk_enabled(sk)) { - gfp_t gfp =3D GFP_KERNEL | __GFP_NOFAIL; - int amt; - - /* Account the backlog memory; prior accept() is aware of - * fwd and rmem only. - */ - mptcp_data_lock(sk); - amt =3D sk_mem_pages(sk->sk_forward_alloc + - msk->backlog_unaccounted + - atomic_read(&sk->sk_rmem_alloc)) - - sk_mem_pages(sk->sk_forward_alloc + - atomic_read(&sk->sk_rmem_alloc)); - msk->backlog_unaccounted =3D 0; - mptcp_data_unlock(sk); - - if (amt) - mem_cgroup_sk_charge(sk, amt, gfp); - } } =20 static int mptcp_stream_accept(struct socket *sock, struct socket *newsock, diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index d0ae782c9ade..9a9dbab672af 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -394,7 +394,6 @@ struct mptcp_sock { =20 struct list_head backlog_list; /* protected by the data lock */ u32 backlog_len; - u32 backlog_unaccounted; }; =20 #define mptcp_data_lock(sk) spin_lock_bh(&(sk)->sk_lock.slock) --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557701; b=kRnBkmsUjWmzDwFHSLzMQqyGzvYcuSvnhqXKuZe3hfvNtWZtBiqK3kHoBzDkD69TDU/6 PO5WkptvHHKq7//q2tkE9Yfn+zTmSn5473u1xQITCP6V1OOmOwUu+5Np9GhsZHAsSuSvF 5+EqvGri2xmxnr8cZniqxI+nxQkH+jNnTg5yw99uD12L8hqmch9Q5rsx4OD0gnSC22dFF qy+WFI2W+Vhf/vQvCCtrjTi01r6P/Q+dPOTW3XHBDSFVNGeDR3m+VEz0yR61jDKTpod05 zt8uVVw22O+FRinhwN7cWF4xiQ82GbU9VZmWP5jIIsJcK6WbnItn9A6Re6QLTnPZubw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557701; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=Go74yThHBrsGIdc8q8T69DSh++6U4M/PkWT1eGOmrMM=; b=c0sIBjZWNBqoj25Tgu9Of8troySqucSE/uTqBDm/+sRCl55Vi7+Euz/oQ1qLOr3U3GLc YWCX/T3JCks3WEnOZ1jPD58TDVOy2RwUH5ZL2fEeDu8MD+kIZWooG4VEAu5/5GiDdcHIW nkPiSczVXnf+VkcQN6TkDOmQ5oSajRHg4VWsLTDCSp9vclEpTDR4JZuyoHR/ShP8PJAAI PTiVFxvDjlTuLH+VQkMdYSrbXWriuECcNf1PvqZDBI8l+tCnRX/k8no0aENZpav69AhC0 J+rLF6LiWgiG6HQlJuWFqjA1+N0uEFzhLtZbfLBs7oRq0xj0l+cnz7/fYeCwEDzvBiQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KE4YuMZ6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 52DC0606A31E for ; Tue, 24 Nov 2026 22:01:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=KE4YuMZ6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5FEF51F000C0; Tue, 24 Nov 2026 22:01:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557700; bh=Go74yThHBrsGIdc8q8T69DSh++6U4M/PkWT1eGOmrMM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=KE4YuMZ6D8LzwxT4hyumc9LvNFDdKx3Jjo4u+1Q4duu42YS2W2TGdLyJBHxfYDMis vFZKnKwltazZOcTW2oueixF1dMUw+ogzSb99BZoWHnaelItmpKZkSQWVs+ybnF9Aoc eaBT/hzbmrtu2klNyO50Y1CtiTFmj1kOdupGhGqEarSUaJC0F2lM044I9VrlbDfT4S 2A9e0lcRTQ47ObpWA9KyaR+PP/zmJjDtbirz+U+HEGQcg56hu3IbuN0pPYDMcFBa5G YCkgea1IRoSb1ig9xdSCb6XHQulh9l8657N4wQEhDzlAlZd5D4RaBWJ40TpoOlx0kQ F0/bxNw2+cNqA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:52 +0100 Subject: [PATCH mptcp-net v3 35/50] mptcp: don't charge a subflow twice when it joins during accept() X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-35-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3140; i=matttbe@kernel.org; h=from:subject:message-id; bh=c2+ix/HGvshaaudfQy1jEBX8gZQBc0AgBNBUND/L2DE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOHm+ey1pvjxdcmXU912fzvT0vZRYfM7nz+eMCiWtr ffTbpxX7ShlYRDjYpAVU2SRbovMn/m8irfEy88CZg4rE8gQBi5OAZhIUwPDf9dVrC15BwWEOHLc djSuiFu6M+vPdYbz1dHTtnTdM/QTdmRkuMjbUp4ayGxSeOa9r63kXr5+p4271th933Pf3JJ15iV uFgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A subflow that joins an MPTCP connection while accept() runs can be charged twice to the memory cgroup of the server, for the memory that it already holds when accept() charges it. Nothing removes this extra charge. At accept(), __inet_accept() gives the MPTCP socket (msk) the memory cgroup of the caller, then sets its sk_socket. From then on, mptcp_finish_join() gives this memory cgroup to a joining subflow, via mptcp_sock_check_graft(), and each page that the subflow reserves is charged. Because accept() owns the msk, such a subflow is added to the join list, which mptcp_graft_subflows() moves to the subflow list before charging each subflow for the memory that it holds. A subflow that joined in between is then charged a second time for this memory, which will be uncharged only once. The window is short: from the end of __inet_accept() to the start of mptcp_graft_subflows(). And the extra charge is not zero only if data was received on the new subflow before mptcp_graft_subflows() gets to it, while a peer must not send data on it before the fourth ACK (RFC 8684, section 3.2). The fix used here is to skip, in mptcp_graft_subflows(), the subflows that already have a memory cgroup: they got it when they joined, and their memory has been charged since then. This issue has been found by an AI code review agent, while reviewing the code of the commit "mptcp: don't charge a shared page twice at accept()". It cannot be triggered on demand: the window is too narrow. It has been reproduced with a 500 ms sleep added after __inet_accept(), to widen it, and a Packetdrill script sending 1000 bytes on a subflow joining during accept(). Without this patch, a page stayed charged to the memory cgroup once all the sockets were freed, and none with it: memcg sock: 4096 bytes Fixes: 6228efe0cc01 ("mptcp: leverage the backlog for RX packet processing") Signed-off-by: Matthieu Baerts (NGI0) --- v2: update a comment (Clashiko) --- net/mptcp/protocol.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index c9ef23276399..8017f8775728 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -4678,8 +4678,8 @@ static void mptcp_graft_subflows(struct sock *sk) =20 /* Subflows joining after __inet_accept() will get the * mem CG properly initialized at mptcp_finish_join() time, - * but subflows pending in join_list need explicit - * initialization by the loop below. + * even if pending in join_list. The ones that joined before + * need explicit initialization by the loop below. */ mptcp_data_lock(sk); list_splice_init(&msk->join_list, &join_list); @@ -4702,7 +4702,8 @@ static void mptcp_graft_subflows(struct sock *sk) if (!ssk->sk_socket) mptcp_sock_graft(ssk, sk->sk_socket); =20 - if (!mem_cgroup_sk_enabled(sk)) + /* Got the memcg when joining: its memory is already charged */ + if (!mem_cgroup_sk_enabled(sk) || mem_cgroup_from_sk(ssk)) goto unlock; =20 __mptcp_inherit_cgrp_data(sk, ssk); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557702; b=YnXPP/q2t3eKX5Pk/LbdAaHQ2fOZv0vEbq1uClfrr5apvReTPzy6i7vlzCZQw9OdKILe TZgGTrQbFiDrq6LTIVw/TYuQaZlFfZn6rw6IeO13hwpyvDLQf0WTtFHd89dF8sgw0ZSt5 WQa9VVvnMhuMp7/uxUKWpP/yFxGP8HempOa/COMm0xv8Gt4I+ap3aExt0W+B6+/Nngg2l tK660AtpB54VBaLbiCo4ailPBWSY1275ir8cneyYauyoaIJzyWhqGJT4E1FAiRapgjOzZ ZDaCflGu2xWnAg6cYoWmoOHXCb7aPI/si2kF++1LF6GOE1VW6S0Kts3BkmJD3v3zbzw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557702; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=SEWviBA1IHkhnuFBT21PVfMjaLqut6QpPzbT5sjLphc=; b=Zt6lx7UYlRarTxJ14VCcvQhdm/gqt5z4K7NssrxzSyTPuDx2/iwxJ7u9egZOoboHR0mh D3QmLiRRZlQVqfEUoVZIKZTm9JdWiu8gkPO2sjdG4azUjObzgH4lfMaetAE36oeGjGl6b 3M9ZTh2/CV8Q1rDG6ja8tHFApiK24OKEkTiBh4X0WIEkFpGGKoX1tAfqDiZJDMfdeK3AE T2kGkq3mzZx8ckKUwL+2zZmFtX31x+9E7VOhplxUODyzMIpDmnV+FqkFgog1/4d2/qVUE XJet2aqNQIoh231CTQpnNh4L/5hODokfczzkypoxd8JUov09MJ+nCYZwM9SqV5jAvog== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZexiKdZk; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id AF3AD606A31E for ; Tue, 24 Nov 2026 22:01:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=ZexiKdZk Received: by smtp.kernel.org (Postfix) with ESMTPSA id B56C71F000C0; Tue, 24 Nov 2026 22:01:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557702; bh=SEWviBA1IHkhnuFBT21PVfMjaLqut6QpPzbT5sjLphc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=ZexiKdZkCVn6MEg66VXU9o9zeSPcwdxx0tYOpD5wMP1HFrzAsZd9D29Ylz4Fhf69p 8KCSvmG9nDoeEBnaDDLRu1Rdnv/FD2rN+PPMD1AHPCzu7l83+fDuWUHHFZ5H5FPPLh rzZnSC4J5seelTd6GAfnoMD5XkIrzYsQNVAGWeJ5jd4/zCxWvLIc/sNsCMoH1Tq1kN mQ1Lo5rY4LEMxIvcc+53ty1zCqR4Lj54j2wWfbY52vR1QpmgKbHYnKlF2L9ydjmcbR zDAwN+bQ7PWWsymqdWV9G8qVT+hRUiTOsJSjcevdG1ObqrXhkZx/tm3eWS8OdVKVvF vVN2nBbZ/IhZQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:53 +0100 Subject: [PATCH mptcp-net v3 36/50] mptcp: continue the last mapping after a fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-36-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" , Chris Mason X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7612; i=matttbe@kernel.org; h=from:subject:message-id; bh=+E6PYDVDucCbo1N+J8lQKS7FwLVyR9iD4U1CCHdjtUE=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOHlld3oxmRxunr97FU/7nKM2v/Y0x31SWHpRWCT+X 1JzTLlLRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwEQM7jP8U4/fs6dcyUpn45Wp lTqe9nedmT8JZ4UESOVt+HowqX7hKkaGhyu3TXx+JP3WjK3ap7efPX1gXp3NzcWe0rvk+8W1ayQ e8AEA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 From: Chris Mason An established MPTCP connection that falls back to TCP after a zero window probe or a reinjection can stall in one direction, so that recv() returns neither the remaining data nor end of file. After a fallback, subflow_check_data_avail() gives each skb a dummy mapping, at the data sequence number (DSN) iasn + SSN - 1, where iasn is the DSN of the peer's first byte and SSN is the subflow sequence number. This is right only as long as DSNs and SSNs advance together, but a zero window probe or a reinjection maps old data a second time, which takes new SSNs and no new DSN. Each later dummy mapping is then too high, so __mptcp_move_skb() treats all further data as out of order: data SSN 1 to 1000 DSN iasn to iasn + 999 probe SSN 1001 DSN iasn + 999, dropped ack_seq iasn + 1000, the next DSN expected dummy SSN 1002 DSN iasn + 1001 The fix used here is to: - keep in the new member dsn_base of the subflow context the first DSN of the peer's last mapping, minus its first SSN, plus 1 - compute the DSN of a dummy mapping as dsn_base + SSN - 1 - keep in the new member dsn_end the highest end of a mapping of the peer so far - make mptcp_try_fallback() fail while the peer's last mapping ends below dsn_end, so that the caller resets the subflow 32 bits are enough for both: the dummy mapping only takes the lower 32 bits of its DSN, see __mptcp_expand_seq(), and the end of a mapping stays within a window of dsn_end. One case is left: if only the receiver falls back after a zero window probe or a reinjection, it now delivers data resent at the MPTCP level as new data, unless the sender resets the subflow before, as it does since "mptcp: don't resend data acked without MPTCP opts". Without this patch, the receiver stalled instead. This issue has been found with the help of an LLM, and reproduced in a VM, with the reproducer shared with the original version of this patch, and with a new Packetdrill test: between two unmodified Linux hosts, nftables removing the MPTCP options after a zero window probe, a DSS checksum failure, or a failed MP_JOIN. Without this patch, the reader stalled for good, the data staying in the out-of-order queue: receiver 22.764: READ-TOTAL outcome ii-right-so-far-then-nothing bytes 2= 670592 of 8388608 [...] [...] end: hang: no data and no end of file for 20 s RESULT [...] R: DssFallback=3D1 [...] OFOQueue=3D204 NoDSSInWindow=3D145 = [...] And with the Packetdrill test: dss_fallback_after_probe_server.pkt:25: runtime error in read call: Expec= ted result 2000 but got 1000 with errno 22 (Invalid argument) Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation") Signed-off-by: Chris Mason [ dsn_base and dsn_end on 32 bits: struct mptcp_subflow_context grows by 8 bytes instead of 16, and lent_mem_frag stays in the same cacheline. Shorter comments. Moved after "mptcp: stop resending data to a peer that fell back": alone, this patch turns a stall into data delivered twice, when only the receiver falls back after a probe or a reinjection. Commit message: mention the remaining case + how the issue was found, and its symptoms. ] Signed-off-by: Matthieu Baerts (NGI0) --- v2: msg: the sender now resets in the remaining case (Clashiko) Note (Sashiko): the remaining case, when only the receiver falls back, needs a sender not resetting the subflow, e.g. with an older kernel: the data is then delivered twice, instead of a stall before this patch. The RFC at the end of this series resets instead of falling back. Note (Clashiko on v2): a reinjection of old data with a bad checksum is reset one RTT later, after the MP_FAIL: theoretical, it needs DSS checksums, a reinjection and a corruption. --- net/mptcp/protocol.h | 9 ++++++++- net/mptcp/subflow.c | 21 ++++++++++++++++++--- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 9a9dbab672af..7cdd0a7e8296 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -582,6 +582,8 @@ struct mptcp_subflow_context { __wsum map_data_csum; u32 map_csum_len; u32 prev_rtt_seq; + u32 dsn_base; /* MPC: DSN - SSN + 1 of peer's last map */ + u32 dsn_end; /* MPC: highest end of the peer's maps */ u32 request_mptcp : 1, /* send MP_CAPABLE */ request_join : 1, /* send MP_JOIN */ request_bkup : 1, @@ -606,7 +608,8 @@ struct mptcp_subflow_context { mpc_drop : 1, /* the MPC option has been dropped in a rtx */ resetting : 1, /* subflow is resetting */ old_data_pending : 1, /* old data not acked with MPTCP opts */ - __unused : 8; + map_old : 1, /* MPC: peer's last map is below dsn_end */ + __unused : 7; bool data_avail; bool scheduled; bool pm_listener; /* a listener managed by the kernel PM? */ @@ -1350,6 +1353,10 @@ static inline bool mptcp_try_fallback(struct sock *s= sk, int fb_mib) =20 msk =3D mptcp_sk(sk); =20 + /* the peer might still be resending old data */ + if (subflow->map_old && !__mptcp_check_fallback(msk)) + return false; + /* queued old data would be sent without mapping after a fallback */ if (subflow->old_data_pending && !__mptcp_check_fallback(msk)) return false; diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 3590c1207e88..f73e4b8deca4 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -540,6 +540,8 @@ static void subflow_set_remote_key(struct mptcp_sock *m= sk, =20 /* for fallback's sake */ subflow->map_seq =3D subflow->iasn; + subflow->dsn_base =3D subflow->iasn; + subflow->dsn_end =3D subflow->iasn; =20 WRITE_ONCE(msk->remote_key, subflow->remote_key); WRITE_ONCE(msk->ack_seq, subflow->iasn); @@ -1438,6 +1440,17 @@ static bool mptcp_subflow_fail(struct mptcp_sock *ms= k, struct sock *ssk) return true; } =20 +/* Fallback: dummy maps go on from the last valid one, unless it is old */ +static void subflow_update_dsn_base(struct mptcp_subflow_context *subflow) +{ + u32 end =3D subflow->map_seq + subflow->map_data_len; + + subflow->dsn_base =3D subflow->map_seq - subflow->map_subflow_seq + 1; + subflow->map_old =3D before(end, subflow->dsn_end); + if (!subflow->map_old) + subflow->dsn_end =3D end; +} + static bool subflow_check_data_avail(struct sock *ssk) { struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); @@ -1471,6 +1484,8 @@ static bool subflow_check_data_avail(struct sock *ssk) if (unlikely(!READ_ONCE(msk->can_ack))) goto fallback; =20 + subflow_update_dsn_base(subflow); + old_ack =3D READ_ONCE(msk->ack_seq); ack_seq =3D mptcp_subflow_get_mapped_dsn(subflow); pr_debug("msk ack_seq=3D%llx subflow ack_seq=3D%llx\n", old_ack, @@ -1501,6 +1516,7 @@ static bool subflow_check_data_avail(struct sock *ssk) subflow->reset_reason =3D MPTCP_RST_EMIDDLEBOX; goto reset; } + subflow_update_dsn_base(subflow); WRITE_ONCE(subflow->data_avail, true); return true; } @@ -1532,9 +1548,8 @@ static bool subflow_check_data_avail(struct sock *ssk) subflow->map_data_len =3D skb->len; subflow->map_subflow_seq =3D TCP_SKB_CB(skb)->seq - subflow->ssn_offset; subflow->map_seq =3D __mptcp_expand_seq(subflow->map_seq, - subflow->iasn + - TCP_SKB_CB(skb)->seq - - subflow->ssn_offset - 1); + subflow->dsn_base + + subflow->map_subflow_seq - 1); WRITE_ONCE(subflow->data_avail, true); return true; } --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557704; b=Th8F9Qn29mv+SvO+jUXWY/PJS3Hd6zf5XWBq7j7/DkyU4LS+76Ej8nfIlEqJItoVD7L/ KZFttm7DjbMNvF8YmvxAz93HVFnt4A00ROmSh/jSYdJBuxE5Z1OfeKP28JOKH293x/LrU X2g+jAPyl/C/1/iQUev69Cwy4N9MaH+vOPyUQYw2UVlBb3uCv9ozZv2DGS6lbQJnRJbyL xQ+OcnVRDkNR4KcZPiCLsEnESDRxKGB9oRB3swVjm50vlBwGHY8LpsLQyWi9k6eS3j8zF tbG8SZI1Gmqkms+ZJsbS+D0O/nvHssaZIe7WAOBfs7wuzX2VhkfcWROXCz5UGxDBvtQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557704; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=akgy1IF03oHhfH3dm+WDYpmchl+tz47+k9fmEJhAutc=; b=MRcIBfPF182yw63qe5Pd5I9BMqZudM2bv2dbivnrJiyLmheU/qonBvC8Ispqf9yc3fsp kKmr7lW1DK81g2SwYsmUcoDUdTcN/XJY5SIxU72/rFrJQd2Fcc0R3N1HtJEqLI8x00s6Z qkhQIdtdGSNFysBdwzjmahrgnPPUkFuxbRdXZ/zSy5rS1BwJX8IIVBfgpQtYkA0/+KaK5 S3PJB+wXwuz6DBZpFaPOIprcFYlSgUqWONS54G7xI4We/bj01zjoJrq6+PPFrlNQzxvea cPwX9l96q9zTIiI1qx4wiWxWVZpn2Z0I1G+fU6mmyfDVpWLl8NIaqEG7PYfaQGRfZhQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jB4+6JAL; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 278CA606A31E for ; Tue, 24 Nov 2026 22:01:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=jB4+6JAL Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F1551F000E0; Tue, 24 Nov 2026 22:01:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557703; bh=akgy1IF03oHhfH3dm+WDYpmchl+tz47+k9fmEJhAutc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=jB4+6JAL/iy3VSxkrzy6Ldlpu9WDkHCoIccSypsCg180DSnA5j1sm9hO0WKO4eJ/T FqNHxon0gaSmpVpiVpIZt7hzZgC4K5kkZM4VoQaAwyywSJJcI6TuPNpoWgZlniSz1t dzPssH6XXh0XPFghWIhLlV9oA++ETz8JKzP43/96hlLblGp/PJb9ukHG3LCVr6cfMm EfzQ9FUvJjuJ5cApToWLAyzyYUkx9GD4uR5WZKhRryTCZNNwTlurOHgBMLe2tSNx/b hU7tsZW5B1Et1uUcJdVu1+GlNPFSmHi1Asn+64vk3L5JE8wVsxvvV0Cu+ztXj6NoQC jFI5aP5IuTMjA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:54 +0100 Subject: [PATCH mptcp-net v3 37/50] mptcp: keep the first byte after a simult connect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-37-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2739; i=matttbe@kernel.org; h=from:subject:message-id; bh=m9vYyuwRYUYQmAg3qxcuoaeUuW7/Pj4Md9dE9Bxlrdg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOPk4Na0u+Cy0+7IqZvGpO+675p5SmnlM90rf5RVpr z28KgQWd5SyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAExkWSPD/4C2gCMNzqz/v/Ev i5rWJ31UiT+qzHPimp3RNhVdx6/FpDP84RKfqfeu0EVX++s7OTXGZydXnNy+7UZ2WBKP2fozSvN keAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A simultaneous connect leads to a fallback to TCP, decided when sending the SYN-ACK from the SYN_RECV state. The received data is then mapped with dummy mappings, based on ssn_offset, the peer's ISN, normally set by subflow_finish_connect() when receiving the SYN-ACK. But here, it is only called on the next packet, received in ESTABLISHED: its sequence number was then used as ssn_offset, and the first received byte was dropped. Set ssn_offset when sending the SYN-ACK after a simultaneous connect, and only take it from a SYN in subflow_finish_connect(). This issue has been reported by Sashiko, while reviewing another fix, and confirmed with a new Packetdrill test: after a simultaneous connect, 10 bytes are received. Without this patch, only 9 were read: simult_connect_data.pkt:24: runtime error in read call: Expected result 1= 0 but got 9 with errno 115 (Operation now in progress) Fixes: 2834f8edd74d ("mptcp: cleanup fallback dummy mapping generation") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue spotted by Sashiko Note (Clashiko on v2): ssn_offset is not set if the crossed SYN-ACK cannot be built: theoretical, it needs a simultaneous connect and an allocation failure. --- net/mptcp/options.c | 5 +++++ net/mptcp/subflow.c | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 05b9c66aaed6..41eb39968a9a 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -474,6 +474,11 @@ bool mptcp_syn_options(struct sock *sk, const struct s= k_buff *skb, * in mptcp_established_options_mp() */ subflow->snd_isn =3D TCP_SKB_CB(skb)->end_seq; + + /* simult connect: the peer's SYN-ACK will not set ssn_offset */ + if (unlikely(sk->sk_state =3D=3D TCP_SYN_RECV)) + subflow->ssn_offset =3D tcp_sk(sk)->rcv_nxt - 1; + if (subflow->request_mptcp) { if (unlikely(subflow_simultaneous_connect(sk))) { WARN_ON_ONCE(!mptcp_try_fallback(sk, MPTCP_MIB_SIMULTCONNFALLBACK)); diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index f73e4b8deca4..439a11d92281 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -591,7 +591,9 @@ static void subflow_finish_connect(struct sock *sk, con= st struct sk_buff *skb) subflow->rel_write_seq =3D 1; subflow->opt_ack_seq =3D tcp_sk(sk)->snd_una; subflow->conn_finished =3D 1; - subflow->ssn_offset =3D TCP_SKB_CB(skb)->seq; + /* simult connect: not a SYN-ACK, see mptcp_syn_options() */ + if (TCP_SKB_CB(skb)->tcp_flags & TCPHDR_SYN) + subflow->ssn_offset =3D TCP_SKB_CB(skb)->seq; pr_debug("subflow=3D%p synack seq=3D%x\n", subflow, subflow->ssn_offset); =20 mptcp_get_options(skb, &mp_opt); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557705; b=D7S1r+ST/ewTpp7RhCVg1yraV7/klyGauB3VusTc4AMyy+mpCZZ+9b+dtK9v2My+jekD As11wQSgfbnksSbHLURZhMEER5vIj/WfMrb+fyw56juj2JYwEcXs0Mo9v5jaquBin3yuB MF6lQPFqMcw9VYBei13F4ZMgFSyY3WT1MA82MNhCb2LTCx7HFniL1P+V060dkR/8llTss jNToRqU261pDuESJAVHFQo/laByeVEOXMe5BaJNn+2UmK1AWvlXg9BOg0xJD5Ch+RgaQD 1GSgDfB7gn39SzDakQrtnP2r6iKSN3WJTQH0iUnptK7OM1hS110YmY8g6Xyus0byDiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557705; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=TzDTzRvo+7IVefhsP1uRXe2C7YrGVfjeLPSV6bKvoXo=; b=lCkrgj2ErHmbx3bUU/981NBRSzv7MTiEJvEF4RrUrt0qjIczCCiHQwHO/HRZco+ZGX2q S+zdj1xjk8prrgNAWnTh7ScIebc+NGWiayuFpAvDtWEoRIXrR8dYPx/VRrdio8AA4Y60Y YlRpp4CVnWIvMoYmdrSsZeus7y0vRIdek9d/fa26ownSVys305Rrb2m4YrkkvkEcmCnMb tS60DXI2HK+OwNtPhtGQg3tLzQJqIpu3vN6hQkmL0mOKIhOZgJ00Zz1gxgITAUixBlhqo ZwB43/FnYCGztD33fdJp10DpyBCzrb6s/Vzgva3XmtOUQan2lnu8QsCcQblB7DI+6Dw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DukzyMgt; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C282B606A31E for ; Tue, 24 Nov 2026 22:01:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=DukzyMgt Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4F111F000E0; Tue, 24 Nov 2026 22:01:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557705; bh=TzDTzRvo+7IVefhsP1uRXe2C7YrGVfjeLPSV6bKvoXo=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=DukzyMgtJy35lEWRWHP1trkctA9YrDY63J1gYxZKYEmdTBNxWioecgDOSc0crY065 WUEnT1tnaaMJsyQIQ2moeseBUOdaGQo1u3TIE7oXw1i60OLQgDA9zNQa89EVeDDHbO SWzglDuCJuGIy6bXz5/3LvA0VxC/YJVW8kEU57Tksta4r5ZFIkKSZSudzq2A5LY0Hs IioSEOxDucx8ep8FC9mBNVmuJcFL4fpsfBpqK/1msszY72FknpzeV96XafJaYfFpjM 0DnBl6tims7TPdxWO388qUBhi4ltqSb2TRU51MIQdOQgLZke9vq0HjgILt6h3a896/ 08EXvhOAlzOFw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:55 +0100 Subject: [PATCH mptcp-net v3 38/50] mptcp: move to ESTABLISHED after a simult connect X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-38-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2324; i=matttbe@kernel.org; h=from:subject:message-id; bh=F35SWgZ2Re/nV1Q82WD/8Bh9Eu7zNtUmuFey2DOAdHY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOPnqjT50hj/dmiaw+wL7hcITJmfnrkyc9+bfLtnlB 569Xz/JuaOUhUGMi0FWTJFFui0yf+bzKt4SLz8LmDmsTCBDGLg4BWAiPc4M/6yunDwf7Gmx40HW 9tJuzTin+duFL1SsnX1w58pw+VcuDYYM/8zdvkyo5bj8KceNOSTixMmZ8xbp37qf/f5G4O1l0fl CMbwA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 After a simultaneous connect, the subflow moves from SYN_RECV to ESTABLISHED when it receives the peer's SYN-ACK. Since the commit mentioned below, the MPTCP socket only follows when subflow_finish_connect() is called, on the next received packet. Until then, it stays in SYN_SENT: POLLOUT is not reported, write() returns EAGAIN, and a blocking connect() waits, until the peer sends something. As it was done before this commit, propagate the state from subflow_state_change() in this case. subflow_finish_connect() then returns early: also check there if MPTCP is blocked, as it does. This issue has been found by an AI code review agent, while checking a review from Sashiko, and confirmed with a new Packetdrill test: after a simultaneous connect, poll() is called. Without this patch, POLLOUT was not reported: simult_connect_write.pkt:18: runtime error in poll call: Expected result = 1 but got 0 with errno 115 (Operation now in progress) Fixes: 71154bbe4942 ("mptcp: fallback earlier on simult connection") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent, after a Sashiko review v3: also check if MPTCP is blocked, as subflow_finish_connect() did (Clashiko) --- net/mptcp/subflow.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 439a11d92281..190c75311ff6 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1988,6 +1988,19 @@ static void subflow_state_change(struct sock *sk) =20 __subflow_state_change(sk); =20 + /* simult connect: not finished by subflow_finish_connect() */ + if (unlikely(!subflow->conn_finished && + sk->sk_state =3D=3D TCP_ESTABLISHED && + inet_sk_state_load(parent) =3D=3D TCP_SYN_SENT && + mptcp_check_fallback(sk))) { + subflow->rel_write_seq =3D 1; + subflow->conn_finished =3D 1; + /* It looks like MPTCP is blocked, while TCP is not */ + if (subflow->mpc_drop) + mptcp_active_disable(parent); + mptcp_propagate_state(parent, sk, subflow, NULL); + } + /* Rx queue processing is unneeded, error reporting will take place at * __mptcp_close_ssk() time and subflow reset can't happen in case of * fallback: subflow_sched_work_if_closed() would be a no-op. --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557707; b=z7tP0UsXoYiF77Prs+bPb20HSMgUeoy061ur8L5zuQtL+hE1wcOM8Cq79lauhqgF51pH sC8d0eoCHysvGex3yzqc5ocuhGR5HEmJVnlyZhF4IBZ/9oNj60ZpJFcfSt+xasbQulJh5 PNpfGA6J1BakRIyrjq07R8gfIs64wnGKJ2TUsqX+xz7z9/yRxRHS+Y79GGLkOtnGCWji+ sX2JSK7DfQQLlMAaQ+RNl8HIRRljcc1pH4Wei0SLYWw2mLLxiaVMd18O2jPZM+QrGidpC r1SpXDU5tkGmAeEsMAAmUzJzbtRV2ejt16tjKDi4paa66tmFniPSce9EPIayLCcgIVQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557707; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=BXX7V9xwAoM4rFqBies07TLWW1I87/kmyVgTL6n+Ui4=; b=355dIYWzFnwauCmvHMgGHvqa0wL5pusdYNiT0cY39gB1yn0adrHvEoxvtrO+B0HKE8jQ ciBNgvefFO79y2BKfUSjC1N6maJBIwM/ZqcLCZOQtVq4MoPYQ0V46cek/0qLOgFf8PjAq hj1QDS2DnD7hyWTPTVuol9mIDXvDWj1RwYghiZBhukj6Q+OitNiVIqeG8q+10HCwEFUYG KqGRzDq/SsIY8vl0RCKDtF6dmewvYwOPXwymSz3qao35MtFJ1xlbt84BiZNr+vuHDQf3s UkSw+kWk6ZIEgkQgdsbmPYsShZgNibwtlg6Syu3O1dD7tGJHCE61Ju8e7vOCF4EpYXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eycnyrpc; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E54CA606A31E for ; Tue, 24 Nov 2026 22:01:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eycnyrpc Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0CC9D1F000C0; Tue, 24 Nov 2026 22:01:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557706; bh=BXX7V9xwAoM4rFqBies07TLWW1I87/kmyVgTL6n+Ui4=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=eycnyrpcpGvjrmCIYpOA2+wjkx9zzdaPbgoQ4Lzi9FDQJvpyK91RjAEH4t4KrIcJP oDjfp06Dkto7znhdpZWkTsf5XyLtNgkrmdPP8zVrqv989vNmZcT5+7m1LhWvVb7YTO hPXg6DIxTR8STjusTERN+opTwURPsK+SV/1gus9c9LN5naOObVkK8zw6juJct1CQK3 toNrDY00wwkbv1mftjgenLc2n9pplRqqweqi9QzhTbGn29HVB88ikIBOg5qXQ9AMKg 5LG2Ho/pIJmNGipd5aA2qa7rVUhNAlIoPVKKV4FhKHxqCme0WCFujd1nDEHM3cjMYg Y+ewMxu/fMKUA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:56 +0100 Subject: [PATCH mptcp-net v3 39/50] mptcp: fix MSG_PEEK after a partly peeked skb X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-39-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2025; i=matttbe@kernel.org; h=from:subject:message-id; bh=akG9Mkw+666ZUDD0xRz2OG0bewBK2jkpjADxAVAdk4k=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOPnnuT358+zcVtnpZm8ii30DJUQ7Dv5te+B+7Hha7 eO+o4/vdZSyMIhxMciKKbJIt0Xmz3xexVvi5WcBM4eVCWQIAxenAEyk8x3DP9sltxwWKs13eaKa cC/4roj4QpOVB2bPuT5RSuCWxMF034kM/2tvbZNzUCuPkFn3zOlYNNvH+LZahZ22R79pajn2+Po uYwAA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When recvmsg() with MSG_PEEK needs another pass, e.g. after having moved the data from the backlog, the data already peeked is skipped. If this data ends in the middle of an skb, e.g. the last one peeked, extended since then by coalescing, the following skbs were skipped too, entirely or partly, because the length of the data skipped in the first skb was not counted: the peeked data was then corrupted. This issue was likely causing a subtest from mptcp_connect_sendfile.sh to fail, e.g. on NIPA, with a debug kernel. In the "saveWithPeek" mode, the client saves the data peeked before reading it: the received file had the same size, but not the same content. # 46 ns1 MPTCP -> ns1 (10.0.1.1:10043 ) TCP (duration 264ms)= [FAIL] file received by client does not match (in, out): The root cause has been confirmed with a debug patch holding the MPTCP socket lock for 200ms after the first MSG_PEEK pass in recvmsg(): 1000 bytes are peeked, then 1000 bytes are received and coalesced with them, and 60000 more bytes in other skbs. Without this patch, only 60000 bytes were peeked instead of 62000, and they were different from the data read after: peek repro: peeked 60000 bytes, DIFFERENT data To fix this, count the data skipped in the first skb, so that the next ones are not skipped. Fixes: 8e04ce45a8db ("mptcp: fix MSG_PEEK stream corruption") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue causing a flaky selftest --- net/mptcp/protocol.c | 1 + 1 file changed, 1 insertion(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 8017f8775728..0ff84d9684f1 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2301,6 +2301,7 @@ static int __mptcp_recvmsg_mskq(struct sock *sk, stru= ct msghdr *msg, delta =3D copied_total - total_data_len; offset +=3D delta; data_len -=3D delta; + total_data_len +=3D delta; } =20 count =3D min_t(size_t, len - copied, data_len); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557708; b=NGeXvlFBpYZE9lwUkG2WlbOlBjBgfVvdAMyi890+g5s/R5sFtMWyAgbuinYaxs/DeKHf sPx/7F+up5pqQ3cmYz5pxyjubw8g3BlMbndy2uNf/ZB7bJMxBKbydEukdObd4mULem9Xv psp6UxNcenVScDMyQ6/rck5E6lXFLYrcNrMrJPGEvoYdgqQprBFEkfdYkImuTrxZe+BVD fU47OphennpRQwiVdCUYEIxA9BuaYcM+sw8QEit7O81hsiPn+Id4G5WBFMCCBjojfw4lc 9BZ/zRA9yBp00Xu8GssOJk7jblyam7mQGyGE9CwhMeDPznqR1QWXNX+1bolx9QvB/2g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557708; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=ZpOH4Fv0iQliZDk/hpYObcdBoFRQuJbom8BzxrjY7wc=; b=T+zJaZvRRy1pclHaLPSUx6mahKGsopMcadrUJREG73XEsiDecJz2fJSHKnItRdryLnyA 92h442ENV7A4mB6Wc1QjGH1XdhbOmFO0Hifb2ECnFfpOv9NLUqn7RbQUTB5Ah7f/uzEQg udgXAz6q6SrtAo56kCiwmzMNNDH9O3Pdfnk/JyijRofZXY/dt/LJYyoEx5Wb9IB2NOqmk Bbde7b01F/t82Y+Lf3n0LB5/Gv623BUNocd5h0sO9d1Ijjl99tYb3pkAHCbI308apWUru B2SPJLnI7APwdjzRM3oARLgdbFDTkj103BQ/5JBV//WebggAeHS8tBPVPzA+HWUdr4A== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=L9qyOEpi; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E2CE4606A31E for ; Tue, 24 Nov 2026 22:01:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=L9qyOEpi Received: by smtp.kernel.org (Postfix) with ESMTPSA id F08351F000C4; Tue, 24 Nov 2026 22:01:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557707; bh=ZpOH4Fv0iQliZDk/hpYObcdBoFRQuJbom8BzxrjY7wc=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=L9qyOEpiXTiGOtuy81gCRQtY6NKROOwyY2jFn+1UJ3mVidgZ3byv0B+lPpIzDsGyK RqNG8TntPBYpZNwW05EkSPjt+z6e8fpwBIDLaOmBXQbwPhUeKg9yykhzNQzwZtPOw4 YeV0Zln5Wc7OzRDzMX0uQlQeLEN2XhDBehVbPso5WwrQnuzjcbBDFPDYkvqwWOqNYB ypZHWRWyrkzQI4J7EuMIrvtIZg+Cy6v2gwEX2PQTrx+9UVC2fKhglm7dtCdraX7jdm cRzPVQ9FbGmZa9dAJbfdRJ6qDF/99pUkB5clyTsGyq5m+MONEFn/bvkvNetcUcxr2i lEdQUYrAXTNSw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:57 +0100 Subject: [PATCH mptcp-net v3 40/50] mptcp: send the DATA_ACK after moving the backlog X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-40-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3639; i=matttbe@kernel.org; h=from:subject:message-id; bh=mCEn3srhu+73Lm6vdJ8Kvg3rYeSLemVd72+UgVNtutg=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOAW6L9lmdzxe+Gf6Cqts/YX3dFjd5kTOnWBW9aot6 ALDn81POkpZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbyyIzhN3vO94NrUzmlWybm Hz1TfJD9zeX1z9Sb3r7+9YJFf8dsj9cM/9P2x74P7a+2WbrdQXWjfU1mRseFH/ubM6bvf2LRVjg llw8A X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The data received while the MPTCP socket is owned by the user is put in the backlog, and only moved to the MPTCP socket later. The TCP ACK sent for this data then carries the previous DATA_ACK, and after having moved the data, an updated DATA_ACK was only sent if a TCP ACK was still pending, for more than one MSS. If the peer had nothing else to send, it then didn't get the new DATA_ACK, until another ACK was sent, e.g. when the reader frees enough space in the receive buffer. Its MPTCP retransmission timer could then fire, and the data was retransmitted for nothing at the MPTCP level. Such a retransmission also prevents a later fallback to TCP, after an MP_FAIL: this was causing the "Infinite map" subtest from mptcp_join.sh to fail from time to time, with an unexpected MP_RST. This behaviour has been introduced by commit bc68b0efa1bf ("mptcp: move the whole rx path under msk socket lock protection"): before, this data was moved to the MPTCP socket right away, even if it was owned by the user. To fix this, schedule a delayed ACK on the subflow of the last skb taken from the backlog, if no ACK is pending there: the new DATA_ACK is then sent with the next ACK on this subflow, or when the delayed ACK timer expires. TCP sends its ACK when processing its own backlog, possibly delayed too. The root cause has been confirmed with a Packetdrill script and a debug patch keeping the MPTCP socket lock in recvmsg() while data is received. Without this patch, the DATA_ACK was not updated after having read the data: error handling packet: Timed out waiting for packet Fixes: bc68b0efa1bf ("mptcp: move the whole rx path under msk socket lock p= rotection") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue causing a flaky selftest Note (Clashiko on v2): with several subflows, no DATA_ACK is scheduled if the last subflow cannot send ACKs: only a spurious retransmission, as before. --- net/mptcp/protocol.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 0ff84d9684f1..2f89719e8454 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2417,10 +2417,21 @@ static void mptcp_rcv_space_adjust(struct mptcp_soc= k *msk, int copied) msk->rcvq_space.time =3D mstamp; } =20 +/* The ACKs of the data put in the backlog carried the previous DATA_ACK */ +static void mptcp_subflow_schedule_ack(struct sock *ssk) +{ + bool slow =3D lock_sock_fast(ssk); + + if (tcp_can_send_ack(ssk) && !inet_csk_ack_scheduled(ssk)) + tcp_send_delayed_ack(ssk); + unlock_sock_fast(ssk, slow); +} + static bool __mptcp_move_skbs(struct sock *sk, struct list_head *skbs, u32= *delta) { struct sk_buff *skb =3D list_first_entry(skbs, struct sk_buff, list); struct mptcp_sock *msk =3D mptcp_sk(sk); + struct sock *ssk =3D NULL; bool moved =3D false; =20 while (1) { @@ -2428,6 +2439,9 @@ static bool __mptcp_move_skbs(struct sock *sk, struct= list_head *skbs, u32 *delt list_del(&skb->list); *delta +=3D skb->truesize; =20 + /* NULL if the subflow has been closed */ + if (skb->sk) + ssk =3D skb->sk; moved |=3D __mptcp_move_skb(sk, skb); if (list_empty(skbs)) break; @@ -2439,6 +2453,9 @@ static bool __mptcp_move_skbs(struct sock *sk, struct= list_head *skbs, u32 *delt if (!moved) return false; =20 + if (ssk && !__mptcp_check_fallback(msk)) + mptcp_subflow_schedule_ack(ssk); + /* Only the worker can close an orphan, as it must then destroy it */ if (!sock_flag(sk, SOCK_DEAD)) mptcp_check_data_fin(sk); --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557709; b=GqdKdYxyZKLkI8aGmNiz+Nf8C78f3vRP/PbtDclga0W2gsleZyzk9aAFfkMLtlvKBRgg nxtIP6mtWY5TpoUxCQEHiHjP1MUi1cXa/edJDqzGouGZneH3srXUVhI3Yo2gzzhxucUpF Nr+75aThI5hdt7SSRfFRTuYaRd0zvtCvixhQllgBk/Gv2meLZzrjrxRUyNejiw/i2rOQ7 VkinTwNvuS6hEkyHphizi3mcWOeacdawyq8ljEC1uOcG2+E1LKJxJdls3YLJq+0+9TDbg rbzel/1F9K2XPAMM+5WDs5kwc4RuVA6DjSTu6QGW2Il+DycozrYSsLauKmcM4R2YNcg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557709; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=0A0xyfSATAln0Q+Deiz0cCQvaovCf99nMyyZVnsqkw8=; b=2xqJnG2Xr95CvEA3nBYovm9Q9LX91Wld3PTvNwpk25kvD8jmHqOFsBkSK3uQZNyYs/fq Axawf+V8vO9GSdDG3LvDKRFR2+LdGVOL3MKOaeGVtZZFLaO7bN9/euZSwXN69dBGjKde3 fQqtyLLItX/ww7ikcrhaeZ1545afLUw2W40cwI3d+8NX992Ab52IOp1xVH3nSWNSGp60g Iq9c+ezkAC9O/6GltjidAzaald7r1go35dQgcJnU/e6SCDDrX9tO5Nl4KHp6vg2BcEUmu A699HQujqgIdUOwi1Mc0sm/HMqynFanQ9lvV8YHXfBbcQPphgDruCRyDCOLrtGVkMLA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eFHlZ+DB; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 652CE606A31E for ; Tue, 24 Nov 2026 22:01:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=eFHlZ+DB Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D18D1F000C0; Tue, 24 Nov 2026 22:01:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557708; bh=0A0xyfSATAln0Q+Deiz0cCQvaovCf99nMyyZVnsqkw8=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=eFHlZ+DB8hIuI24hGXOC9RksFUjc9LRVeeA+S/1Zu2tRZ5zuj/m2OR/BtBv7ezp+I k6/0L5NhFI8EVxcMpu62WGi+uC8/znX5MEpdJobh+Hvab9y6iyW2IEVCAxAqf5FSLQ frNq3S7txS3hXO16hztAu6/P0BrMmn6kNv8tbDytieMypEZ/6oDS8/DyeEyV2m9DXy oy2+EJ1ofSJ+U7FP91wOxe5+3K4qmEqkFb0mkZSj4RjXei5sFjpkGG4a913QvYqED0 W0ZYMHTRIDjU33bFq43cLOB3SRyDLl783V2grDhf8aFXAexQ4cPALeBYh8ELsVfXA4 70UZqrBcWS5PA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:58 +0100 Subject: [PATCH mptcp-net v3 41/50] selftests: mptcp: join: infinite map: no spurious rtx X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-41-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3144; i=matttbe@kernel.org; h=from:subject:message-id; bh=24pzTk9FT5cN/9FozCylpHkdx1ESVFmi0SmeT9jC2YU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOAUKe35Z9xjMc1/y6arPZ8NWzR3n0t/Ifl2c7rrjx 6J+uYOpHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABP59ZaR4Unp76x11xnSeDR/ fu2MZo1Yar8+K9kqufZAPKvgT//n5xj+h+pccT+Z8ig8/dfpGts1mbHmoVwbp+zwCr7IdLesarI rDwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The "Infinite map" subtest sometimes failed with a reset instead of a fallback to TCP, and the transfer was then stuck: [FAIL] client exit code 2, server 2 (...) MPTcpExtMPTCPRetrans 1 (...) MPTcpExtDuplicateData 1 (...) reset tx server [FAIL] got 1 MP_RST[s] TX expected 0 infi tx client [FAIL] got 0 infinite map[s] TX expected 1 Once some data has been retransmitted at the MPTCP level, a fallback with an infinite mapping is no longer allowed: a checksum failure then leads to a reset. Here, the retransmission is spurious: in the 'fast' mode used by this subtest, each side writes 100 bytes, then waits 200ms. The 100 bytes from the server can be received while the client socket is owned, e.g. when it is writing its own data: the TCP ACK is then sent with the previous DATA_ACK, and the next one is only sent with the next data, 200ms later. Meanwhile, the MPTCP retransmission timer of the server, armed with the minimum RTO of its MPTCP socket, 200ms by default, can expire. This has been confirmed by setting tcp_rto_min_us to 20ms in both netns, with a capture showing the stale DATA_ACK, then the retransmission of the same data 20ms later, with a new subflow sequence number: S>C [P.], seq 1:101, ack 1, [mptcp 24 dss ack 3936022471 seq 115919130101= 1008422 subseq 1 len 100 (...)], length 100 C>S [.], ack 101, [mptcp 12 dss ack 1159191301011008422], length 0 (...) S>C [P.], seq 101:201, ack 101, [mptcp 28 dss ack (...) seq 1159191301011= 008422 subseq 101 len 100 (...)], length 100 These MPTCP retransmissions are expected here. To avoid them, increase the minimum RTO to 1 second in this subtest: the corrupted packet is the next one sent by the client, after its 200ms pause. The MPTCP socket only uses this sysctl since commit ea4eb2adb0d3 ("mptcp: honour configured min/max RTO in retransmit paths"), in v7.3: before, this change only increases the minimum RTO of the subflows. Errors are ignored on kernels without this sysctl. Fixes: b6e074e171bc ("selftests: mptcp: add infinite map testcase") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for a flaky selftest --- tools/testing/selftests/net/mptcp/mptcp_join.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/net/mptcp/mptcp_join.sh b/tools/testin= g/selftests/net/mptcp/mptcp_join.sh index 4c045532f137..3d48b02ee8c9 100755 --- a/tools/testing/selftests/net/mptcp/mptcp_join.sh +++ b/tools/testing/selftests/net/mptcp/mptcp_join.sh @@ -3828,6 +3828,12 @@ fail_tests() # single subflow if reset_with_fail "Infinite map" 1; then MPTCP_LIB_SUBTEST_FLAKY=3D1 + # MPTCP retransmissions prevent the fallback: avoid spurious + # ones during the 200ms pause of the 'fast' mode + ip netns exec $ns1 sysctl -q net.ipv4.tcp_rto_min_us=3D1000000 \ + 2>/dev/null || true + ip netns exec $ns2 sysctl -q net.ipv4.tcp_rto_min_us=3D1000000 \ + 2>/dev/null || true test_linkfail=3D128 \ run_tests $ns1 $ns2 10.0.1.1 join_csum_ns1=3D+1 join_csum_ns2=3D+0 \ --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557710; b=qLMt72/AeIJtdywxftRh42jktzTS6oqjMQ+Ko7wBmAaCy+Uiza7wlQ8MMabY/SRutBMf BwL6r8IyiKokwgclAfcxTDVJqzffXu3c1a8UQ7NHVhwSU2bwb7YPVAzA5Eg/CRPANG1aq /xGL0JQdu3zF4FuMr/SWQpDZNL8S0e+KwbubPV/7qWges0nc5rBubn3ZODpaeuzqIx0bh WUJHkSPp0pW0W1ht5rkNgQv+OCPdTdKTt0hEPIX/+K/K9BX4otgT4lJX3mh/KcBfcqOK4 Z1b+nK9i3x++sTUnLuAbJPnk5/WlBPUkmwKUvs1ev8DuZRBEjEDJLZs5043tQmfzZmg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557710; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=PEZwwhiUvCNmEuUcG+vzYmc9W2vxSlt/Vn/YGDhEMBY=; b=RKHQHW3XrG3mG/HHrBgugrZIjeV9nLiofCgLK/zNSbQUEXschCCqoYJ8CdtG8jV2tdgb KCFqRBpKJQOeA02NCjqoRx7kpAvBe1JFReKaO+SChkX5DrLHM0HUz2mU2zYhtouRdOvWa rgC5JaNy5Cxui5WXWSTxesAAwy13C8ZjuywuM+rL5ssWyYzMiBR5dMG/j/gBuXbzIKHL9 LGHPSWlxzDAusNlcQapKi8Hf0MDfErye8ycOQ0YpxW2/bHzzTEv/a607OnATwWwZC1fly xV/JpODHGMdpiZzdBbLaDHxscyOfVN8QKFX91nbfXSz3CvGNcEwydIqaRgFdrWXQ2RQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C9H7yoVs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C3D0606A31E for ; Tue, 24 Nov 2026 22:01:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=C9H7yoVs Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C5731F000C4; Tue, 24 Nov 2026 22:01:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557709; bh=PEZwwhiUvCNmEuUcG+vzYmc9W2vxSlt/Vn/YGDhEMBY=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=C9H7yoVsPoMadSXfwGmWOPNyrKSUSVXpyh7/+S2kqhm3pCpH6JbLD6NTqpZ8Nji0/ GNY22t8IsFYkP1zwsCnZIhU00CE5DIDlDlBLAb25QdKfazRlhcHYQ6xpXQJOGid9SM x5GPHjaj+4iBOiQNEX0thpSoDN6XnjJolmkp5DF/279hjsc0I4bhApYjf233Ex2VuP +aWTiD2q7liZ3qk9AX4++A+aERwoM4c+I8H53mS5sLf98cNSE3UjZk3ZLk2C5cMB8k ZArpJIIvBi01a8QOuK5nZW6SDrYWv6UZEEYqKsmm0faQ+1pPpokiMV2TW4I2qsx+r9 99p1lk/esD5ww== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 22:59:59 +0100 Subject: [PATCH mptcp-net v3 42/50] selftests: mptcp: connect: trunc: wait for acks X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-42-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2970; i=matttbe@kernel.org; h=from:subject:message-id; bh=0RLcJEopSMRfxvOzmTtDqRvHPeGB9K5sSrOYzXnOaes=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOAUTMq/v+2DTfPH319DwZK5jE18fZJkVsEXZ37bH8 mPe5FvTO0pZGMS4GGTFFFmk2yLzZz6v4i3x8rOAmcPKBDKEgYtTACbyho+RYa1F4ss08Rfia3d2 dT4sXOGbtqwya4b++xt9Va6hoe/XL2P4n1ctmDwnxH7KVEO/1BtX9y1oiE4uD7070X3jbO8Pv8K P8wIA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The "fastclose server test" subtest from mptcp_join.sh was still failing from time to time, because the client output file didn't have the expected size, e.g. on NIPA: [FAIL] file received by client output file has wrong size (866, 1024) Server ns stats (...) (...) TcpExtTCPOrigDataSent 3 TcpExtTCPDelivered 2 Here, the server sent 3 data segments only, the last one not acked yet, and the client received all the data from these segments. The rest of the data, already written by the server, was still queued, e.g. held by Nagle, waiting for the last segment to be acked. But the server then closed its socket, with data from the client still to read, as expected here: an MP_FASTCLOSE is then sent, and the data still queued is discarded, as with a TCP reset. To fix this, wait for the written data to be acked, with SIOCOUTQ, before stopping in the truncate mode, so before closing the socket. A timeout is reported: it would look like this issue otherwise. This issue has been confirmed on a debug kernel, where this subtest failed a few times: each time, the client didn't have any data left in its queues, and the data received matched the data in the segments sent by the server. With this patch, it no longer failed. Fixes: 6bf41020b72b ("selftests: mptcp: update and extend fastclose test-ca= ses") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for a flaky selftest --- tools/testing/selftests/net/mptcp/mptcp_connect.c | 24 +++++++++++++++++++= +++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/net/mptcp/mptcp_connect.c b/tools/test= ing/selftests/net/mptcp/mptcp_connect.c index 8c788977e594..861fa2bd70d0 100644 --- a/tools/testing/selftests/net/mptcp/mptcp_connect.c +++ b/tools/testing/selftests/net/mptcp/mptcp_connect.c @@ -643,6 +643,26 @@ static void shut_wr(int fd) shutdown(fd, SHUT_WR); } =20 +/* the data still queued would be dropped by a reset: wait for its ack */ +static void wait_for_ack(int fd) +{ + struct pollfd pfd =3D { .fd =3D fd }; + int i, queued; + + for (i =3D 0; poll_timeout < 0 || i < poll_timeout; i +=3D 10) { + if (quit || ioctl(fd, SIOCOUTQ, &queued) < 0 || queued <=3D 0) + return; + + /* e.g. reset: the data will not be acked */ + if (poll(&pfd, 1, 0) > 0 && (pfd.revents & POLLERR)) + return; + + usleep(10000); + } + + fprintf(stderr, "timeout while waiting for the data to be acked\n"); +} + static int copyfd_io_poll(int infd, int peerfd, int outfd, bool *in_closed_after_out, struct wstate *winfo) { @@ -768,8 +788,10 @@ static int copyfd_io_poll(int infd, int peerfd, int ou= tfd, } =20 if (cfg_truncate > 0 && total_wlen >=3D cfg_truncate && - total_rlen >=3D cfg_truncate) + total_rlen >=3D cfg_truncate) { + wait_for_ack(peerfd); break; + } } =20 /* leave some time for late join/announce */ --=20 2.55.0 From nobody Wed Nov 25 18:25:57 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557711; b=4fGZe82AswHTOdyxWEznGyunTgsJ5SxCcEN7aDhIQDmuEDpOen7D98iMnCka2F8a6rMp 8gffdZFiK29upzwf9gF4RjSVJJrDl2VMOosLSlDAd0ncGUS8GB9DJCXzWZgxZpw0uQozm I1ZQW/dket1+5NbUOoEzajhpcFtU17UZucKHhQvqAmDG44qB2i6zW1n28Y6I5t0EVt5aD LAeAH6XD20i+RsloKFbGqohXTfYv9FgSFcOKpKYNLS8vyAYaAEmOSzz9YmLzx2Mx4phop YZxOc3VH1NslIPZEUvVQ8hDfMcVq9JgDCuk/3P361ElfM2oVkpNdioPbQ+8PJNBRLDw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557711; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=Wpc8NQoFDbc3SUtQXMz9OSb3rLLK95RFFl1NMsM2Myw=; b=kbDYtdiEk3EMhgSDTUnAXv7/frvDe/9aFoFsbwcEg/jA+4buZGMa+CoyQzHHMDPLz5Bg hcLgjQwo5vfKrMmgrvZXGW0lwBNpMwJgLO/mfYRb0onZlur7eSYRYBF8439FaJ/b5ZRJK uB+v9wZelC7XpOyVIPhsLf3laEFbNI/vc8cPQZ2ggQnQt6idrpgG88VgBTodpSQ8mdwk0 3+2yUj0GEYS7npR5OahZyZwNtYUzp18zEaw5oDAsgsEYtx6RCjXuTEp2KfCROa58bYNyg hcH7QZFzC9xxvPQCODs/l6wn/Q6amF5KyDdmmN9xNtd98S4CgPQlVavzyPXOdD1OZxw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=alvVLrxs; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 725BC606A31E for ; Tue, 24 Nov 2026 22:01:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=alvVLrxs Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB6B31F000E0; Tue, 24 Nov 2026 22:01:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557711; bh=Wpc8NQoFDbc3SUtQXMz9OSb3rLLK95RFFl1NMsM2Myw=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=alvVLrxsw2OfO2YD0PnMhrD+gV5vtmHJK8iMlXxEoEc0k4rQv+z9ObZ3RmN4yjcHr rWg0+Cz2UWEA2y7/7HfXngPqakOXPegIifNJ1kMzChDqC6CnReBIR9AamiHJwYgfwh Ggu+1VwrUuFDYKg/kBRAYrumdLLzYbQjFqyYLsGnDI+gzIFztzMZcnCnbhhjEYwOfD 4hHdOUZ9tC8iXwP3LBUXUqjx6pIs0d2rsDu9bKDHIzp8ggvfyItIcIEWFKQYv4XtAk +ev4ygrZ7V0T/lpmWjAikBl+ZzAWTEsTJ1OkfQPw+mfs9QQpGSrrEj3cgbnjrcDWe9 6zoexKFFoY4jA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:00 +0100 Subject: [PATCH mptcp-net v3 43/50] mptcp: order write_seq and DATA_FIN flag X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-43-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2519; i=matttbe@kernel.org; h=from:subject:message-id; bh=+QfHppTEXucMsitalkhZ1Oba6m65ZLLLiq0bb2hZsg8=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOIV6k3i1NnYpX9q7d9uXB5svf/Ux6rp9WGL99Afvf M9W7HtZ21HKwiDGxSArpsgi3RaZP/N5FW+Jl58FzBxWJpAhDFycAjCRhL2MDD83NE4W73td3u9+ ufOq0T12231ve64LXO7WTwvY/Cv+vDbDf4cZS72frRYOfTWrVyxxufUtQ92zkwJfLDzlfPngtuc nQ3gA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 mptcp_data_fin_enabled() can be called from the subflow TX path, e.g. when an ACK is sent from BH, without the msk socket lock. But __mptcp_wr_shutdown() sets write_seq and snd_data_fin_enable without ordering them: on a weakly ordered CPU, the TX path could see the flag with the old write_seq. After all the data had been sent, the DATA_FIN could then be sent with the sequence number of the last byte of data, before the right one. Use a release/acquire pair, to read the new write_seq with the flag. This issue has been found by an AI code review agent (Clashiko), while reviewing "mptcp: order write_seq and DATA_FIN flag for fallback". It is theoretical: it has not been reproduced, and it needs a shutdown racing with a packet sent from another CPU, after all the data has been sent. Still, it is fine to fix it like that, without real impact: the release/acquire pair is cheap -- plain accesses on x86 -- with the release done once at shutdown time, and the acquire when sending a packet, as the plain accesses before. Fixes: 43b54c6ee382 ("mptcp: Use full MPTCP-level disconnect state machine") Signed-off-by: Matthieu Baerts (NGI0) --- v3: new, for an issue spotted by Clashiko --- net/mptcp/protocol.c | 3 ++- net/mptcp/protocol.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 2f89719e8454..e0f39931493e 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3694,7 +3694,8 @@ static void __mptcp_wr_shutdown(struct sock *sk) =20 /* will be ignored by fallback sockets */ WRITE_ONCE(msk->write_seq, msk->write_seq + 1); - WRITE_ONCE(msk->snd_data_fin_enable, 1); + /* pairs with the acquire in mptcp_data_fin_enabled() */ + smp_store_release(&msk->snd_data_fin_enable, 1); =20 mptcp_check_send_data_fin(sk); } diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 7cdd0a7e8296..a9daa047203c 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1028,7 +1028,8 @@ void __mptcp_error_report(struct sock *sk); bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, b= ool use_64bit); static inline bool mptcp_data_fin_enabled(const struct mptcp_sock *msk) { - return READ_ONCE(msk->snd_data_fin_enable) && + /* pairs with the release in __mptcp_wr_shutdown() */ + return smp_load_acquire(&msk->snd_data_fin_enable) && READ_ONCE(msk->write_seq) =3D=3D READ_ONCE(msk->snd_nxt); } =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557712; b=z86pJQJg7rmpuKugQvesUZuhr6xo5QGMGE2mUFsSVZZVp/0pH6dp/s6K1Dg7H3YuQUHZ wL0wVbOo+OQSNhuw/LbWNUhcSjtAarH2VI54aD6bhpEV2VOy6YDf142qHhYmA+Ch3op2B sFEGkTsE1KLEJ2V/jyFVuRCEujHSobmwXVbB3I1yoG2ztTnPs577T92Jfbj45cjADkG6a yRvSwRw5IvYcOUg+MMEydysGAYp89GKviWTDtyxNYLdrLi9GnsSmzHyfZnhm6eX2xehFu s+fPewWXp4JwCruxO2tZCPRhc5MYJhGU9fCaekI+Mpsv5V3IXjgSuProYMMwo9J6TiQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557712; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=xJ76myPlAylgMT1avbb8/C31thGCQd6FTIA1l3hh1gM=; b=Slb3fd4bU9Gu3nI99u+jMpEn1zjmaH4mW1EK5bFP4sej9ivNuTw+ucCgOWJZYRzczwK3 TZN2NnM8WRfe95hR+S95r8TqFuFaa9LeeqMBvmZy+V7Ty7Apr3470LctbarIJwrtdmxD6 3l+wWpY3M8PT0L5t06C5kSXPcejuPzVMjD6O66pYPH/4/ZuI6bZaNNV2iF69QeUselpkB W6gOr1N7bQ5ploJWm0H9QkuL5lIWJn+he0f52pY+BqoQ7IWV1j+hQvzIz0YBWHKvwXq+F 0AWdTu6m6EZBvJrZUzafN5m4ienVGguPJNyVo5YbGmMmznlQqAdrco3Mj8fmZG5V9Bg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WzUqVIM2; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A128F606A31E for ; Tue, 24 Nov 2026 22:01:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=WzUqVIM2 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5DA81F000C0; Tue, 24 Nov 2026 22:01:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557712; bh=xJ76myPlAylgMT1avbb8/C31thGCQd6FTIA1l3hh1gM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=WzUqVIM2wwdqJ5CxvTxV335s1VaOy/lZwEUWOrV+CfnaPw8Wmkn5Y83AhT67W+BB9 73WxmJ35Gs9yfl1XYpBYWlpvyOzoYHa15Ri9foBAyyouABYsnX/863cB5JW6LmioBw qyIdJc79qvH7f7gHyVj7TkYBg4Tor73TQWafeof/e4PoaH5UA2DhPjjXgfVAOtckQ1 FIZUIBn0Sirk8KEty6iGYSplkoZ2/ysJzEecv1igvjyn/RBJtv495Bz9dTXWCPDtti 0oMzA7+gwZ4awwsZNCUUCHIdy7uDORz/9v3117LUsChM7GLpoXXwZJ9NTjfSFpJAK1 AxvjOzENmThFQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:01 +0100 Subject: [PATCH mptcp-net v3 44/50] mptcp: order write_seq and DATA_FIN flag for fallback X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-44-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2732; i=matttbe@kernel.org; h=from:subject:message-id; bh=S8DtQhGYBbNNO/6GEaGZhFu6/M4/fbrcPiqfvlFEMiU=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOIVKr3XmhXi3PLpxJvz1Br9JAo4OfwXfnTW8xjNzT kSc52z9jlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgImkfWP4Z3FgQds2sdhq4a03 ubjljy5fwV8fnr+jI6w2bn78vqyLzAz/TF8kzeW9opdpG1C9MSTsN8vmVfP/7tizeUPc0hvKV3l MmAA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 mptcp_try_fallback() can run in BH, without the msk socket lock. Since the commit mentioned below, it reads write_seq after snd_data_fin_enable, not to send a FIN before new data. But it reads the flag without ordering it with write_seq: on a weakly ordered CPU, mptcp_try_fallback() could see the flag with the old write_seq, and send a FIN before the last byte of data. Read the flag with an acquire, pairing with the release used by __mptcp_wr_shutdown() since the previous commit, to read the new write_seq with the flag. This issue has been found by Clashiko, while reviewing the commit mentioned below. It is theoretical: it has not been reproduced, and it needs a shutdown racing with a fallback, with exactly one byte not sent yet. Still, it is fine to fix it like that, without real impact: the release/acquire pair is cheap -- plain accesses on x86 -- with the release done once at shutdown time, and the acquire only when falling back. Fixes: d0e88ecfae68 ("mptcp: don't send a FIN before the pending data on fa= llback") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue spotted by Clashiko v3: only the acquire, the release being in the new previous commit, fixing an older issue --- net/mptcp/protocol.c | 4 +++- net/mptcp/protocol.h | 6 ++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index e0f39931493e..f361cd40a8e4 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -3694,7 +3694,9 @@ static void __mptcp_wr_shutdown(struct sock *sk) =20 /* will be ignored by fallback sockets */ WRITE_ONCE(msk->write_seq, msk->write_seq + 1); - /* pairs with the acquire in mptcp_data_fin_enabled() */ + /* pairs with the acquires in mptcp_data_fin_enabled() and + * mptcp_try_fallback() + */ smp_store_release(&msk->snd_data_fin_enable, 1); =20 mptcp_check_send_data_fin(sk); diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index a9daa047203c..59ddf3dafeba 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -1365,8 +1365,10 @@ static inline bool mptcp_try_fallback(struct sock *s= sk, int fb_mib) if (!__mptcp_try_fallback(msk, fb_mib)) return false; =20 - /* no FIN before new data: see mptcp_check_send_data_fin() */ - if (READ_ONCE(msk->snd_data_fin_enable) && + /* no FIN before new data: see mptcp_check_send_data_fin(), and the + * release in __mptcp_wr_shutdown() + */ + if (smp_load_acquire(&msk->snd_data_fin_enable) && !before64(READ_ONCE(msk->snd_nxt) + 1, READ_ONCE(msk->write_seq)) && !(ssk->sk_shutdown & SEND_SHUTDOWN)) { gfp_t saved_allocation =3D ssk->sk_allocation; --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557714; b=MgPacSG++EhkSz4yQ/9EDW+y8LZZYr/gSn0nKe6k8chELYOn4kRJFicxMwaKY1BHUQqR myF49MUH5KPx4Nr/+0WrPqkeztIOaRc7TVt8qg1541RsrtpZbZ/KzXw9pl3EiUn/unlco OPoz2hfVB18tjlnP4ohJUsdWLwwzf4mncc4PPNIm/xmwNM7mZNyRJHj3xTtWoxJ9bDvrg eFIl5baBsYr4FUm7sTp7M8+Zfk+/THrAWETRrwLchs/tM8coktjdwHd2p0t3CtlBRNaaO ow0fh23JER6vC5OaUFW/Lwemb1L/6jkh1btf5eEdz+OTIGlBPDK2aveHfiGNpOgk8mQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557714; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=bRj+iw09z95Vt4m3slu/ZkNAqRgTDYxqJvcCjFrJfQU=; b=zVD5KZKPC6uPPoDWMWKxOHAnN3ESd8YHCbOpMHNwqIDTiUHe/BDArdRewOEOilNNpJtA FOJXtABCjecQY9OUsqOcP7aoOpaH8sCLY1tszjnqsyhXVAYcHTMrFJazBbOwJNHJyCe1U W1++2fGGPnEPW2qGLoDJayhwrECYtbJjdTXoNosh3sRFaj4pc6GNrsYIzhjNNV0gCtmM7 c5S+jJQJuaO8SAvm66/tMapOLybxDcnfbU8aP72l6TgSbZ7YYZ8AA5hSGJ1B2UJ9GexDM ktjlqoqe8LxqhLtWxDi7u9tv2fsF5dttQl979J0JIaQHCudwQPh6o5Gwk5e5KS/XsiA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g8jTetPY; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29968606A31E for ; Tue, 24 Nov 2026 22:01:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=g8jTetPY Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4DA511F000C4; Tue, 24 Nov 2026 22:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557713; bh=bRj+iw09z95Vt4m3slu/ZkNAqRgTDYxqJvcCjFrJfQU=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=g8jTetPYHgNhwYC+ZMg3Wfj1fzQbIs+VmqhnBUMmwBSXOwIiDhTCOonqcgKdEF5ee LmQnffQmZ5UPA3rr1N5af38WZ7F7Ys5v5V4W0j67cYB8Nx4VZgC33B0zon711aNrW6 hN6MK4LF1v9kS0ZNN2/sK1PZNrJc4h2kZjFsqPapMLpovLx8wba/LZz5wNFSn3+iN7 MWNNEak1AGekdnTWJoaSpbSVwxWn0wwcEi3MR59LeljOwciQHcvYAz5C8CxttqZbGd YeUrfroGPpMEpBuzaV+gKNmRM76DI3XZ0+AWnORCuVsnizlKhl3D1cbGjiF9iEfdGe O3h89Yq9ytC/w== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:02 +0100 Subject: [PATCH mptcp-net v3 45/50] Squash to "bpf: Add mptcp packet scheduler struct_ops" X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-45-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=3205; i=matttbe@kernel.org; h=from:subject:message-id; bh=2q1ai/hXQweAc/Y1uF2TOJhqJ0hbp/UliAcw49JGtR4=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOIULEngrpe9yas9+sVF6ymeTTeximYsfpzqZMpl9y fR6kD6jo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCI7FzP8T2ds3Jyy/f/W2VPt VqRtcby7n91bY8bXsvwzpnuTvl89/Jnhf7K1/cUvSTFHrMN/H6s3frfJ+I/zDDMWI+ZnLK94r0X KMAEA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 A BPF scheduler can return 0 from get_send() without picking any subflow, e.g. the bkup one from the BPF selftests, when all the subflows are backup on both sides. With data to send, a DATA_ACK received while the msk is not owned by the user then makes the push loop of __mptcp_subflow_push_pending() spin forever, in softirq: watchdog: BUG: soft lockup - CPU#2 stuck for 49s! [python3:182] (...) RIP: 0010:bpf_iter_mptcp_subflow_next+0xf/0x40 (...) Call Trace: bpf_prog_bf2471f1d206d5cc_bpf_bkup_get_send+0x78/0xd7 bpf__mptcp_sched_ops_get_send+0x4c/0xb0 __mptcp_subflow_push_pending+0x148/0x390 mptcp_incoming_options+0x836/0xba0 tcp_data_queue+0x6da/0x10c0 tcp_rcv_established+0x2d5/0xce0 tcp_v4_do_rcv+0x13f/0x300 tcp_v4_rcv+0xbff/0x1200 (...) Stop this loop when the current subflow is not picked: if another one is, the loop already stops after delegating the push to it. The default scheduler always picks a subflow when returning 0: not affected. This issue has been found by an AI code review agent, while reviewing a patch for the BPF schedulers, and confirmed with a reproducer: the bkup scheduler on the client side, its only subflow marked as backup on both sides, data queued by the client, then data sent by the server, carrying the DATA_ACK causing the soft lockup above. Similarly, the push loop of __mptcp_push_pending() spins forever, with the msk and subflow locks held, when a BPF scheduler keeps picking a subflow that cannot send, e.g. a new subflow in SYN_SENT picked by the bkup scheduler before its backup flag is set: mptcp_sendmsg_frag() then returns -EAGAIN, which does not decrease push_count in this state. Decrease it after any failure: -EAGAIN is only returned for a subflow that cannot send, or that has just been reset. The default scheduler does not pick such subflows: not affected. This second issue has been found by an AI code review agent (Clashiko), while reviewing a previous version of this patch. Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue found by a review agent v3: also stop the push loop of __mptcp_push_pending() when the picked subflow cannot send (Clashiko) --- net/mptcp/protocol.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index f361cd40a8e4..a3c2d8f93bd7 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1901,10 +1901,7 @@ void __mptcp_push_pending(struct sock *sk, unsigned = int flags) =20 ret =3D __subflow_push_pending(sk, ssk, &info); if (ret <=3D 0) { - if (ret !=3D -EAGAIN || - (1 << ssk->sk_state) & - (TCPF_FIN_WAIT1 | TCPF_FIN_WAIT2 | TCPF_CLOSE)) - push_count--; + push_count--; continue; } copied =3D true; @@ -1961,6 +1958,9 @@ static void __mptcp_subflow_push_pending(struct sock = *sk, struct sock *ssk, bool keep_pushing =3D false; else copied +=3D ret; + } else { + /* a BPF scheduler might not pick any subflow */ + keep_pushing =3D false; } =20 mptcp_for_each_subflow(msk, subflow) { --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557715; b=IzRT7Viyz2bHrT0mMWOuQC7gcTvnf9sAkjLQotTrHwawfmOSgQlcHP2ITxoNwVC25WCq a0dQEvSn7PVVqt34lzWDbuofZv7ND0/5wRswHP4vfCx6IaRG37c91vopc2jSvn+5c8zhz 9aJ83jFN6rGtTdUj0BMXVkGnR2VyrZ/s/NJzZ9yA/1alynmKmGPv8YBIfRe3AnSn+jjeE qtWB1FR3wbHi2fbEHS4Jt2LhD3lCg2V5zstyMzGJnYOuTjjYEUSw84f0cL0K/Gl3YwRjq p+9mon9ve5sFS4DOR49I2P2NWrP6eY/KYxDwnkHNSQzQbw80QfBkUrL5wUxQehAtL/g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557715; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=EWoHBY+BB6ZCC1JySWSWV/hMjELII5E3R7ugWCGN40o=; b=db6IdXGqMG7smf8RORsPKMdDfQnnwYBAsK/nZ7gn4leOBzdM+2fIggMGJtWbEA42uCXR PpIs4pyowi7BEbYzvEdXQFHS3ht8Z3RJ5yZpRCHRMEllvxGKoNIRDjWLl2rCcLJqqjRrT AO85F3WOzYnZ/3TP6d9SIjuYrGCbD8X+S/p0JF1lTtFhAgpMM2J/xQAkdQCyYY2T95LdO eAjOGvlDJ6ayKC0Zil2m7J9y8RV3+CIrAH3LpeOpdV8UWj/x8Al3KIl6/wVNV8fUirmRB n8qu9VWlc0p+jOtQymtivBTK/zgaK0akOY/QgW2Ta/Poxd/TjHDnSv97elriRj1G40Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aZ0Tj9gb; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 60598606A31E for ; Tue, 24 Nov 2026 22:01:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aZ0Tj9gb Received: by smtp.kernel.org (Postfix) with ESMTPSA id 680F01F000CF; Tue, 24 Nov 2026 22:01:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557714; bh=EWoHBY+BB6ZCC1JySWSWV/hMjELII5E3R7ugWCGN40o=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=aZ0Tj9gbxq1pVILOgIO1nhxHJk21aHJfO+BrbGT7nYI2yagFj2WmmE2vY+/oRhPhL wL3J0abgOhS/HQqY6F3mcicjHxFiqB2OqRIJE7owBuMK4sszUvLxx33xRFbV204nic PSHy7QGVTzuOFLR0RyP6jQCEka6cUMs+y1dYhiolPdejH78uhSmkGLSw/hPnUB5DXC wBZpGl68XXp/ruIrqA+CJWf7SShRfjJ2WUsrfx2AgvT+suN+XGad8OKRSIeXnW1XiA GtEHQSh2bvIR+O7rUUmWFtZUxERRUCtRZcDQifh62/R13qOl0Pr608JWrESRi0TMtr 0nit5kZLiN9rg== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:03 +0100 Subject: [PATCH mptcp-net v3 46/50] Squash to "bpf: Export mptcp packet scheduler helpers" X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-46-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2040; i=matttbe@kernel.org; h=from:subject:message-id; bh=dsA0uoT5xLmopMB0Vy93rCGpv2MKessFV60gPVmJqv0=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOEXeP38jFnTrdI2rQWhzZLvTEQW25j/1JxP+Pe7a9 jUtguFBRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwET+LWdk+J2Uv2zOl/mNcYp2 P6c+O+3ynNmo5ZS0WHGc2pVNKn/WrWX4720yaXP0s4+OT7enbnp1V/FdwbfmU1sbKhQTm5tvBS9 qZwEA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 With a BPF scheduler, the rtx timer interval, msk->timer_ival, is only set if the scheduler calls the mptcp_set_timeout() kfunc: only the burst one does. This interval is 0 once all the data has been acked, and the rtx timer can then be armed with it, e.g. by the next push: it then fires every jiffy, retransmitting the data in flight until it is acked. Since "mptcp: arm the rtx timer if a push leaves data behind", this also happens when a push sends nothing, e.g. in a memory shortage: the timer then fires every jiffy, until a push succeeds. Set this interval before calling a BPF scheduler, as the default one does when picking a subflow, also when a subflow is already scheduled, as the scheduler is then not called. This issue has been found by Clashiko, while reviewing "mptcp: arm the rtx timer if a push leaves data behind". Not reproduced. Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for an issue spotted by Clashiko v3: also set the interval when a subflow is already scheduled (Clashiko) Note: when squashing, the commit message could mention that mptcp_sched_get_send() now sets the rtx timer interval with a BPF scheduler, as the default one does. --- net/mptcp/sched.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/net/mptcp/sched.c b/net/mptcp/sched.c index 1e59072d478c..01500f9f9f8a 100644 --- a/net/mptcp/sched.c +++ b/net/mptcp/sched.c @@ -182,6 +182,10 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) return -EINVAL; } =20 + /* as the default scheduler: the rtx timer needs an interval */ + if (msk->sched && msk->sched !=3D &mptcp_sched_default) + mptcp_set_timeout((struct sock *)msk); + mptcp_for_each_subflow(msk, subflow) { if (READ_ONCE(subflow->scheduled)) return 0; @@ -189,6 +193,7 @@ int mptcp_sched_get_send(struct mptcp_sock *msk) =20 if (msk->sched =3D=3D &mptcp_sched_default || !msk->sched) return mptcp_sched_default_get_send(msk); + return msk->sched->get_send(msk); } =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557716; b=5KQZycZ2uIOWhi5Me+Ieq+fN3HPaJeDM7jFJNEFvU4FzUoYWukjkoksavjWD+qyPBmNS alKcPSlVYNcG/WjQTv/aWBOU+1IYFm/qJttYzzvp9ZL9GOOPDtBzMddwxdrPFEPPFmMI0 fyrsJFe5EJlVhqb7y791zrjuAaNI+vcgyBG1zTdWj7z7kQgqfU6ckfI0YQsJkoGuyw371 u2xcmT6s9QUCiu14J4+iow30ndjKp6t0w5YJcvJ3qm1kdEuKpBnG+bq/yd59Lt/7ZFIZn JtW0+vzCm+E0WpHU2jEHhTDeRdlosYM40W2M0ZzRXKMsrvZ3/9nf8eZ6BUHY8wsvy4w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557716; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=y8i/oyaV74z/cMVr8AWAB0C86+EUiNTMHskUP6Bgd2U=; b=P1gRjqVNf7YZ6tWdukDVpGFpGfMFfpELB04NJ/4YsIBm61Jsp56beVZQaBo3XFlnpg/G 3D4SqwGrXB1Lbr7c3RN0Rl2dRKw1vkGR47VE3GX2DOO4huSnYi9EveQBD9gVR0M/sSHbY dnBEcfB0zkv7tZ+wA1w7wRIoTe/QwEBy5IPM5aRoOPMQhdn/Xk935QMqMHxR1Z5Ap4fWF 5gwRBCLsovHJN1PQSBYPaLAYojMbLneSdvyK87le/0H2Or9uOXdMT//QB4JlSKSUChkmh NVTcNwPOxQkNrXc/lG47kByMQj11A9OQYT7HT29uUCi1e7y6utPFe8piwloGVKJhI2Q== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iFEByJlG; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2154606A321 for ; Tue, 24 Nov 2026 22:01:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=iFEByJlG Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5F271F000EB; Tue, 24 Nov 2026 22:01:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557716; bh=y8i/oyaV74z/cMVr8AWAB0C86+EUiNTMHskUP6Bgd2U=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=iFEByJlG+Q6hEblSEbsshfbgHVRR4Bn8jUNtI/mde4+xD14Wnzfta3uL7LOZ5AO0V Ucm74Q4wnx2kc/6AcJti9h+rT4++KHEAv9SjJFMMNz44ZkS4z7BftsAfifQ4c0lZf/ N/UOjy5+lQo7wHufVe0DfVYGvAdzJVQ3Cf7u3x2g+sO+UTZUrzHi9bWHZ8RBO/Y66v Z832QW2i/q94OEbiCEz+vy0kIAlIB/5tKzFLG8a8Co/WPxQFZPsn2Ya0RSzGlRAjO2 XZ59cSTwrjOxtbRtfoLPk7T6TzM063ZfJ+y+oNa4EShOhD9MuG/XaUq8k6HpB3sbxC 69/fIX55rAN+w== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:04 +0100 Subject: [PATCH mptcp-next mptcp-net v3 47/50] mptcp: push pending data after a fallback on reception X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-47-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2273; i=matttbe@kernel.org; h=from:subject:message-id; bh=VoEFd52P0f/Wl7Nsl318cKlCYYppJi0VzYbUjZ9145o=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOEU2LV7tseqd2vy/AtrP3hvyHr2hlW1YveK5ifU60 +q9OhKhHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABPZ/Zzhf/RLp7AsibzjegIr ImwPmE5ZsEdcqL7hg59M9/9ZX69OSmJk6HI6VmVQ/UZ62dQVRx4b7U2ee8v1nBfHnflZDpcDlDY KcgAA X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When received data without DSS makes the MPTCP socket fall back to TCP, the data not sent yet is not pushed: on fallback, this is done by mptcp_incoming_options(), which already processed this packet before the fallback. This data, and the FIN of an earlier shutdown, then wait for the next packet from the peer, or for the MPTCP retransmission timer armed before the fallback: up to one RTO. Push it from mptcp_data_ready(), which follows these fallbacks, also the ones after a DSS corruption. For the next packets, this push comes after the one from mptcp_incoming_options(), which already sent what it could. This issue has been found by Clashiko, while reviewing "mptcp: don't send a FIN before the pending data on fallback", and confirmed with a new Packetdrill test: after a shutdown, with data still in the MPTCP socket, the peer sends data without MPTCP options. Without this patch, with an RTO of one second, the data is sent about one second later: dss_fallback_push_pending_server.pkt:27: error handling packet: timing er= ror: expected outbound packet at 0.312538 sec but happened at 1.274089 sec;= tolerance 0.100000 sec With this patch, the data and the FIN are sent right after the fallback. Note for the backports: the fallback after receiving data without DSS comes from commit 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data"), also in v6.12, and backported down to v5.15. Fixes: e32d262c89e2 ("mptcp: handle consistently DSS corruption") Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for mptcp-next, for an issue spotted by Clashiko in a fix pending in net --- net/mptcp/protocol.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index a3c2d8f93bd7..016b16b3cc92 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -1083,6 +1083,10 @@ void mptcp_data_ready(struct sock *sk, struct sock *= ssk) } else { __mptcp_move_skbs_from_subflow(msk, ssk, false); } + + /* mptcp_incoming_options() can't push if this data caused a fallback */ + if (__mptcp_check_fallback(msk) && sk_stream_memory_free(ssk)) + __mptcp_check_push(sk, ssk); mptcp_data_unlock(sk); } =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557717; b=wvZWKhwZ06xcRQgKaYNO9XIR7Mi9k41RO2oimHxt56CF8t5+yfgi4ypVVlg3TShN5d1p /BUv8JDtMlTbiPFrl9NTCmQQanSOI0Tmk0ZXcoSdGAvJs4nkI0PB2qaHUGQd+FM+YD7Np JGvVqDDGWRGqesDRvvrcmWCvvV3GkIjh+s5NZiA1PVcLEiPmUdnNMJQmWqdrgXA/2z5vT UJm/zAeNYnLf0WmQ9rYbhkzzPS4oWJMkTFsng47AHKp7QbF0pfHPSQmb3GKN7CLfFAL0j 9ur6Xc11TIRA8HcnhXWsQR8dO8V2rguSuBlAqIfAxVRqxb+UkRHnpCnhQ3QqHo0cJkQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557717; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=Jd7F08cGCiDp86kacKQcbWhyKdloas4iKA/eNsBn/SM=; b=YSChRHelHeV27Fn7oBTkj6Kf1rbcBYckMtWxhZNrOd+pJpuIihqSzXrM1DCkpFsmN9d0 ryyrqc2rwmYzIA2nNCpXtWBXuIwSFNdqKBI1AQ4vbDVxi/B6UqrUC8k/+sDVrRXQJmdr+ FEbI4D0HUDdFPBnNyrYalTZ0sXyDOSWjWMrHGt/wae2X+8G39F9UHXZFughBk2ugsg0Y3 6JVb/DxStrWvcoTkMx5osY01SzQne4lgxhwckXzWOYnOQ/kGG3GIvWUK3cvNb7E3+KLZC bFeW68NSzzWRtZjj2cEh/gTJkvBKCxBPIBfX7h5PBSA7TbUywFAqatq4vuf8Rxnfhqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bzUgU36f; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75687606A321 for ; Tue, 24 Nov 2026 22:01:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=bzUgU36f Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8BD31F000C4; Tue, 24 Nov 2026 22:01:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557717; bh=Jd7F08cGCiDp86kacKQcbWhyKdloas4iKA/eNsBn/SM=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=bzUgU36fnjkKYROeVmJRz7D+XyAd+Yw8UUFXc+L9syFzo+kqiDY99GzXDhWk41JRI 4x+KhuKZTBdeMu9WqvhUB8F5/Wc+i6RlbK6KS4OI5lk9rSZJ/kC8Q5Lk34qdzIZ1n5 5mInNAEq3E5RY0140aL75i7j43dhCPaCiLJI6TxPSRd4TjgkcCe7JiPEyAkEFGvto+ ckxDPbrC7vfvU1LpoXedKpD+gYAYaN4Q2JHah0g76+vvmRl3g5Um5jS0FjDe0vFO7p F4FRi+0LkbWbO8le1Ye3UALgjrBF2dhVQk0K+xyYtTm3QY7DMJ61ML/fiocaFVv3X5 l8Bim8hvj3MDw== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:05 +0100 Subject: [PATCH mptcp-next mptcp-net v3 48/50] mptcp: report errors as TCP does when closing X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-48-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=7050; i=matttbe@kernel.org; h=from:subject:message-id; bh=Ph5iSx0BeWYtMqvh4sPPWNlYm0a/1Ti2C3EtEq+SQ7I=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOEXFJbsz9D8+id0v0rC2XO/+5dPzrM4onL6rtjOh4 cspTUvpjlIWBjEuBlkxRRbptsj8mc+reEu8/Cxg5rAygQxh4OIUgIlMrGFkeC3BHGwzW+/Wdw13 AfGHAizup91OTymu15eZaGLe4s/rz/C/YL2omeHn2+8l7i5qlFxteHRC81FPvebS4L/2F0MX3OL iAgA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 When the close timeout expires, or when the last subflow is closed in another state than ESTABLISHED, the MPTCP socket moves to TCP_CLOSE without error, and recv() then reports ENOTCONN instead of EOF. In these cases, TCP sets SHUTDOWN_MASK and an error depending on the state: ETIMEDOUT after a timeout, and ECONNRESET, EPIPE or ECONNREFUSED after a reset. Do the same, as tcp_done_with_error() does, also in the late cleanup done by accept(), when the first subflow has been closed before: with the error of the last subflow, e.g. ETIMEDOUT after its RTO. After a reset, or without error, the error depends on the MPTCP-level state, e.g. EPIPE after a DATA_FIN. When a subflow error closes the socket, SHUTDOWN_MASK is now set too, as tcp_done() does. This changes the errors seen by the applications: after the close timeout, reading or writing now reports ETIMEDOUT once, instead of ENOTCONN or EPIPE, then EOF and EPIPE, as with TCP after a timeout. The tests checking these errors in the MPTCP Packetdrill repository have to be adapted. With the reproducer from the GitHub issue, where the only subflow dies by RTO, send() now returns ETIMEDOUT after the subflow timeout and the close timeout, instead of EPIPE. Link: https://github.com/multipath-tcp/mptcp_net-next/issues/648 Signed-off-by: Matthieu Baerts (NGI0) --- v2: new, for mptcp-next, as suggested in issue #648 on GitHub Note (Clashiko on v2): the FIN cleared by the disconnect of the first subflow is now handled by "mptcp: return EOF after a DATA_FIN, as TCP does", and a reset received before accept() after a fallback by "mptcp: report errors received before accept()". In FIN_WAIT2, the subflow error is still reported by __mptcp_error_report(), deferred to the release of the socket. --- net/mptcp/protocol.c | 88 +++++++++++++++++++++++++++++++++++++++---------= ---- 1 file changed, 67 insertions(+), 21 deletions(-) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 016b16b3cc92..0a7600aea181 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -518,6 +518,56 @@ static void mptcp_close_wake_up(struct sock *sk) sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN); } =20 +/* Mirror the tcp_reset() error propagation */ +static int mptcp_reset_err(const struct sock *sk) +{ + int err; + + switch (sk->sk_state) { + case TCP_SYN_SENT: + err =3D ECONNREFUSED; + break; + case TCP_CLOSE_WAIT: + err =3D EPIPE; + break; + default: + err =3D ECONNRESET; + } + + return err; +} + +/* No more data can be exchanged: report it, as tcp_done_with_error() does= */ +static void mptcp_close_err(struct sock *sk, int err) +{ + WRITE_ONCE(sk->sk_err, err); + /* This barrier is coupled with smp_rmb() in mptcp_poll() */ + smp_wmb(); + WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK); + mptcp_set_state(sk, TCP_CLOSE); + if (sock_flag(sk, SOCK_DEAD)) + return; + + mptcp_close_wake_up(sk); + sk_error_report(sk); +} + +/* As TCP: the error of the last subflow, e.g. ETIMEDOUT, but after a reset + * (EBADMSG: by MPTCP) or without error, it depends on the msk state + */ +static void mptcp_close_last_err(struct sock *sk, int err) +{ + switch (err) { + case 0: + case ECONNREFUSED: + case ECONNRESET: + case EPIPE: + case EBADMSG: + err =3D mptcp_reset_err(sk); + } + mptcp_close_err(sk, err); +} + static void mptcp_shutdown_subflows(struct mptcp_sock *msk) { struct mptcp_subflow_context *subflow; @@ -983,7 +1033,7 @@ static bool __mptcp_subflow_error_report(struct sock *= sk, struct sock *ssk) if (ssk_state =3D=3D TCP_CLOSE && !sock_flag(sk, SOCK_DEAD)) { /* This barrier is coupled with smp_rmb() in mptcp_poll() */ smp_wmb(); - WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); + WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK); mptcp_set_state(sk, ssk_state); } report =3D true; @@ -2809,7 +2859,7 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, { struct mptcp_sock *msk =3D mptcp_sk(sk); bool dispose_it, need_push =3D false; - int fwd_remaining; + int fwd_remaining, ssk_err; =20 /* Do not pass RX data to the msk, even if the subflow socket is not * going to be freed (i.e. even for the first subflow on graceful @@ -2817,6 +2867,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct= sock *ssk, */ lock_sock_nested(ssk, SINGLE_DEPTH_NESTING); subflow->closing =3D 1; + /* in case it is the last subflow: before its disconnect or dispose */ + ssk_err =3D READ_ONCE(ssk->sk_err); =20 if (flags & MPTCP_CF_PUSH) mptcp_cleanup_ssk_backlog(sk, ssk); @@ -2905,13 +2957,15 @@ static void __mptcp_close_ssk(struct sock *sk, stru= ct sock *ssk, mptcp_set_close_tout(sk, tcp_jiffies32 - (mptcp_close_timeout(sk) + 1)); mptcp_schedule_work(sk); + } else if (sk->sk_state =3D=3D TCP_CLOSE) { + mptcp_close_wake_up(sk); } else if (sk->sk_state !=3D TCP_ESTABLISHED || msk->in_accept_queue) { mptcp_check_rcv_close(sk); - mptcp_set_state(sk, TCP_CLOSE); - WRITE_ONCE(sk->sk_shutdown, - sk->sk_shutdown | SEND_SHUTDOWN); - mptcp_close_wake_up(sk); + if (sk->sk_state =3D=3D TCP_CLOSE) + mptcp_close_wake_up(sk); + else + mptcp_close_last_err(sk, ssk_err); } else { mptcp_start_tout_timer(sk); } @@ -3108,20 +3162,10 @@ static void mptcp_check_fastclose(struct mptcp_sock= *msk) unlock_sock_fast(tcp_sk, slow); } =20 - /* Mirror the tcp_reset() error propagation */ - switch (sk->sk_state) { - case TCP_SYN_SENT: - WRITE_ONCE(sk->sk_err, ECONNREFUSED); - break; - case TCP_CLOSE_WAIT: - WRITE_ONCE(sk->sk_err, EPIPE); - break; - case TCP_CLOSE: + if (sk->sk_state =3D=3D TCP_CLOSE) return; - default: - WRITE_ONCE(sk->sk_err, ECONNRESET); - } =20 + WRITE_ONCE(sk->sk_err, mptcp_reset_err(sk)); mptcp_set_state(sk, TCP_CLOSE); WRITE_ONCE(sk->sk_shutdown, SHUTDOWN_MASK); smp_mb__before_atomic(); /* SHUTDOWN must be visible first */ @@ -3441,8 +3485,7 @@ static void mptcp_worker(struct work_struct *work) mptcp_do_fastclose(sk); mptcp_for_each_subflow_safe(msk, subflow, tmp) __mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0); - WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); - mptcp_close_wake_up(sk); + mptcp_close_err(sk, ETIMEDOUT); } =20 if (sock_flag(sk, SOCK_DEAD) && sk->sk_state =3D=3D TCP_CLOSE) { @@ -4795,10 +4838,13 @@ static int mptcp_stream_accept(struct socket *sock,= struct socket *newsock, */ if (unlikely(inet_sk_state_load(msk->first) =3D=3D TCP_CLOSE)) { if (unlikely(list_is_singular(&msk->conn_list))) { + int err =3D READ_ONCE(msk->first->sk_err); + mptcp_check_rcv_close(newsk); /* not reported in the accept queue */ __mptcp_error_report(newsk); - mptcp_set_state(newsk, TCP_CLOSE); + if (newsk->sk_state !=3D TCP_CLOSE) + mptcp_close_last_err(newsk, err); } mptcp_close_ssk(newsk, msk->first, mptcp_subflow_ctx(msk->first)); --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557718; b=iPj+klbIyoMTTLKCRBHU6v9lELpaNwU4XRjktUOYVMqNQWT1794KAoPrq2PMIQuy5LDT H70G8QAFcgAXwvdEqIEkfcsrx1Yfmt49g23kbg5+ApQb/G8rZD2dtFITJWmJV2V6F9m8L DtaKsuNI4zD3kDV2xo8doypRNepy67nA25GowjgEfZ4LtEB6HDDDYwU7KBOQHQYd2PJ1I KPMiVezVb8eTySsPxAhNsBgcLmvTSjYVqGgkLO5xQ5evucacelC/T63Hnqx/sCUnp803P 78HO1L4qzUqICa9iQvCBAcaR7ZZDBM861GUev8iyXddZ8TcCforIIuw6ZAoTGd2T9eQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557718; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=GKy4IzqPyNbbe/Z9k7aHJ2BdVCuLhUY3DMyghIU6m3A=; b=pWfiP1Qk0VjEi+QmO+ZzxfpB4v0dn7EoCkMGViQkgDtk+M111NUmwi+3DQP1BsKwLm6S IdeG0v0cHTH1MZXrOa4rsi95s/RxrDgF3JomxUlltn3BKSrFRfJA++MZTxvA9V1Vnv5E4 j9O4kkSvefpfqWb4xV1nk7Rs+x++3kMFqV48eB6PsuDLac11fWlQ2w3nS0mS+JmkKCERu 8S4MF6ESRq2KC/0GWuTUU/eJsSB3FnYsY4OTCZ2uodraLk+OXvPVmuvDSfNw+e0WQkpMq hVPctDFIotNUOKtIrc6DP5XXbq8NjqPV4Mm7r8a/MXdHAhVl0O9/K+D1vPsoQK6CaRw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aFKvQLB6; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE4DC606A31E for ; Tue, 24 Nov 2026 22:01:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aFKvQLB6 Received: by smtp.kernel.org (Postfix) with ESMTPSA id C81AF1F000C4; Tue, 24 Nov 2026 22:01:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557718; bh=GKy4IzqPyNbbe/Z9k7aHJ2BdVCuLhUY3DMyghIU6m3A=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=aFKvQLB6D7oyubjHLgh4/FFmBbXvUeG2sMG9e01cI50knY+2SQZz+WP+pchhL9OwL iG4keA0VjiyGeeCvvfQYub43d8DwO7eHilmzY4jAGwZs4eg3ozXSng6UoIZZGd1uOW Jragh4UQxumaQ0VcG/o21pVAjysY1vrkhN2sP6pI863UfWm/OUCxs8z2mTyZ49mSBH V6R8iTuXtjACXj9sozAOA7NwIrDuTLY8IcBI+mBrmSHMKg4qyVp22Bo77KCPS0ovBg UDW1GXQ8+EjC+GxTshnEmM63SU2wYpo3JoDeRIVzwwt7zBviITqeN/nfWq8nPPrfcJ bqBIhwI9kmSsQ== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:06 +0100 Subject: [PATCH mptcp-next mptcp-net v3 49/50] mptcp: trace: name all the mapping statuses X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-49-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=1011; i=matttbe@kernel.org; h=from:subject:message-id; bh=gyak2MPogMH+dV/UnL8UcZqNnchGm6wQy7IX9HHs9sY=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOMXC8guznJ71G0z6/kTwncOGTYHvGjZN49jKtFRm6 W2h9C0MHaUsDGJcDLJiiizSbZH5M59X8ZZ4+VnAzGFlAhnCwMUpABNZVMTI0OYRXVfhsWOxnfGR l7ZsfCpHlD7pCnHcka3W7jNwFP67h+GfwnG9jKgpa80ULrFYnrnAZiK+IfnB4i2vXz1pmqMv3nC RDQA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 The subflow_check_data_avail tracepoint prints the status returned by get_mapping_status() with its name, except for MAPPING_BAD_CSUM and MAPPING_NODSS, added later: they were printed as numbers. This has been found by an AI code review agent (Clashiko), while reviewing a patch adding another status. Signed-off-by: Matthieu Baerts (NGI0) --- v3: new, for an issue spotted by Clashiko --- include/trace/events/mptcp.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/trace/events/mptcp.h b/include/trace/events/mptcp.h index c47fa2672b84..ebc7408c1fa6 100644 --- a/include/trace/events/mptcp.h +++ b/include/trace/events/mptcp.h @@ -19,7 +19,9 @@ { 1, "MAPPING_INVALID" }, \ { 2, "MAPPING_EMPTY" }, \ { 3, "MAPPING_DATA_FIN" }, \ - { 4, "MAPPING_DUMMY" }) + { 4, "MAPPING_DUMMY" }, \ + { 5, "MAPPING_BAD_CSUM" }, \ + { 6, "MAPPING_NODSS" }) =20 TRACE_EVENT(mptcp_subflow_get_send, =20 --=20 2.55.0 From nobody Wed Nov 25 18:25:58 2026 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795557720; b=5YxtG6uU3762spT5ohYRvwkpCsSuZu/S2r/Y67RL0DJRPBHIcLoKhjqTMbsVbMMF4LFP 0UoAVdkNB7gvE0zwyf2nbfTQvWWW46+5L3NbV4kgvbK3h8SmvClnDSnIx0sJvXI7Z3Prc FCQiwH+Fe0kqe/XDs1G9Y5QihySdE57JGETPvNKGnJiqzbn9z6gjtGjZPVeOAh8709U8r Y4Zvn1dKYnLXJGW5kHOqh32WAAZH0rXU6uksOzRzPWN57/vnEMK/9i7jEqXDEVpSJ6rzl aYwhhJ14kixPJTxNaYzkEL0U1p3o8B0A9QbsrxM/Z38TQ70F7wuBgnxY1uRZ8mO8KAg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795557720; h=Received:DKIM-Signature:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Mailer:X-Developer-Signature:X-Developer-Key; bh=O16Xz9pcsCpx+Y4NNFZRTY55w9BCwh9Bvb1j8eCRXUs=; b=4pH9I+/+WUr9v7bRCuM2khNEKQuRYXSwZqF+UxOrrWAeBikkoAbte3cBAwvSZh4b9fZd FFvL5ReLIm8RHcPDknLKmV7ZGOU3GsZuFunQr9di02WYSw5nUWhZkqdhSL/Oarxdoe4GN jpqsuLriWFdQajqQlEO7S9Ya7H/gmcNVl4ZDOJPt9461n+ftz/j9Kgk3w8na7R84nlR1W Cf28j/FUVwqWFtBiJ7chHmmVW1pXDj5wCIU0AuRSjH8qMqEe01HqPj+p6JGwWWLsvRIg/ 1PH/A93+/JJsB1lDakkVOO91H+BY8rhBf3o2p8u5RIrxSeJzaiKltm0Ki8WTeGHq3yg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GGQlrGgK; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 03172606A31E for ; Tue, 24 Nov 2026 22:02:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=GGQlrGgK Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1ED0A1F000C4; Tue, 24 Nov 2026 22:01:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795557719; bh=O16Xz9pcsCpx+Y4NNFZRTY55w9BCwh9Bvb1j8eCRXUs=; h=From:Date:Subject:References:In-Reply-To:To:Cc; b=GGQlrGgK8IeIVhgSHPfLzdwh5LorSA4IbpJqwf8nBuwSVh76pisYgUMaXV+SZUsVP 2ZNtFUmwKt/Or6UOPEaoKgT9nfWFel3Mi+FS2Gh+7vXaXdec4JdWyWZndnwU8R84qr TY2eGgrrudxKE5cit134/CrfMw8HzINxWkNFlZRm2DmlNie/ZJOlsKlX2KQvmlVAqi +D1khUepZt22cr8l8jQZxbbvgaEb4xIpLeYOx/fBQSi3qHeWvBxK9WPqzu7cKoGa86 zmhR2AJhfklZKU8gfXhaZ3NhIsbSlLaJXDzx3/h1OJlnbRIFReuU0Gezqq5phL5MJ7 GtlU0MjTUuoMA== From: "Matthieu Baerts (NGI0)" Date: Tue, 24 Nov 2026 23:00:07 +0100 Subject: [PATCH RFC mptcp-next mptcp-net v3 50/50] mptcp: reset when the DSS disappears after a DATA_ACK X-Mailing-List: mptcp@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20261124-mptcp-cmason-fixes-v3-50-416c0920c73f@kernel.org> References: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> In-Reply-To: <20261124-mptcp-cmason-fixes-v3-0-416c0920c73f@kernel.org> To: MPTCP Linux Cc: "Matthieu Baerts (NGI0)" X-Mailer: b4 0.17-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=9776; i=matttbe@kernel.org; h=from:subject:message-id; bh=nOnbLzuo+GXABWI9YVoTiXdZ4ouMQ6YwdR/jgxDXZ6k=; b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLLZOMWmJQibrQ7Rmp4uq3hnb4uuekRO+waOfd8lNor4M 1ju+jupo5SFQYyLQVZMkUW6LTJ/5vMq3hIvPwuYOaxMIEMYuDgFYCLvwxkZtiWe52x7EuPWcTZa b4PM92OVfHbP7W4crxY5w/LpmUfZBIa/YqvXvf/CxMtpodv0s4RD/ZHyxlXTRFuvn7oqca4uMGg hGwA= X-Developer-Key: i=matttbe@kernel.org; a=openpgp; fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073 RFC 8684, section 3.7, describes a fallback to TCP for the case where the MPTCP options get through on the SYN, but not on the next packets. A sender includes a DSS option in each segment "until one of the sent segments has been acknowledged with a DSS option containing a Data ACK": it then has "the confirmation that the DSS option passes in both directions". After that, a subflow that loses its MPTCP options "SHOULD be treated as broken and closed with a RST", with the "Middlebox interference" reason. It's a *SHOULD*. Commit 119d51e225fe ("mptcp: fallback when MPTCP opts are dropped after 1st data") did this fallback as long as allow_infinite_fallback is set, i.e. also after this confirmation, and left the check of the DATA_ACK for later [1]. Such a late fallback is fragile: the peer might still resend data that was mapped before, or a zero window probe might have mapped old data again. The previous commits "mptcp: do not fallback while old data is in flight", "mptcp: stop resending data to a peer that fell back", "mptcp: don't resend data acked without MPTCP opts" and "mptcp: continue the last mapping after a fallback" handle these cases, except one: if only the receiver falls back, it can deliver data resent at the MPTCP level as new data, if the sender does not reset the subflow before, e.g. with an older kernel. Yeah, a very specific corner case. Now, when data without DSS is found on a subflow, the subflow is reset if a DATA_ACK received on it acknowledged data that had been sent: the MPTCP options then passed in both directions. Except after an MP_FAIL exchange: a fallback to TCP is then in progress, so data without DSS is expected, even if the infinite mapping has not been seen. This also closes the case above, but only for a receiver whose data has been acknowledged. Receiving a DATA_ACK is not enough: when the MPTCP options are only dropped in one direction, the peer can fall back while the DATA_ACKs it sent before acknowledged no data. A client that is not fully established falls back when a packet from the server has no MPTCP options, e.g. an ACK of its data, and the other hosts when they receive data without DSS. Except after an MP_FAIL, Linux falls back without sending an infinite mapping, then sends data without DSS: the other side can only fall back too, as before, if its data had not been acknowledged. For the same reason, the amount of received data -- e.g. more than an initial window -- is not used. The same is done when a mapping is invalid, e.g. when it does not cover the received data after a resegmentation by a middlebox, but not for an infinite mapping, the fallback signal from the RFC: it gets a new MAPPING_INFINITE status, also named in the tracepoint. When a middlebox starts dropping the MPTCP options in the middle of a connection, after a DATA_ACK acknowledged data, the subflow is then reset, instead of falling back to TCP when it was safe. If it was the only subflow, the MPTCP connection stays without subflow until the close timeout -- 60 seconds by default, see net.mptcp.close_timeout -- unless a new one is created in between. New Packetdrill tests check these resets. Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/519 [1] Signed-off-by: Matthieu Baerts (NGI0) --- v2: also reset on an invalid mapping (Clashiko), and commit message: the remaining case is now handled by the sender v3: name MAPPING_INFINITE in the tracepoint, and msg: all the invalid mappings (Clashiko) Note: this commit changes the behaviour, it is for next. It fixes a very specific corner case (but it follows what the RFC 8684 recommends to do) but for that it needs an extra flag and more checks. Is it worth it? (I think so, but that's why it is flagged as RFC.) Note (Clashiko on v2): subflow_nodss_is_fatal() also handles the invalid mappings, and the description of MPTCP_MIB_DSSRESET is imprecise: to be improved if this RFC is accepted. Note (Sashiko on v2): an skb going past the end of its mapping is still handled by mptcp_dss_corruption(), which falls back, even after a DATA_ACK: to be covered too if this RFC is accepted. --- include/trace/events/mptcp.h | 3 ++- net/mptcp/options.c | 11 +++++++---- net/mptcp/protocol.h | 3 ++- net/mptcp/subflow.c | 29 +++++++++++++++++++++++++---- 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/include/trace/events/mptcp.h b/include/trace/events/mptcp.h index ebc7408c1fa6..527eb7a18528 100644 --- a/include/trace/events/mptcp.h +++ b/include/trace/events/mptcp.h @@ -21,7 +21,8 @@ { 3, "MAPPING_DATA_FIN" }, \ { 4, "MAPPING_DUMMY" }, \ { 5, "MAPPING_BAD_CSUM" }, \ - { 6, "MAPPING_NODSS" }) + { 6, "MAPPING_NODSS" }, \ + { 7, "MAPPING_INFINITE" }) =20 TRACE_EVENT(mptcp_subflow_get_send, =20 diff --git a/net/mptcp/options.c b/net/mptcp/options.c index 41eb39968a9a..e561143dd121 100644 --- a/net/mptcp/options.c +++ b/net/mptcp/options.c @@ -1144,7 +1144,7 @@ static void rwin_update(struct mptcp_sock *msk, struc= t sock *ssk, subflow->rcv_wnd_sent =3D mptcp_rcv_wnd; } =20 -static void ack_update_msk(struct mptcp_sock *msk, +static bool ack_update_msk(struct mptcp_sock *msk, struct sock *ssk, const struct sk_buff *skb, struct mptcp_options_received *mp_opt) @@ -1153,6 +1153,7 @@ static void ack_update_msk(struct mptcp_sock *msk, u32 win =3D ntohs(tcp_hdr(skb)->window); struct sock *sk =3D (struct sock *)msk; u64 snd_nxt; + bool acked; =20 mptcp_data_lock(sk); =20 @@ -1185,7 +1186,8 @@ static void ack_update_msk(struct mptcp_sock *msk, if (after64(msk->wnd_end, snd_nxt)) __mptcp_check_push(sk, ssk); =20 - if (after64(new_snd_una, old_snd_una)) { + acked =3D after64(new_snd_una, old_snd_una); + if (acked) { __mptcp_snd_una_update(msk, new_snd_una); __mptcp_data_acked(sk); } @@ -1195,6 +1197,7 @@ static void ack_update_msk(struct mptcp_sock *msk, trace_ack_update_msk(mp_opt->data_ack, old_snd_una, new_snd_una, new_wnd_end, READ_ONCE(msk->wnd_end)); + return acked; } =20 bool mptcp_update_rcv_data_fin(struct mptcp_sock *msk, u64 data_fin_seq, b= ool use_64bit) @@ -1356,8 +1359,8 @@ bool mptcp_incoming_options(struct sock *sk, struct s= k_buff *skb) /* we can't wait for recvmsg() to update the ack_seq, otherwise * monodirectional flows will stuck */ - if (mp_opt.use_ack) - ack_update_msk(msk, sk, skb, &mp_opt); + if (mp_opt.use_ack && ack_update_msk(msk, sk, skb, &mp_opt)) + subflow->dss_confirmed =3D 1; /* MPTCP opts pass both ways */ rwin_update(msk, sk, skb); =20 /* Zero-data-length packets are dropped by the caller and not diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h index 59ddf3dafeba..70cd119bdbb8 100644 --- a/net/mptcp/protocol.h +++ b/net/mptcp/protocol.h @@ -609,7 +609,8 @@ struct mptcp_subflow_context { resetting : 1, /* subflow is resetting */ old_data_pending : 1, /* old data not acked with MPTCP opts */ map_old : 1, /* MPC: peer's last map is below dsn_end */ - __unused : 7; + dss_confirmed : 1, /* a DATA_ACK acked our data */ + __unused : 6; bool data_avail; bool scheduled; bool pm_listener; /* a listener managed by the kernel PM? */ diff --git a/net/mptcp/subflow.c b/net/mptcp/subflow.c index 190c75311ff6..efbd3efd379e 100644 --- a/net/mptcp/subflow.c +++ b/net/mptcp/subflow.c @@ -1072,7 +1072,8 @@ enum mapping_status { MAPPING_DATA_FIN, MAPPING_DUMMY, MAPPING_BAD_CSUM, - MAPPING_NODSS + MAPPING_NODSS, + MAPPING_INFINITE }; =20 static void dbg_bad_map(struct mptcp_subflow_context *subflow, u32 ssn) @@ -1242,7 +1243,7 @@ static enum mapping_status get_mapping_status(struct = sock *ssk, if (data_len =3D=3D 0) { pr_debug("infinite mapping received\n"); MPTCP_INC_STATS(sock_net(ssk), MPTCP_MIB_INFINITEMAPRX); - return MAPPING_INVALID; + return MAPPING_INFINITE; } =20 if (mpext->data_fin =3D=3D 1) { @@ -1453,6 +1454,22 @@ static void subflow_update_dsn_base(struct mptcp_sub= flow_context *subflow) subflow->dsn_end =3D end; } =20 +/* RFC 8684, 3.7: no fallback once a DATA_ACK acked our data, except MP_FA= IL */ +static bool subflow_nodss_is_fatal(struct mptcp_sock *msk, + const struct mptcp_subflow_context *subflow) +{ + bool fatal; + + if (!subflow->dss_confirmed) + return false; + + /* before a fallback, only an MP_FAIL clears allow_subflows */ + spin_lock_bh(&msk->fallback_lock); + fatal =3D msk->allow_subflows; + spin_unlock_bh(&msk->fallback_lock); + return fatal; +} + static bool subflow_check_data_avail(struct sock *ssk) { struct mptcp_subflow_context *subflow =3D mptcp_subflow_ctx(ssk); @@ -1473,7 +1490,9 @@ static bool subflow_check_data_avail(struct sock *ssk) status =3D get_mapping_status(ssk, msk); trace_subflow_check_data_avail(status, skb_peek(&ssk->sk_receive_queue)); if (unlikely(status =3D=3D MAPPING_INVALID || status =3D=3D MAPPING_DUMM= Y || - status =3D=3D MAPPING_BAD_CSUM || status =3D=3D MAPPING_NODSS)) + status =3D=3D MAPPING_BAD_CSUM || + status =3D=3D MAPPING_NODSS || + status =3D=3D MAPPING_INFINITE)) goto fallback; =20 if (status !=3D MAPPING_OK) @@ -1523,7 +1542,9 @@ static bool subflow_check_data_avail(struct sock *ssk) return true; } =20 - if (!mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) { + if (((status =3D=3D MAPPING_NODSS || status =3D=3D MAPPING_INVALID) && + subflow_nodss_is_fatal(msk, subflow)) || + !mptcp_try_fallback(ssk, MPTCP_MIB_DSSFALLBACK)) { /* fatal protocol error, reset the subflow and let the * worker close it */ --=20 2.55.0