🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #26587

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

#26587
From: netdev-bot+sashiko
Date: Thu, 03 Dec 2026 21:51
234 lines
16478 bytes
Thank you for your contribution! Sashiko AI review found 4 potential
issue(s) to consider.

Critical: 0 · High: 1 · Medium: 1 · Low: 2

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [High] The fix does not cover MPTCP connections that fell back to TCP
  (plain TCP peer), so they still get the reset this commit claims to…
- [Medium] Unbounded orphan lifetime controlled by the remote peer
  (baseline decision: resolved later in the series).
- [Low] The new timer restart in mptcp_check_send_data_fin() can
  overwrite a deliberately backdated close timeout.
- [Low] mptcp_orphan_keep() evaluates `tcp_jiffies32 -
  READ_ONCE(tcp_sk(ssk)->rcv_tstamp) < 2 * TCP_RTO_MAX` under the msk…

--

mptcp: keep an orphan while it can send its data

This commit keeps an orphaned MPTCP socket alive past its close timeout
while data is still pending and an active subflow recently received an
ACK. In that case mptcp_worker() re-arms the timeout and pushes the
pending data again, and the close timeout is also restarted when the
DATA_FIN is sent for an orphan.

Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/647

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index d6a07fa4b4e4c..82a0cbe38192e 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;

[Severity: High]
Does this cover connections that fell back to plain TCP? The
snd_nxt == write_seq check only counts data still queued at the MPTCP
level. It does not count data that is already in the subflow's TCP
write queue but has not been sent.

On fallback, mptcp_check_allowed_size() doesn't apply the peer window:

net/mptcp/protocol.c:mptcp_check_allowed_size() {
    ...
	if (__mptcp_check_fallback(msk))
		return avail_size;
    ...
}

So the whole tail can move into msk->first as soon as it fits in the
subflow sndbuf, even while the peer window is closed.

__mptcp_push_pending() then calls mptcp_check_send_data_fin(). That
sets snd_nxt = write_seq, restarts the close timeout (the new code
further below) and calls mptcp_subflow_shutdown(). On fallback, that
queues the TCP FIN behind the undelivered data and simulates the
DATA_FIN ack:

net/mptcp/protocol.c:mptcp_subflow_shutdown() {
    ...
		if (__mptcp_check_fallback(mptcp_sk(sk))) {
			pr_debug("Fallback\n");
			ssk->sk_shutdown |= how;
			tcp_shutdown(ssk, how);
			...
			WRITE_ONCE(mptcp_sk(sk)->snd_una, mptcp_sk(sk)->snd_nxt);
    ...
}

>From then on, mptcp_orphan_keep() can never return true. When the
restarted TCP_TIMEWAIT_LEN expires:

mptcp_worker()
  mptcp_do_fastclose()      /* sets fastclosing, returns early on fallback */
  __mptcp_close_ssk(sk, ssk, subflow, 0)
    __mptcp_subflow_disconnect(ssk, subflow, fastclosing)
      tcp_disconnect(ssk, 0)  /* RST, write queue purged */

Take an MPTCP server with a plain TCP client. The server writes data
that fits in the subflow sndbuf, then calls close(), and the client
pauses for more than 60 seconds. Would the client still get ECONNRESET
and lose the tail?

That is the symptom the commit message describes as fixed ("TCP
delivered everything, as MPTCP now does"). The same logic is still
there at the end of the series.

Should the keep check also account for data queued in the subflows on
fallback, or should fallback orphans be left to TCP's orphan handling?

> +
> +	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;

[Severity: Low]
Can this unsigned subtraction underflow? tcp_ack() writes
tp->rcv_tstamp in softirq, under the subflow lock:

	tp->rcv_tstamp = tcp_jiffies32;

This check runs under the msk socket lock only, and the order of the
two loads here is unspecified. Consider this sequence:

- the worker loads tcp_jiffies32 (T)
- jiffies ticks
- another CPU processes an ACK and stores rcv_tstamp = T + 1
- the worker loads rcv_tstamp

The difference is then 0xffffffff, so a subflow that has just received
an ACK is treated as not live. If it is the only active subflow, the
orphan is fastclosed.

Would taking a single tcp_jiffies32 snapshot and using a signed
comparison avoid this? mptcp_close_tout_expired() just above already
uses time_after32().

> +	}
> +
> +	return false;
> +}
> +

[ ... ]

> @@ -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);
> +	}

[Severity: Medium]
With only this patch applied, what limits how long an orphan can be
kept? Each time the close timeout expires, it is re-armed here as long
as these hold:

- snd_nxt != write_seq
- an active subflow got any ACK within 2 * TCP_RTO_MAX

There is no cap, no orphan count check and no memory pressure check.
A peer that advertises a zero window and acks the probes could keep
the msk and its send buffers pinned forever. The commit message notes
that "nothing limits how long the peer can keep its window closed".

