This is a note to let you know that I've just added the patch titled mptcp: do not wait for bare sockets' timeout to the 6.1-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: mptcp-do-not-wait-for-bare-sockets-timeout.patch and it can be found in the queue-6.1 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From d4e85922e3e7ef2071f91f65e61629b60f3a9cf4 Mon Sep 17 00:00:00 2001 From: Paolo Abeni <pabeni@xxxxxxxxxx> Date: Tue, 7 Feb 2023 14:04:13 +0100 Subject: mptcp: do not wait for bare sockets' timeout From: Paolo Abeni <pabeni@xxxxxxxxxx> commit d4e85922e3e7ef2071f91f65e61629b60f3a9cf4 upstream. If the peer closes all the existing subflows for a given mptcp socket and later the application closes it, the current implementation let it survive until the timewait timeout expires. While the above is allowed by the protocol specification it consumes resources for almost no reason and additionally causes sporadic self-tests failures. Let's move the mptcp socket to the TCP_CLOSE state when there are no alive subflows at close time, so that the allocated resources will be freed immediately. Fixes: e16163b6e2b7 ("mptcp: refactor shutdown and close") Cc: stable@xxxxxxxxxxxxxxx Signed-off-by: Paolo Abeni <pabeni@xxxxxxxxxx> Reviewed-by: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx> Signed-off-by: Matthieu Baerts <matthieu.baerts@xxxxxxxxxxxx> Signed-off-by: David S. Miller <davem@xxxxxxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- net/mptcp/protocol.c | 9 +++++++++ 1 file changed, 9 insertions(+) --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2908,6 +2908,7 @@ bool __mptcp_close(struct sock *sk, long struct mptcp_subflow_context *subflow; struct mptcp_sock *msk = mptcp_sk(sk); bool do_cancel_work = false; + int subflows_alive = 0; sk->sk_shutdown = SHUTDOWN_MASK; @@ -2933,6 +2934,8 @@ cleanup: struct sock *ssk = mptcp_subflow_tcp_sock(subflow); bool slow = lock_sock_fast_nested(ssk); + subflows_alive += ssk->sk_state != TCP_CLOSE; + /* since the close timeout takes precedence on the fail one, * cancel the latter */ @@ -2948,6 +2951,12 @@ cleanup: } sock_orphan(sk); + /* 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) + inet_sk_state_store(sk, TCP_CLOSE); + sock_hold(sk); pr_debug("msk=%p state=%d", sk, sk->sk_state); if (mptcp_sk(sk)->token) Patches currently in stable-queue which might be from pabeni@xxxxxxxxxx are queue-6.1/selftests-forwarding-lib-quote-the-sysctl-values.patch queue-6.1/mptcp-be-careful-on-subflow-status-propagation-on-errors.patch queue-6.1/selftests-mptcp-allow-more-slack-for-slow-test-case.patch queue-6.1/net-mscc-ocelot-fix-vcap-filters-not-matching-on-mac.patch queue-6.1/mptcp-do-not-wait-for-bare-sockets-timeout.patch queue-6.1/net-mscc-ocelot-fix-all-ipv6-getting-trapped-to-cpu-.patch queue-6.1/hv_netvsc-allocate-memory-in-netvsc_dma_map-with-gfp_atomic.patch queue-6.1/rds-rds_rm_zerocopy_callback-use-list_first_entry.patch queue-6.1/net-dsa-mt7530-don-t-change-pvc_eg_tag-when-cpu-port.patch