1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00

mptcp: consolidate transition to TCP_CLOSE in mptcp_do_fastclose()

The MPTCP code always set the msk state to TCP_CLOSE before
calling performing the fast-close. Move such state transition in
mptcp_do_fastclose() to avoid some code duplication.

Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Reviewed-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Paolo Abeni 2023-06-20 18:30:21 +02:00 committed by Jakub Kicinski
parent 00079f18c2
commit bbd49d114d

View file

@ -2655,6 +2655,7 @@ static void mptcp_do_fastclose(struct sock *sk)
struct mptcp_subflow_context *subflow, *tmp; struct mptcp_subflow_context *subflow, *tmp;
struct mptcp_sock *msk = mptcp_sk(sk); struct mptcp_sock *msk = mptcp_sk(sk);
inet_sk_state_store(sk, TCP_CLOSE);
mptcp_for_each_subflow_safe(msk, subflow, tmp) mptcp_for_each_subflow_safe(msk, subflow, tmp)
__mptcp_close_ssk(sk, mptcp_subflow_tcp_sock(subflow), __mptcp_close_ssk(sk, mptcp_subflow_tcp_sock(subflow),
subflow, MPTCP_CF_FASTCLOSE); subflow, MPTCP_CF_FASTCLOSE);
@ -2692,10 +2693,9 @@ static void mptcp_worker(struct work_struct *work)
* even if it is orphaned and in FIN_WAIT2 state * even if it is orphaned and in FIN_WAIT2 state
*/ */
if (sock_flag(sk, SOCK_DEAD)) { if (sock_flag(sk, SOCK_DEAD)) {
if (mptcp_should_close(sk)) { if (mptcp_should_close(sk))
inet_sk_state_store(sk, TCP_CLOSE);
mptcp_do_fastclose(sk); mptcp_do_fastclose(sk);
}
if (sk->sk_state == TCP_CLOSE) { if (sk->sk_state == TCP_CLOSE) {
__mptcp_destroy_sock(sk); __mptcp_destroy_sock(sk);
goto unlock; goto unlock;
@ -2938,7 +2938,6 @@ static void __mptcp_destroy_sock(struct sock *sk)
void __mptcp_unaccepted_force_close(struct sock *sk) void __mptcp_unaccepted_force_close(struct sock *sk)
{ {
sock_set_flag(sk, SOCK_DEAD); sock_set_flag(sk, SOCK_DEAD);
inet_sk_state_store(sk, TCP_CLOSE);
mptcp_do_fastclose(sk); mptcp_do_fastclose(sk);
__mptcp_destroy_sock(sk); __mptcp_destroy_sock(sk);
} }
@ -2980,7 +2979,6 @@ bool __mptcp_close(struct sock *sk, long timeout)
/* If the msk has read data, or the caller explicitly ask it, /* If the msk has read data, or the caller explicitly ask it,
* do the MPTCP equivalent of TCP reset, aka MPTCP fastclose * do the MPTCP equivalent of TCP reset, aka MPTCP fastclose
*/ */
inet_sk_state_store(sk, TCP_CLOSE);
mptcp_do_fastclose(sk); mptcp_do_fastclose(sk);
timeout = 0; timeout = 0;
} else if (mptcp_close_state(sk)) { } else if (mptcp_close_state(sk)) {