The TCP orphan limits in tcp_probe_timer() (tcp_orphan_retries() and
tcp_out_of_resources()) don't apply, because the subflows are not
SOCK_DEAD. __mptcp_close() also doesn't count MPTCP orphans in
tcp_orphan_count.

This seems to be fixed later in the series:

- "mptcp: limit an orphan probing a zero window" adds
  mptcp_subflow_probe_timed_out()
- "mptcp: count orphans as TCP does" adds tcp_orphan_count_inc() and
  mptcp_orphan_oom()

Since this patch has Cc: stable, could it be backported without those
follow-ups?

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

[Severity: Low]
Can this restart overwrite a close timeout that was backdated on
purpose? When the last subflow of an orphan is closed while msk->first
is already in TCP_CLOSE, __mptcp_close_ssk() does:

		if (sock_flag(sk, SOCK_DEAD)) {
			/* let the worker close and destroy the orphan */
			mptcp_set_close_tout(sk, tcp_jiffies32 -
					     (mptcp_close_timeout(sk) + 1));
			mptcp_schedule_work(sk);

There are two ways this can run before mptcp_check_send_data_fin():

- inside mptcp_worker() itself, earlier in the same run, via
  mptcp_pm_worker()->mptcp_pm_rm_addr_recv()->
  mptcp_pm_rm_addr_or_subflow()->mptcp_close_ssk()
- from netlink PM paths such as mptcp_pm_nl_subflow_destroy_doit(),
  before the worker runs

A DATA_FIN may still be pending at that point. For example,
__mptcp_subflow_push_pending() pushed the last data and only scheduled
the worker, and all the data was DATA_ACKed. In that case, the new
mptcp_start_tout_timer() call resets probe_timestamp to now. Then
mptcp_close_tout_expired() is false and the state is not TCP_CLOSE, so
__mptcp_destroy_sock() is skipped.

Would the orphan then stay around for another TCP_TIMEWAIT_LEN with no
usable subflow, instead of being destroyed in this worker run as it
was before? This code is unchanged at the end of the series.

> +
>  	mptcp_for_each_subflow(msk, subflow) {
>  		struct sock *tcp_sk = mptcp_subflow_tcp_sock(subflow);
>

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17%40kernel.org
Technical Details
Message-ID: <179633470902.3146.5343522154219240904@kernel.org>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376883-linux-kernel-netdev=dewy.ru
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-376883-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net 2/9] mptcp: keep an orphan while it can send its data
Date: Thu, 03 Dec 2026 21:51:49 +0000
Organization: Usenet Network
Message-ID: <179633470902.3146.5343522154219240904@kernel.org>
References: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2605938"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:Md6BJSCYFqhyDG29csJ5X7D60D4= sha256:nDaA4SQhwWB58/ubYfMbtEKFpQYxrF6T0484eziKshY=
	sha1:vwe8ZaHtniHr0PjY5Kt/joAO25o= sha256:E3gmRQkF31/EkZSgOO+IKtaupLVy5bQWSPNRuV1TQnE=
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 89422117A08; Fri,  4 Dec 2026 00:52:10 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.74
X-Spam-Status: No, score=-3.74 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.24, 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 JLqnxs9e2X4w;
	Fri,  4 Dec 2026 00:52:03 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-376883-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74])
	by mail.dewy.ru (Postfix) with ESMTPS id 61031117A3B; Fri,  4 Dec 2026 00:51:55 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by sto.lore.kernel.org (Postfix) with ESMTP id EA36F601AE2; Thu,  3 Dec 2026 21:51:54 +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=1796334711;
	b=vz9xs5UanZQDe4dvHzo5+AkSyEBGi2fI5nfi3/X/0Mnc48m6P1vn9AtoSaS4PZbrgjZx
	 xwhni9LFQzRsERfgd1YK1TuerF/1xA5Aa1n92SDD8dnoun8yFMjKjS61UVY3PC85ZJvMR
	 r7u4SVtRLPjzwXeRi2kBAr4MXpREfQ9RDlVsORfFGuKbpmahgUU9LiQqSQwvGjT5kjDhC
	 PdYwDdqjr8t0imuM8t5kiNejlmUuqwMTck6tfZwNr19MvUT26TPbljN8ry0TUeUk9DvNw
	 6nFCwD1C9p/nJ2SsTFX+JTruseNcXFk26kFQeqWjRnExJKYHJoDFxjwkhNeN6uvUI6g==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796334711;
	h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc:
	 Date:Message-ID:In-Reply-To:References:X-sashiko-severity:
	 Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id:
	 List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner:
	 Precedence:MIME-Version;
	bh=qTqeKyhTuhMnkw5Z6NenzDSpDpylvG533DRYE4IA+Oo=;
	b=wzflYvoWHkPH7FPj5H5UkLV84epm5wG+Oax4wHP63SQcBgXX17M1eFMEtchkPjk+NNvw
	 668P57hDhawDFqY+KRCEePgpBidgB2iZCsfgijHTXxsp2I2qqbWuUUBewgmNtsNplKSyo
	 GUlm0KQ5Qq5O+oBjvVvMfdpzZppCHapaVQVGaIBe+dCJ9qKTmrRDvlhz22eAQQAX641fl
	 GteqE5Jl/I6fl4Vw1kJUB7xdt+JJUicgulZ6TWqFBGn/RnoAcNi/b+0nHFN56w+YyTsvX
	 boLggvny4+F3IFVGHtY7AT2xOVsOf+dxwEIaUCgpdReB6IAlA4M15sAduEoPvnu0scQ==
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=R09QPqsO;
	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 A3DE2606A336;
	Thu,  3 Dec 2026 21:51:51 +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=R09QPqsO
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=1796334710;
	b=zmUZX8/joQt06O+9P86XLy0pjjpGXq8jTRsQJi+VYOjtnVFockM0hW5m4Q1OmApw68CP
	 8CB0K5YGMAKgE2lA1jOiM9bVyu8SnYnpkD//DrnkGHtW/zJlmUR6bLIpuOP1xYrVrXxDb
	 AtPks2L6zotbwh4+xj9FP11oU9MQ75lbZoH1KZsm/vxYDAMuZAox9mk57IqCfcVs5n7GK
	 25zrKXH4Q+UNo++/eA2QHBPxOOrtKbfRvFwXXQzhBXc4gho+Lo6tbMNmvv5xnrLyMjgy2
	 u6mo7ZDDVeibtLmkuWZCGTIajZ3E88HdIQUKhq1YdRUEPUk5zkyPFr199JyNhixQ/Zw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796334710;
	h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID:
	 In-Reply-To:References:X-sashiko-severity:Content-Type:
	 Content-Transfer-Encoding:MIME-Version;
	bh=qTqeKyhTuhMnkw5Z6NenzDSpDpylvG533DRYE4IA+Oo=;
	b=HA6RNjMzu9lZvHJt2wkRwCRWBKVTFM/jG0Sa62toz2JuGibKvmWlweOD/ib5Lt/3beUT
	 THTF6h7faa2K+G3H3kEeJ8MRcztLpMmVy2omdXXAeSBnP93ghktp7pgkbZr5bZZ4uCwRC
	 yx1zHmSf2dZKYGeo8KA0AKDQ6Ro4iZ+1JaNb8O+OjNGhnkclPNBpyG4xY88jVkCWSmimb
	 hVdLFAPnUYKQFLlyDJH4BCYsoz59KVcYgct+NnrtTtBlmP94RI8qWerxB8XWdI45Jexv/
	 3F7EbeVhEUtrF7EvTDysXpTiF4Ys1aATHSXUB2KzeQXyMSGu3zNnFzPV36f7O7bXE3g==
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=R09QPqsO;
	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 C0AC3606A322;
	Thu,  3 Dec 2026 21:51:50 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 810131F000CE;
	Thu,  3 Dec 2026 21:51:49 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796334710;
	bh=qTqeKyhTuhMnkw5Z6NenzDSpDpylvG533DRYE4IA+Oo=;
	h=Subject:From:To:Cc:Date:In-Reply-To:References;
	b=R09QPqsO9K7onZCMXNRLKQiHeuk6zjw2yW2my0qXb9uRyzN6wozV17gd1+/uGYIzm
	 6XLEGHxTsDvb2OJskv7PaSA7vJio/Gp8V5z8oG3t/cwyv2OyB5wNlAGU4+IG4eHeYu
	 BmLZo50xX5x60ek9A2z79iTc/vt2tpIE7C864efFAyw5Z5y5hY/PLv+hE1lnewPzQK
	 G4NJz2kdPN4Qk7A0g010exTk4bpSoQVhn02TkX8W/rbYDR5JWCICbTSEsq2dJe1l9g
	 gyLBYRtNQ3aAx8lz2dKvGc2OBBxLlxf+CJBNfHxEFgmoQO1IJe6411DeoIN5n8yvtG
	 fRjJV69ylBHbA==
X-Cc: martineau@kernel.org, geliang@kernel.org, davem@davemloft.net,
 edumazet@kernel.org, kuba@kernel.org, pabeni@redhat.com, willemb@google.com,
 horms@kernel.org, dcaratti@redhat.com, netdev@vger.kernel.org,
 mptcp@lists.linux.dev, mason@kernel.org, stable@vger.kernel.org
X-In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-2-9f03efcb1a17@kernel.org>
X-sashiko-severity: High
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