[PATCH mptcp-net] Squash-to: "mptcp: fix accept vs worker race"

Paolo Abeni posted 1 patch 1 year, 1 month ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/multipath-tcp/mptcp_net-next tags/patchew/a0b61938d72605d35cd4d988ac533b88f45d7f89.1680810015.git.pabeni@redhat.com
Maintainers: Matthieu Baerts <matthieu.baerts@tessares.net>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
There is a newer version of this series
net/mptcp/protocol.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
[PATCH mptcp-net] Squash-to: "mptcp: fix accept vs worker race"
Posted by Paolo Abeni 1 year, 1 month ago
Avoid the ugly timeout hack, we can rely simple on
the in_accept_queue flag.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/mptcp/protocol.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c
index c131315d833b..045570ebad96 100644
--- a/net/mptcp/protocol.c
+++ b/net/mptcp/protocol.c
@@ -2387,8 +2387,6 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk,
 
 		/* ensure later check in mptcp_worker will dispose the msk */
 		sock_set_flag(sk, SOCK_DEAD);
-		inet_csk(sk)->icsk_mtup.probe_timestamp = tcp_jiffies32 -
-							  TCP_TIMEWAIT_LEN -1;
 	}
 
 	dispose_it = !msk->subflow || ssk != msk->subflow->sk;
@@ -2495,12 +2493,12 @@ static void __mptcp_close_subflow(struct sock *sk)
 
 }
 
-static bool mptcp_check_close_timeout(const struct sock *sk)
+static bool mptcp_should_close(const struct sock *sk)
 {
 	s32 delta = tcp_jiffies32 - inet_csk(sk)->icsk_mtup.probe_timestamp;
 	struct mptcp_subflow_context *subflow;
 
-	if (delta >= TCP_TIMEWAIT_LEN)
+	if (delta >= TCP_TIMEWAIT_LEN || mptcp_sk(sk)->in_accept_queue)
 		return true;
 
 	/* if all subflows are in closed status don't bother with additional
@@ -2723,7 +2721,7 @@ static void mptcp_worker(struct work_struct *work)
 	 * even if it is orphaned and in FIN_WAIT2 state
 	 */
 	if (sock_flag(sk, SOCK_DEAD)) {
-		if (mptcp_check_close_timeout(sk)) {
+		if (mptcp_should_close(sk)) {
 			inet_sk_state_store(sk, TCP_CLOSE);
 			mptcp_do_fastclose(sk);
 		}
-- 
2.39.2
Re: [PATCH mptcp-net] Squash-to: "mptcp: fix accept vs worker race"
Posted by Matthieu Baerts 1 year, 1 month ago
Hi Paolo,

On 06/04/2023 21:41, Paolo Abeni wrote:
> Avoid the ugly timeout hack, we can rely simple on
> the in_accept_queue flag.

Thank you for this patch!

Indeed cleaner and good idea to have renamed the function.

Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>

Just applied:

New patches for t/upstream-net and t/upstream:
- e64fe31d095e: "squashed" in "mptcp: fix accept vs worker race"
- Results: db0ea133bb6b..38f9e8a70d76 (export-net)
- Results: 930f9c85e067..016e68a14412 (export)

Tests are now in progress:

https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export-net/20230407T092153
https://cirrus-ci.com/github/multipath-tcp/mptcp_net-next/export/20230407T092153

Cheers,
Matt
-- 
Tessares | Belgium | Hybrid Access Solutions
www.tessares.net