]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
mptcp: decouple mptcp fastclose from tcp close
authorPaolo Abeni <pabeni@redhat.com>
Tue, 25 Nov 2025 15:54:29 +0000 (10:54 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 6 Dec 2025 21:12:40 +0000 (06:12 +0900)
[ Upstream commit fff0c87996672816a84c3386797a5e69751c5888 ]

With the current fastclose implementation, the mptcp_do_fastclose()
helper is in charge of two distinct actions: send the fastclose reset
and cleanup the subflows.

Formally decouple the two steps, ensuring that mptcp explicitly closes
all the subflows after the mentioned helper.

This will make the upcoming fix simpler, and allows dropping the 2nd
argument from mptcp_destroy_common(). The Fixes tag is then the same as
in the next commit to help with the backports.

Fixes: d21f83485518 ("mptcp: use fastclose on more edge scenarios")
Cc: stable@vger.kernel.org
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Geliang Tang <geliang@kernel.org>
Reviewed-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Signed-off-by: Matthieu Baerts (NGI0) <matttbe@kernel.org>
Link: https://patch.msgid.link/20251118-net-mptcp-misc-fixes-6-18-rc6-v1-5-806d3781c95f@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
[ Adjust context ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/mptcp/protocol.c
net/mptcp/protocol.h

index 289047f421788d0210458af128c53290f90053e2..c4858776e2b8552efefecc1be0639034758f2d5b 100644 (file)
@@ -2826,8 +2826,12 @@ static void mptcp_worker(struct work_struct *work)
                __mptcp_close_subflow(sk);
 
        if (mptcp_close_tout_expired(sk)) {
+               struct mptcp_subflow_context *subflow, *tmp;
+
                inet_sk_state_store(sk, TCP_CLOSE);
                mptcp_do_fastclose(sk);
+               mptcp_for_each_subflow_safe(msk, subflow, tmp)
+                       __mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0);
                mptcp_close_wake_up(sk);
        }
 
@@ -3233,7 +3237,8 @@ static int mptcp_disconnect(struct sock *sk, int flags)
        /* msk->subflow is still intact, the following will not free the first
         * subflow
         */
-       mptcp_destroy_common(msk, MPTCP_CF_FASTCLOSE);
+       mptcp_do_fastclose(sk);
+       mptcp_destroy_common(msk);
        msk->last_snd = NULL;
 
        /* The first subflow is already in TCP_CLOSE status, the following
@@ -3456,7 +3461,7 @@ out:
        return newsk;
 }
 
-void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags)
+void mptcp_destroy_common(struct mptcp_sock *msk)
 {
        struct mptcp_subflow_context *subflow, *tmp;
        struct sock *sk = (struct sock *)msk;
@@ -3465,7 +3470,7 @@ void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags)
 
        /* join list will be eventually flushed (with rst) at sock lock release time */
        mptcp_for_each_subflow_safe(msk, subflow, tmp)
-               __mptcp_close_ssk(sk, mptcp_subflow_tcp_sock(subflow), subflow, flags);
+               __mptcp_close_ssk(sk, mptcp_subflow_tcp_sock(subflow), subflow, 0);
 
        /* move to sk_receive_queue, sk_stream_kill_queues will purge it */
        mptcp_data_lock(sk);
@@ -3492,7 +3497,7 @@ static void mptcp_destroy(struct sock *sk)
 
        /* allow the following to close even the initial subflow */
        msk->free_first = 1;
-       mptcp_destroy_common(msk, 0);
+       mptcp_destroy_common(msk);
        sk_sockets_allocated_dec(sk);
 }
 
index c13bfb821b0a0b4976927ad4b81fac7cc5f198ae..375633719d239c0a43c6e7dc6613edd0669cea02 100644 (file)
@@ -762,7 +762,7 @@ static inline void mptcp_write_space(struct sock *sk)
        }
 }
 
-void mptcp_destroy_common(struct mptcp_sock *msk, unsigned int flags);
+void mptcp_destroy_common(struct mptcp_sock *msk);
 
 #define MPTCP_TOKEN_MAX_RETRIES        4