🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #17472

[PATCH net 6/7] mptcp: don't send a FIN before the pending data on fallback

#17472
From: "Matthieu Baerts (NGI0)"
Date: Mon, 16 Nov 2026 22:06
62 lines
11272 bytes
When an MPTCP connection falls back to TCP after having been shut down,
the data that is still in the write queue of the MPTCP socket is lost:
a FIN is sent at fallback time, and this data cannot be sent after it.
This can happen with TCP Fast Open (TFO), when a server writes data and
shuts the connection down before the third ACK, and this ACK has no
MPTCP options.

When the MPTCP socket has been shut down, mptcp_try_fallback() also
shuts the subflow down: if the DATA_FIN had already been sent, nothing
would send a FIN on this subflow otherwise. The commit introducing this
only considered the case where all the data had already been pushed to
the subflow.

The fix used here is to only shut the subflow down at fallback time if
no new data is pending, i.e. if all the data before the DATA_FIN has
already been sent. Otherwise, mptcp_check_send_data_fin() will do it
once this data has been pushed, e.g. by the previous commit. Pending
data that has been reinjected, e.g. after the failure of another
subflow, is not new: it is already in this subflow.

This issue has been found by an AI code review agent, while reviewing
the code of the previous commit, and confirmed with a new Packetdrill
test, where the server writes data and shuts the connection down before
the third ACK, from which the MPTCP options are removed. Without this
patch, a FIN was sent right after this ACK, and the data was never
sent:

  inbound injected packet:  0.240127 . 501:501(0) ack 4103187975 win 450
  outbound sniffed packet:  0.240207 F. 4103187975:4103187975(0) ack 501 win 1050
  outbound sniffed packet:  1.347800 F. 4103187975:4103187975(0) ack 501 win 1050
  outbound sniffed packet:  2.499829 F. 4103187975:4103187975(0) ack 501 win 1050
  outbound sniffed packet:  4.739843 F. 4103187975:4103187975(0) ack 501 win 1050
  server-tfo-fallback-shutdown-before-3rd-ack.pkt:27: error handling packet: Timed out waiting for packet

Fixes: d51991e2e314 ("mptcp: fix shutdown vs fallback race")
Cc: stable@vger.kernel.org
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
---
 net/mptcp/protocol.h | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/net/mptcp/protocol.h b/net/mptcp/protocol.h
index 011e73d04ee6..7d226ee38315 100644
--- a/net/mptcp/protocol.h
+++ b/net/mptcp/protocol.h
@@ -1333,7 +1333,11 @@ static inline bool mptcp_try_fallback(struct sock *ssk, int fb_mib)
 	msk = mptcp_sk(sk);
 	if (!__mptcp_try_fallback(msk, fb_mib))
 		return false;
