Netdev List
 help / color / mirror / Atom feed
From: netdev-bot+sashiko@kernel.org
To: matttbe@kernel.org
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
Subject: Re: [PATCH net 4/9] mptcp: count orphans as TCP does
Date: Thu, 03 Dec 2026 21:51:51 +0000	[thread overview]
Message-ID: <179633471192.3146.8810228234232955911@kernel.org> (raw)
In-Reply-To: <20261202-net-mptcp-misc-fixes-7-4-rc7-v1-4-9f03efcb1a17@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.

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

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

- [Medium] For fallback MPTCP connections, the new OOM abort at close()
  does not reset the connection.
- [Low] The MIB counter and the RST reason disagree for the new MPTCP OOM
  abort.

--

mptcp: count orphans as TCP does

This commit adds MPTCP sockets orphaned by close() to tcp_orphan_count.
That way tcp_max_orphans and the TCP memory limits apply to them. If
tcp_check_oom() reports too many orphans or too much memory, the orphan
is reset at close() or when its close timeout expires, and the abort is
counted in TCPAbortOnMemory.

> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 96b3baef341f3..fc8aad7e2fde9 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -2840,6 +2840,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;
> +}

[Severity: Low]
Should the reset sent for this abort use SK_RST_REASON_TCP_ABORT_ON_MEMORY?

Both new abort paths end up in mptcp_do_fastclose(). One is a direct call
from __mptcp_close(). The other is from mptcp_worker() once
mptcp_orphan_keep() returns false. mptcp_do_fastclose() hard-codes the
close reason:

net/mptcp/protocol.c:mptcp_do_fastclose() {
    ...
		tcp_send_active_reset(ssk, SK_RST_REASON_TCP_ABORT_ON_CLOSE);
    ...
}

include/net/rstreason.h pairs SK_RST_REASON_TCP_ABORT_ON_MEMORY with
LINUX_MIB_TCPABORTONMEMORY, and __tcp_close() uses the two together:

	if (tcp_check_oom(sk, 0)) {
		tcp_set_state(sk, TCP_CLOSE);
		tcp_send_active_reset(sk, SK_RST_REASON_TCP_ABORT_ON_MEMORY);
		__NET_INC_STATS(sock_net(sk), LINUX_MIB_TCPABORTONMEMORY);

With this patch, a non-fallback MPTCP OOM abort is counted in
TCPAbortOnMemory, but the tcp_send_reset tracepoint reports
ABORT_ON_CLOSE for it.

The hard-coded reason was already there, but this patch is the first to
use it for memory aborts.

[ ... ]

> @@ -3579,8 +3592,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);
> +	}

[Severity: Medium]
Does this branch reset the connection when the msk has fallen back to
TCP?

On fallback sockets, mptcp_do_fastclose() sets TCP_CLOSE and returns
before it sends any RST:

	/* Explicitly send the fastclose reset as need */
	if (__mptcp_check_fallback(msk))
		return;

So subflow->send_fastclose stays 0. Since the msk is now TCP_CLOSE, the
destroy path runs right away:

__mptcp_close()
  __mptcp_destroy_sock()
    mptcp_destroy()                  /* sets free_first */
      mptcp_destroy_common()
        __mptcp_clear_xmit(sk)       /* drops unsent msk-level data */
        __mptcp_close_ssk(sk, ssk, subflow, 0)
          __tcp_close(ssk, 0)        /* dispose_it is true */

If close() ran with data still pending at the msk level,
mptcp_check_send_data_fin() returned early. The subflow is therefore
still ESTABLISHED, and __tcp_close() sends a normal FIN on it. A RST
follows only if TCP's own tcp_check_oom(ssk, 0) in __tcp_close() also
fires.

In the orphan-limit case, both checks read the same cached orphan count.
TCP then resets as well, and TCPAbortOnMemory is incremented a second
time for the same connection.

In the memory case, tcp_out_of_memory() checks the subflow's
sk_wmem_queued against SOCK_MIN_SNDBUF. That value can be small while the
msk's queue is large, for example when msk-to-subflow pushes fail under
tcp_mem[2] pressure. Can the peer then get a clean FIN after
__mptcp_clear_xmit() has silently dropped the rest of the stream?

The close timeout path in mptcp_worker() handles the same fallback socket
differently. There, free_first is still 0, so __mptcp_close_ssk() goes
through __mptcp_subflow_disconnect() and tcp_disconnect(), which sends a
RST.

The commit message says:

    reset an orphan when there are too many orphans, or when TCP uses
    too much memory: at close(), and when its close timeout expires

Should the fallback case get an explicit reset here, with
TCPAbortOnMemory counted only once? Later patches in this series don't
seem to change mptcp_do_fastclose(), mptcp_orphan_oom() or this branch of
__mptcp_close().

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261202-net-mptcp-misc-fixes-7-4-rc7-v1-0-9f03efcb1a17%40kernel.org

  reply	other threads:[~2026-12-03 21:51 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 21:29 [PATCH net 0/9] mptcp: misc fixes for v7.4-rc7 Matthieu Baerts (NGI0)
2026-12-02 21:29 ` [PATCH net 1/9] mptcp: pm: kernel: c-flag: keep local_addr_used in sync Matthieu Baerts (NGI0)
2026-12-02 21:29 ` [PATCH net 2/9] mptcp: keep an orphan while it can send its data Matthieu Baerts (NGI0)
2026-12-03 21:51   ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 3/9] mptcp: limit an orphan probing a zero window Matthieu Baerts (NGI0)
2026-12-03 21:51   ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 4/9] mptcp: count orphans as TCP does Matthieu Baerts (NGI0)
2026-12-03 21:51   ` netdev-bot+sashiko [this message]
2026-12-02 21:29 ` [PATCH net 5/9] mptcp: return EOF after a DATA_FIN, " Matthieu Baerts (NGI0)
2026-12-03 21:51   ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 6/9] mptcp: wake up blocked senders when no sf left Matthieu Baerts (NGI0)
2026-12-03 21:51   ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 7/9] mptcp: reclaim forward memory after coalescing skbs Matthieu Baerts (NGI0)
2026-12-03 21:51   ` netdev-bot+sashiko
2026-12-02 21:29 ` [PATCH net 8/9] mptcp: don't charge a shared page twice at accept() Matthieu Baerts (NGI0)
2026-12-02 21:29 ` [PATCH net 9/9] mptcp: don't charge the backlog " Matthieu Baerts (NGI0)

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=179633471192.3146.8810228234232955911@kernel.org \
    --to=netdev-bot+sashiko@kernel.org \
    --cc=davem@davemloft.net \
    --cc=dcaratti@redhat.com \
    --cc=edumazet@kernel.org \
    --cc=geliang@kernel.org \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=martineau@kernel.org \
    --cc=mason@kernel.org \
    --cc=matttbe@kernel.org \
    --cc=mptcp@lists.linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=willemb@google.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox