🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #25970

[PATCH net 2/9] mptcp: keep an orphan while it can send its data

#25970
From: "Matthieu Baerts (NGI0)"
Date: Wed, 02 Dec 2026 21:29
92 lines
11859 bytes
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")
Cc: stable@vger.kernel.org
Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/647
Reviewed-by: Mat Martineau <martineau@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.c | 31 +++++++++++++++++++++++++++++++
 1 file changed, 31 insertions(+)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index d6a07fa4b4e4..82a0cbe38192 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2814,6 +2814,28 @@ static bool mptcp_close_tout_expired(const struct sock *sk)
 		  inet_csk(sk)->icsk_mtup.probe_timestamp + mptcp_close_timeout(sk));
 }
 
+/* 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 = mptcp_sk(sk);
+	struct mptcp_subflow_context *subflow;
+
+	if (!sock_flag(sk, SOCK_DEAD) || msk->snd_nxt == msk->write_seq)
+		return false;
+
+	mptcp_for_each_subflow(msk, subflow) {
+		struct sock *ssk = 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;
@@ -3151,6 +3173,11 @@ static void mptcp_worker(struct work_struct *work)
 	if (test_and_clear_bit(MPTCP_WORK_CLOSE_SUBFLOW, &msk->flags))
 		__mptcp_close_subflow(sk);
 
+	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;
 
@@ -3392,6 +3419,10 @@ static void mptcp_check_send_data_fin(struct sock *sk)
 
 	WRITE_ONCE(msk->snd_nxt, msk->write_seq);
 
+	/* 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 = mptcp_subflow_tcp_sock(subflow);
 

-- 
2.55.0
Technical Details
Message-ID: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org>
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376062-linux-kernel-netdev=dewy.ru
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu.MISMATCH!feed-us-txt.newsdeef.eu!feed-us-ny.newsdeef.eu!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376062-linux-kernel-netdev=dewy.ru
From: matttbe@kernel.org ("Matthieu Baerts (NGI0)")
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 2/9] mptcp: keep an orphan while it can send its data
Date: Wed, 02 Dec 2026 22:29:32 +0100
Organization: Usenet Network
Message-ID: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org>
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2065671"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:oTU+laIB+sMcweGDuX/V7k0rFtE= sha256:N1QIE9/ooGFcPdlOBM+472J+nAgj/a9HhVoeivx/vLQ=
	sha1:0Kvl897EyqRiwV432YsSu2I7i+4= sha256:G/XTn4RjQjhq0qRDf6LvBTGnzf0taTtpwfemqJBTUfQ=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 63B0E117738; Thu,  3 Dec 2026 00:32:11 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.401
X-Spam-Status: No, score=-3.401 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1,
	DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id ZIh8f1bjOg9J;
	Thu,  3 Dec 2026 00:32:08 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-376062-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id B9C82117723; Thu,  3 Dec 2026 00:31:59 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id D3BD325F31; Wed,  2 Dec 2026 21:31:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796247117;
	b=QC5lSMuPA20f0baHx1DdOxjN+lw90nRwcOyzSd8eudHE/Jth9aUjdIh5PhJgggg6OV3A
	 e8ocAR09zqBzi8D+f5G+QoidqThHApaLawpWNnuoQPeWVSj4jc8Gpc1LyaIeHnKokSgPD
	 EK7y87+bohDWRq+rHfqsmUQ++RK+3majVOQAjZ3JnTJgWytBZ+g8kzrna6ATBhR945zEj
	 S7kJamc15KxEuMCqSUk2auc0iS6AI612fWmD/7AtquLPMFuRq80GAQW1vEf6n7xZhwIu8
	 GIVfb/RtVozwDu5RDft/pZaOh+fSsrfzYX+tr5DY5ZxSMJ6qNryJvzLwggjcbqwJOTQ==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796247117;
	h=X-Original-To:Received:Received:DKIM-Signature:From:Date:Subject:
	 X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc:
	 X-Mailer:X-Developer-Signature:X-Developer-Key;
	bh=BV4wMUPNbXCAPYABgwHQWVYTNE3NHB0TNbtw4oLBRpU=;
	b=qOmH8/P21I6qG40ekwuaLnKeO+vGDbVNYchQZJHsjQVGDPQCbuzut0fygpWrIX5fZKI3
	 byhpnbHX8qfxT4hXI8+ziSvBayfmzEC00VguVE0xu8TGuT0uMIRAKu3yuF5cHRQ0q1P/B
	 zNzBtlDG7Tfk6xPYj4M9mtHRTkPRRfmYce8HtR8Vg3GJcNBgfO4nvLMo30ispdX4tjmWz
	 rRLkVxKAI37wEGlg4cpCEVqGHaKJ1+UJTr3ODxg0R+PMYgEglai+500/tjChwcxDqiyeE
	 lngShKknmu8dT2fqoOb3q1PR1OvxK6ApLS1cq3zC7oR1aegfXw1BdvgspMWcglZtwXw==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=CfK4V+yb;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 98655606A32F;
	Wed,  2 Dec 2026 21:31:57 +0000 (UTC)
X-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=CfK4V+yb
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796247116;
	b=tCMBgVmVo4X44vRUXUe530kMO6OqC+j7ZeQigMcIKkjd/VCFnC3b9CeaXzHDRGQPqFFR
	 oTV4UyO3cSUvn+8w+8J/BxeIfLbLFZayDjbrd2Efg/2VcQA53eOKLuVsNprahfExWhaI+
	 C1HjaMApQcE3LwMbIG+yDNAMroakVskANXZG7XGZoXYTxTF14PLyWDLHaeLTeARNp7BU4
	 Alsg50I6qdX7MzmlhEbWu9gUjiKe0f27aUjqN2W0AqM2mYF9Jp3FZOGddjQ6cWazKVDwA
	 u++K9oQzMdA00GGedH63AQBMkPt/yXrrXFw086OAfOxeTsiKpO8do6vm6/USynED1Ug==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796247116;
	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=BV4wMUPNbXCAPYABgwHQWVYTNE3NHB0TNbtw4oLBRpU=;
	b=lB/jEqH3dS52/IjSL1mA87ng80Uskszz4FlagC1bhSw+/EKRjD6dB3DE+Wn4iEuKS/7z
	 53Vo4/PrvxhOzmkAnj2mJlrWrFVqdU4pOZKGocK4u2mm0QBkYpKaeFrqWBTYqymYSuuoJ
	 1K+LCgwTOHFdVYp/VSjrx0EQdCN0p/5EZ34ZKnZmNCCRe9/NV7zBdh4+gY+zoxcG3mEz0
	 L7T32erQICRkbcGDoSW7tv1H1vBRz4PqKeZsTGFw97HGyNmcdP8wjOwMk921gZ2yNRqSd
	 Ojt6NTEz3mMyV23/bykITi2yusw/VAc5ZTrG/QSrBLTq6vdpueWqUhVWR4F5ZFjCOlg==
X-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=CfK4V+yb;
	arc=none smtp.remote-ip=100.103.45.18
X-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 B7A1D606A322;
	Wed,  2 Dec 2026 21:31:56 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2897F1F00896;
	Wed,  2 Dec 2026 21:31:54 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796247116;
	bh=BV4wMUPNbXCAPYABgwHQWVYTNE3NHB0TNbtw4oLBRpU=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc;
	b=CfK4V+yb4RRr2uPaZMoEr+zVmZl9AIAk0QfR6yfV3oZlCQwV1FtlqA+WwTOkhjK58
	 WnttNnN1hcEyfwVq3bihmiv3VXtLVuLaNqQzluWNVl204I2Ij7KEWYh9RHNhnfRVsj
	 CM0BcDsMQcqq/x4QzMisid6i+w0MG5OMh5VOyPL33yKLLmRiTiWWp0hFzLQ90FFA5n
	 Me4yI7MvbWriGiF/uMSfg0gGOIcGOXTW/ue8UM1avP1Zn9SZmHIsn+KATY1eTqpn8j
	 lcTqbuLhc5uCEW0AaLcALi/USSYuoRTGopy6zNKRIIjQPQrslYgEBt7v0eCl4y55/u
	 UVReNf/Az56+g==
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17@kernel.org>
X-Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, 
 "Matthieu Baerts (NGI0)" <matttbe@kernel.org>, stable@vger.kernel.org
X-Mailer: b4 0.16.0
X-Developer-Signature: v=1; a=openpgp-sha256; l=3583; i=matttbe@kernel.org;
 h=from:subject:message-id; bh=AyhMNA66WRkOaygGQsogwq36/Mh+2ly45BoU9gQdeIQ=;
 b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLIF+mzPP/jqX+dhWOTW887f80mR7yWeElMJ1d+tZ0pYy
 l0ehxh1lLIwiHExyIopski3RebPfF7FW+LlZwEzh5UJZAgDF6cATMRNj5Fh04zUTc9DIs50X9x5
 /JaI0dFCxm3s4ZVS58y5Q79Kc/svZmT4E9fWGm1Sukfl0bJgZ9FDV34FNfA0fV7zVMpW8lrs7oX
 sAA==
X-Developer-Key: i=matttbe@kernel.org; a=openpgp;
 fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073