MPTCP Linux Development
 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] mptcp: disconnect: reset first subflow's local_id
Date: Fri, 16 Oct 2026 09:47:56 -0700 (PDT)	[thread overview]
Message-ID: <308170eb-b0f2-fff0-0d9a-7610e148fa0c@kernel.org> (raw)
In-Reply-To: <20261015-mptcp-first-disco-id-reset-v1-1-6ae41e8f02c6@kernel.org>

On Thu, 15 Oct 2026, Matthieu Baerts (NGI0) wrote:

> The first subflow can get disconnected for various reasons and
> mptcp_subflow_ctx_reset() will reset most fields and set local_id to -1.
> That's fine until the subflow is reused after a reconnect.
>
> As mentioned by Clashiko [1]: on the retry, local_id is -1, so the
> connect goes through:
>
>  tcp_connect()
>    subflow_rebuild_header()
>      subflow_chk_local_id()
>        mptcp_pm_get_local_id()
>
> mptcp_pm_get_local_id() returns 0 only when the msk local address
> matches the subflow's address. The addresses can change, but even if
> they don't, for an unbound msk, the address is therefore still zero at
> this point. (Note: in MPTCP disconnect selftests, the address is the
> same, and mptcp_pm_get_local_id() will return 0.)
>
> At this stage, the kernel PM might then give the MPC subflow a non-zero
> ID, either from a matching endpoint or by adding an "implicit" endpoint.
> The RFC 8684 says that the first subflow always has the ID 0, and the
> PMs rely on that for special cases. So it is important to reset it to 0.
>
> Note that we need to keep it to -1 in mptcp_subflow_ctx_reset() to avoid
> a double closures in mptcp_close_ssk().
>
> This issue was found by code analysis, and confirmed by looking at the
> ID after a reconnection.
>
> Fixes: a7cfe7766370 ("mptcp: fix data races on local_id")
> Link: https://lore.kernel.org/179198834484.434549.4616694240552704738@kernel.org
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> net/mptcp/protocol.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index 60cbd91be632..4a6f16e0d809 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -3654,6 +3654,7 @@ static int mptcp_disconnect(struct sock *sk, int flags)
> 	 */
> 	mptcp_do_fastclose(sk);
> 	mptcp_destroy_common(msk);
> +	WRITE_ONCE(mptcp_subflow_ctx(msk->first)->local_id, 0);
>
> 	/* The first subflow is already in TCP_CLOSE status, the following
> 	 * can't overlap with a fallback anymore
>
> ---
> base-commit: 6a6728a8e881c12c984d104403ecaa0523d3b7e8
> change-id: 20261015-mptcp-first-disco-id-reset-a0866d67d9a6
>

Fix looks good, thanks Matthieu

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

      parent reply	other threads:[~2026-10-16 16:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-15 13:54 [PATCH mptcp-net] mptcp: disconnect: reset first subflow's local_id Matthieu Baerts (NGI0)
2026-10-15 14:05 ` sashiko-bot
2026-10-15 15:26   ` Matthieu Baerts
2026-10-15 15:28 ` MPTCP CI
2026-10-16 16:47 ` Mat Martineau [this message]

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=308170eb-b0f2-fff0-0d9a-7610e148fa0c@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox