All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mat Martineau <martineau@kernel.org>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>
Cc: MPTCP Linux <mptcp@lists.linux.dev>
Subject: Re: [PATCH mptcp-net v3 03/50] mptcp: count orphans as TCP does
Date: Tue, 24 Nov 2026 17:21:25 -0800 (PST)	[thread overview]
Message-ID: <3c2617a1-5fa9-eb64-65f1-4be239d29c7e@kernel.org> (raw)
In-Reply-To: <20261124-mptcp-cmason-fixes-v3-3-416c0920c73f@kernel.org>

On Tue, 24 Nov 2026, Matthieu Baerts (NGI0) wrote:

> 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) <matttbe@kernel.org>

Reviewed-by: Mat Martineau <martineau@kernel.org>

> ---
> 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 sock *ssk)
> 	return ret;
> }
>
> +/* 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);
> 	}
>
> 	return false;
> @@ -3547,6 +3557,9 @@ static void __mptcp_destroy_sock(struct sock *sk)
> 	sk_stream_kill_queues(sk);
> 	xfrm_sk_free_policy(sk);
>
> +	if (test_and_clear_bit(MPTCP_ORPHAN_COUNTED, &msk->flags))
> +		tcp_orphan_count_dec();
> +
> 	sock_put(sk);
> }
>
> @@ -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 == 0)
> +	if (subflows_alive == 0) {
> 		mptcp_set_state(sk, TCP_CLOSE);
> +	} else if (sk->sk_state != 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);
> +	}
>
> 	sock_hold(sk);
> 	pr_debug("msk=%p state=%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
>
> /* MPTCP socket release cb flags */
> #define MPTCP_PUSH_PENDING	1
>
> -- 
> 2.55.0
>
>
>

  reply	other threads:[~2026-11-25  1:21 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 21:59 [PATCH mptcp-net v3 00/50] mptcp: misc fixes Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 01/50] mptcp: keep an orphan while it can send its data Matthieu Baerts (NGI0)
