From: Geliang Tang <geliang@kernel.org>
To: "Matthieu Baerts (NGI0)" <matttbe@kernel.org>, mptcp@lists.linux.dev
Subject: Re: [PATCH mptcp-net v2 1/5] mptcp: propagate shutdown to subflows when possible
Date: Sat, 06 Sep 2025 08:45:16 +0800 [thread overview]
Message-ID: <9f2a05ac6034fb33f579302a0ede2ec13eb6c915.camel@kernel.org> (raw)
In-Reply-To: <20250905-sft-mptcp-disc-err-v2-1-dfb3b6b4a877@kernel.org>
On Fri, 2025-09-05 at 20:18 +0200, Matthieu Baerts (NGI0) wrote:
> When the MPTCP DATA FIN have been ACKed, there is no more MPTCP
> related
> metadata to exchange, and all subflows can be safely shutdown.
>
> Before this patch, the subflows were actually terminated at 'close()'
> time. That's certainly fine most of the time, but not when the
> userspace
> 'shutdown()' a connection, without close()ing it. When doing so, the
> subflows were staying in LAST_ACK state on one side -- and
> consequently
> in FIN_WAIT2 on the other side -- until the 'close()' of the MPTCP
> socket.
>
> Now, when the DATA FIN have been ACKed, all subflows are shutdown. A
> consequence of this is that the TCP 'FIN' flag can be set earlier
> now,
> but the end result is the same. This affects the packetdrill tests
> looking at the end of the MPTCP connections, but for a good reason.
>
> Fixes: 3721b9b64676 ("mptcp: Track received DATA_FIN sequence number
> and add related helpers")
> Fixes: 16a9a9da1723 ("mptcp: Add helper to process acks of DATA_FIN")
> Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
> ---
> net/mptcp/protocol.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
> index
> 1c26acf6c4145896ecbb5c7f7004121c66a20649..9feb9f437c2bdfff392249e7ad0
> 0edd09ba67ac3 100644
> --- a/net/mptcp/protocol.c
> +++ b/net/mptcp/protocol.c
> @@ -372,6 +372,20 @@ static void mptcp_close_wake_up(struct sock *sk)
> sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
> }
>
> +static void mptcp_shutdown_subflows(struct mptcp_sock *msk)
> +{
> + struct mptcp_subflow_context *subflow;
> +
> + mptcp_for_each_subflow(msk, subflow) {
> + struct sock *ssk = mptcp_subflow_tcp_sock(subflow);
> + bool slow;
> +
> + slow = lock_sock_fast(ssk);
> + tcp_shutdown(ssk, SEND_SHUTDOWN);
> + unlock_sock_fast(ssk, slow);
> + }
> +}
> +
> /* called under the msk socket lock */
> static bool mptcp_pending_data_fin_ack(struct sock *sk)
> {
> @@ -396,6 +410,7 @@ static void mptcp_check_data_fin_ack(struct sock
> *sk)
> break;
> case TCP_CLOSING:
> case TCP_LAST_ACK:
> + mptcp_shutdown_subflows(msk);
> mptcp_set_state(sk, TCP_CLOSE);
> break;
> }
> @@ -564,6 +579,7 @@ static bool mptcp_check_data_fin(struct sock *sk)
> mptcp_set_state(sk, TCP_CLOSING);
> break;
> case TCP_FIN_WAIT2:
> + mptcp_shutdown_subflows(msk);
I think we should not directly call mptcp_shutdown_subflows() within
mptcp_check_data_fin() and mptcp_check_data_fin_ack(), but should
instead call it after these functions return and the sk state is
TCP_CLOSE. This ensures that the original purpose of these two
functions remains unchanged.
WDYT?
Thanks,
-Geliang
> mptcp_set_state(sk, TCP_CLOSE);
> break;
> default:
next prev parent reply other threads:[~2025-09-06 0:45 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-05 18:18 [PATCH mptcp-net v2 0/5] selftests: mptcp: avoid spurious errors on TCP disconnect Matthieu Baerts (NGI0)
2025-09-05 18:18 ` [PATCH mptcp-net v2 1/5] mptcp: propagate shutdown to subflows when possible Matthieu Baerts (NGI0)
2025-09-06 0:45 ` Geliang Tang [this message]
2025-09-06 13:42 ` Matthieu Baerts
2025-09-10 3:24 ` Geliang Tang
2025-09-10 8:56 ` Matthieu Baerts
2025-09-06 0:47 ` Geliang Tang
2025-09-05 18:18 ` [PATCH mptcp-net v2 2/5] selftests: mptcp: connect: catch IO errors on listen side Matthieu Baerts (NGI0)
2025-09-05 23:49 ` Geliang Tang
2025-09-06 13:54 ` Matthieu Baerts
2025-09-10 2:44 ` Geliang Tang
2025-09-10 8:56 ` Matthieu Baerts
2025-09-05 18:18 ` [PATCH mptcp-net v2 3/5] selftests: mptcp: avoid spurious errors on TCP disconnect Matthieu Baerts (NGI0)
2025-09-05 18:18 ` [PATCH mptcp-net v2 4/5] selftests: mptcp: print trailing bytes with od Matthieu Baerts (NGI0)
2025-09-05 23:42 ` Geliang Tang
2025-09-06 13:56 ` Matthieu Baerts
2025-09-10 3:26 ` Geliang Tang
2025-09-05 18:18 ` [PATCH mptcp-net v2 5/5] selftests: mptcp: connect: print pcap suffix Matthieu Baerts (NGI0)
2025-09-05 23:39 ` Geliang Tang
2025-09-06 13:58 ` Matthieu Baerts
2025-09-10 3:31 ` Geliang Tang
2025-09-05 20:46 ` [PATCH mptcp-net v2 0/5] selftests: mptcp: avoid spurious errors on TCP disconnect MPTCP CI
2025-09-06 14:00 ` 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=9f2a05ac6034fb33f579302a0ede2ec13eb6c915.camel@kernel.org \
--to=geliang@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