-	if (READ_ONCE(msk->snd_data_fin_enable) && !(ssk->sk_shutdown & SEND_SHUTDOWN)) {
+
+	/* no FIN before new data: see mptcp_check_send_data_fin() */
+	if (READ_ONCE(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 = ssk->sk_allocation;
 
 		/* we are in a atomic (BH) scope, override ssk default for data

-- 
2.55.0
Technical Details
Message-ID: <20261116-net-mptcp-misc-fixes-7-4-rc4-v1-6-bf7656de653e@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364754-linux-kernel-netdev=dewy.ru
References: <20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-364754-linux-kernel-netdev=dewy.ru
From: matttbe@kernel.org ("Matthieu Baerts (NGI0)")
Newsgroups: linux.kernel.netdev
Subject: [PATCH net 6/7] mptcp: don't send a FIN before the pending data on
 fallback
Date: Mon, 16 Nov 2026 23:06:13 +0100
Organization: Usenet Network
Message-ID: <20261116-net-mptcp-misc-fixes-7-4-rc4-v1-6-bf7656de653e@kernel.org>
References: <20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="2178862"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:StXOks9+LHKWx8iPVwQJ9WA2n3A= sha256:Gw74Ku4kXD/2hoe+ZXvboz156xW8GWv9qTYymbSKcKs=
	sha1:iIO7G3IPxxc+I5kTHSOHGCEFJKM= sha256:TqGdSmSp/xY547LvkLpUeNscKvcAefX2DthwQAen/O8=
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 F29A9114D8A; Tue, 17 Nov 2026 01:09:49 +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 x9NhL7f00CeK;
	Tue, 17 Nov 2026 01:09:39 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=104.64.211.4; helo=sin.lore.kernel.org; envelope-from=netdev+bounces-364754-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 sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4])
	by mail.dewy.ru (Postfix) with ESMTPS id 28978114D78; Tue, 17 Nov 2026 01:09:31 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sin.lore.kernel.org (Postfix) with ESMTP id 59257270F0; Mon, 16 Nov 2026 22:09:28 +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=1794866945;
	b=NqpPyNgxpyShdNzA+95aY/en47nOe6RiFhx59Cw8iCl9kepkyqNTE9uSnP0pw4SA/hg5
	 i5GllCyXbgDRK6ataKTnQErFQDTbKpzOqy5GEqj3z7KZ5VcljFal9/4MTYc0r9FTAV47r
	 N3vjDRTTMtNQLCg/F4WaOoVwqJJhUIsgfnQUvtq5IgdiE6pcIhQ15vDTXt2uJVL4/7+Fw
	 QKXRW4poGJ7szIWZ5FwawJKluf29x1/KqlhgIVDNEWBkOLBVlF8UmAku5QhLoWn715akV
	 P3tCR3xN2fXzYCRQPWaj51mfrOTWNd/MaHKVdZvtKF2qC2iJzEUjjFCy7XbjSP/0eeA==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794866945;
	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=7mgC9jL8NBJ5pYS7EFVo2spVfEdDqKdaGi7rc+pAARY=;
	b=YsNRwKNY/TChUBF4fc4dnjfQejzbBLWpOvBebSnHdI63UyFZTM3ild/clJYtAIZZ72q6
	 3oscl0mYUwNkOty6PpI08JtFPE341kc8HDZgM4hMJG4XUP8Pb4Uk1yqvQqKTXPc2NnheK
	 mgVHI/HUxAGJzCk5TADW4W2Ve5eP0JpWcaPs256Pye+xVsW/nWL3BaaP1rExcouacJ+L1
	 cJAB4v3J9U8RF3I79agQegvo6arz1FIXLVByH8FOZBd1QD0iocaBt5AD97Yl1BnDrwuGH
	 RwKFT3kv9X4tOBqrTt6SppblcRYD5iE49o8lROA1fNECCLLbzRfqaOUf16AwT5ZMrMA==
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=hetkCGdD;
	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 F113D606A880;
	Mon, 16 Nov 2026 22:09:04 +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=hetkCGdD
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=1794866944;
	b=4zOvreMmBvfFUuH/YWIlJkDbkixZH4LoMjB3IMTr2Wv4FzVh9JEr0T3OtwX0Ae+649/A
	 M6HCBo7hmDAGEb5dVgPk/N8U6z4zSW50SgBh5Er97XwaUNaO39KtILIJZA7A+k2jIeF98
	 63dF1KbYR8BW1pRzMGO5M819SXW5/qDT6r9pVTryDCALqD7ltp3xFYHAWRU8UtHZJM8Y/
	 7JURQS6rG+68Rq4bmiMyC6acBL+pLE4d38AjqLz+IxnA13+OuB6PlT9eUdMys9XXPRkkF
	 3KpaiglcDO9lj9ZIqqw4H79cB3hWT+V1ir61e8C1KASjEUOpCQDuL8ywYW0F9MF2uYQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1794866944;
	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=7mgC9jL8NBJ5pYS7EFVo2spVfEdDqKdaGi7rc+pAARY=;
	b=VZzdT1ToLGI25HhxhNQ5pkR7na1oPdT6iC/30dfWJFHDS5uMtuQslU40qpuSlQRLW6vd
	 7TyqEgQWxKNfFWoY01aCqQFTTk64WxI5Y9ZtNgH9AZczf+RKuhJ4rC47QTEFc8tfit97n
	 GpBYhcppM3yrBvSfLaeCX55u9DmGLd2RrBliNGt1LqJU0gJe0uahCLZjKgJiedId3gxch
	 02VeU7ZfSHpuh20NTZrDyzclQOEHDmPEpEDaUGkCnXr+fJsGL5alhQJz0jQOhLFJBJ5wJ
	 BLcUpc1wbPMt7b1o+6uKefzz8NJbxVmjOHGfhA/YIPx986/l0kCl+vbIZ+Xpgac60Lw==
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=hetkCGdD;
	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 1DF6A606A8B9;
	Mon, 16 Nov 2026 22:09:04 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A74BB1F000C4;
	Mon, 16 Nov 2026 22:09:01 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1794866944;
	bh=7mgC9jL8NBJ5pYS7EFVo2spVfEdDqKdaGi7rc+pAARY=;
	h=From:Date:Subject:References:In-Reply-To:To:Cc;
	b=hetkCGdDXEkm2883ua7V0ixFQK5QSPIpIaWy78Hd4Iwo4hmZDI2Yoloe5w/YmIqVf
	 XudrZ0hzES6OovQtMHnR9psf+FQ4VmEcUuTT4kIC50ZOw9xyzhGD3OP8xFxYsKClGC
	 Qz9blZXLb3/YEk0lCBL6Hgln6WNh2Ht/j0zU9QsqXHaJ0Pi2t+muHZXwidOqJhEwUP
	 +Y5WANWD9vvclNWiNdgabAGpmYozJYPT+AXeryQ7528KsP2um0jSFpKuf9oXG4mY6D
	 VCAzzm7+c9qlVcHN0AVBuqCGPYRB8/HYWqLbF3eAevaV9j1EkiaHLl5/hf7CEsaPnp
	 Ns37YVyfZ7XYA==
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: <20261116-net-mptcp-misc-fixes-7-4-rc4-v1-0-bf7656de653e@kernel.org>
X-Cc: netdev@vger.kernel.org, mptcp@lists.linux.dev, 
 linux-kernel@vger.kernel.org, "Matthieu Baerts (NGI0)" <matttbe@kernel.org>, 
 stable@vger.kernel.org
X-Mailer: b4 0.17-dev
X-Developer-Signature: v=1; a=openpgp-sha256; l=2987; i=matttbe@kernel.org;
 h=from:subject:message-id; bh=yQZm9eVkTr9yeWS98qWO8sSUzC9QPTMsOrDIzUhNZrk=;
 b=owGbwMvMwCVWo/Th0Gd3rumMp9WSGLJ+171corI61OYN99UWA846j3qGcw+zHISrOBZO+BTaw
 PDA/7hnRykLgxgXg6yYIot0W2T+zOdVvCVefhYwc1iZQIYwcHEKwERmVjEy3FuZdWlJ6b6dOWfO
 zFxw9N+CE0X2Kq90ojoqpu7Mio92MmH4n81eNunyehVJy7fCVYcfxLoyicbxb5YvDvPfkpoU8iO
 VCQA=
X-Developer-Key: i=matttbe@kernel.org; a=openpgp;
 fpr=E8CB85F76877057A6E27F77AF6B7824F4269A073