2026-11-25  1:16   ` Mat Martineau
2026-11-25  1:17     ` Mat Martineau
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 02/50] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
2026-11-25  1:19   ` Mat Martineau
2026-11-24 21:59 ` [PATCH mptcp-net v3 03/50] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
2026-11-25  1:21   ` Mat Martineau [this message]
2026-11-24 21:59 ` [PATCH mptcp-net v3 04/50] mptcp: return EOF after a DATA_FIN, " Matthieu Baerts (NGI0)
2026-11-26  1:57   ` Mat Martineau
2026-11-26  2:59     ` Geliang Tang
2026-11-26  8:06       ` Matthieu Baerts
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 05/50] mptcp: let TCP send orphan data after fallback Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 06/50] mptcp: reset the subflow on abort " Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 07/50] mptcp: wake up blocked senders when no sf left Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 08/50] mptcp: set SEND_SHUTDOWN on close by an sf error Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 09/50] mptcp: start close timeout on initial sf shutdown Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 10/50] mptcp: process a DATA_FIN received with old data Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 11/50] mptcp: no sf left: process pending MP_FASTCLOSE Matthieu Baerts (NGI0)
2026-11-27  1:12   ` Geliang Tang
2026-11-27 18:57     ` Matthieu Baerts
2026-12-01  8:59       ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 12/50] mptcp: no sf left: process pending DATA_FIN Matthieu Baerts (NGI0)
2026-11-24 22:33   ` sashiko-bot
2026-11-26 16:50     ` Matthieu Baerts
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 13/50] mptcp: process pending close events at accept() Matthieu Baerts (NGI0)
2026-11-27  1:06   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 14/50] mptcp: report errors received before accept() Matthieu Baerts (NGI0)
2026-11-27  1:02   ` Geliang Tang
2026-11-27  1:04   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 15/50] mptcp: clear sk_err on connect(), as TCP does Matthieu Baerts (NGI0)
2026-11-26  6:40   ` Geliang Tang
2026-11-26  8:15     ` Matthieu Baerts
2026-11-24 21:59 ` [PATCH mptcp-net v3 16/50] mptcp: clear DEFER_CONNECT on disconnect Matthieu Baerts (NGI0)
2026-11-26  6:41   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 17/50] mptcp: report sf aborts during deferred connect Matthieu Baerts (NGI0)
2026-11-27  1:00   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 18/50] mptcp: no fastclose reset from SYN_SENT subflows Matthieu Baerts (NGI0)
2026-11-26  7:04   ` Geliang Tang
2026-11-26  7:35     ` Matthieu Baerts
2026-11-26  8:02       ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 19/50] mptcp: fastopen: keep listeners and connections Matthieu Baerts (NGI0)
2026-11-26  8:20   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 20/50] mptcp: don't inherit fastopening from a listener Matthieu Baerts (NGI0)
2026-11-26  7:07   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 21/50] mptcp: drop non-MP_JOIN cookie ACKs on PM listeners Matthieu Baerts (NGI0)
2026-11-27  1:17   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 22/50] mptcp: close a subflow reset for a bad mapping Matthieu Baerts (NGI0)
2026-11-27  1:17   ` Geliang Tang
2026-11-24 21:59 ` [PATCH mptcp-net v3 23/50] mptcp: pm: kernel: count endpoint listeners as sockets in use Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 24/50] mptcp: count a listener once when listen() is called again Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 25/50] mptcp: send the infinite map in a single segment Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 26/50] mptcp: keep room for infinite map after fallback Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 27/50] mptcp: do not fallback while old data is in flight Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 28/50] mptcp: stop resending data to a peer that fell back Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 29/50] mptcp: don't resend data acked without MPTCP opts Matthieu Baerts (NGI0)
2026-11-24 22:36   ` sashiko-bot
2026-11-26 16:53     ` Matthieu Baerts
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 30/50] mptcp: pm: kernel: don't count signal+subflow ID 0 endp Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 31/50] selftests: mptcp: join: check re-adding " Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 32/50] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 33/50] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
2026-11-26  2:20   ` Mat Martineau
2026-11-26 14:32     ` Matthieu Baerts
2026-11-24 21:59 ` [PATCH mptcp-net v3 34/50] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)
2026-11-26  2:43   ` Mat Martineau
2026-11-26 14:41     ` Matthieu Baerts
2026-11-24 21:59 ` [PATCH mptcp-net v3 35/50] mptcp: don't charge a subflow twice when it joins during accept() Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 36/50] mptcp: continue the last mapping after a fallback Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 37/50] mptcp: keep the first byte after a simult connect Matthieu Baerts (NGI0)
2026-11-24 22:45   ` sashiko-bot
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 38/50] mptcp: move to ESTABLISHED " Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 39/50] mptcp: fix MSG_PEEK after a partly peeked skb Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 40/50] mptcp: send the DATA_ACK after moving the backlog Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 21:59 ` [PATCH mptcp-net v3 41/50] selftests: mptcp: join: infinite map: no spurious rtx Matthieu Baerts (NGI0)
2026-11-24 21:59 ` [PATCH mptcp-net v3 42/50] selftests: mptcp: connect: trunc: wait for acks Matthieu Baerts (NGI0)
2026-11-24 22:00 ` [PATCH mptcp-net v3 43/50] mptcp: order write_seq and DATA_FIN flag Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 22:00 ` [PATCH mptcp-net v3 44/50] mptcp: order write_seq and DATA_FIN flag for fallback Matthieu Baerts (NGI0)
2026-11-24 22:00 ` [PATCH mptcp-net v3 45/50] Squash to "bpf: Add mptcp packet scheduler struct_ops" Matthieu Baerts (NGI0)
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 22:00 ` [PATCH mptcp-net v3 46/50] Squash to "bpf: Export mptcp packet scheduler helpers" Matthieu Baerts (NGI0)
2026-11-24 22:45   ` sashiko-bot
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 22:00 ` [PATCH mptcp-next mptcp-net v3 47/50] mptcp: push pending data after a fallback on reception Matthieu Baerts (NGI0)
2026-11-24 22:00 ` [PATCH mptcp-next mptcp-net v3 48/50] mptcp: report errors as TCP does when closing Matthieu Baerts (NGI0)
2026-11-24 22:52   ` sashiko-bot
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-24 22:00 ` [PATCH mptcp-next mptcp-net v3 49/50] mptcp: trace: name all the mapping statuses Matthieu Baerts (NGI0)
2026-11-24 22:00 ` [PATCH RFC mptcp-next mptcp-net v3 50/50] mptcp: reset when the DSS disappears after a DATA_ACK Matthieu Baerts (NGI0)
2026-11-24 22:36   ` sashiko-bot
2026-11-26 23:29   ` netdev-bot+sashiko
2026-11-25  0:39 ` [PATCH mptcp-net v3 00/50] mptcp: misc fixes MPTCP CI
2026-11-26 16:54 ` Matthieu Baerts

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3c2617a1-5fa9-eb64-65f1-4be239d29c7e@kernel.org \
    --to=martineau@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.