Skip to content
This repository has been archived by the owner on Apr 18, 2024. It is now read-only.

Commit

Permalink
mptcp: Avoid tcp_done and mptcp_sock_def_error_report warnings
Browse files Browse the repository at this point in the history
It seems to be possible that we are in tcp_keepalive_timer with
send_mp_fclose set to 1 and during that time a call to tcp_close ends up
closing the subflow.

Once we successfully manage to pass the bh_lock_sock() and sock_owned*()
barrier in tcp_keepalive_timer we then may end up in the condition
triggering the sending of a fast-close. But, the socket is now in
TCP_CLOSE state, thus leading to an error in tcp_done if we end up
calling tcp_write_err().

All timers handle this kind of a "race" by checking sk_state for
TCP_CLOSE right after passing the bh_lock_sock() barrier. Even
tcp_keepalive_timer makes sure that we won't do anything on a socket in
TCP_CLOSE state.

Thus, we need to check for sk_state before entering the send_mp_fclose
condition.

Fixes: a313bd7 ("mptcp: Correctly wait for RST when FASTCLOSE'ing")
Signed-off-by: Christoph Paasch <cpaasch@apple.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit 80a651c)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit db07838)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
(cherry picked from commit ef76cf9)
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
cpaasch authored and matttbe committed Feb 28, 2022
1 parent f08ddc1 commit d0b3246
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions net/ipv4/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -2168,6 +2168,7 @@ static const unsigned char new_state[16] = {
[TCP_LISTEN] = TCP_CLOSE,
[TCP_CLOSING] = TCP_CLOSING,
[TCP_NEW_SYN_RECV] = TCP_CLOSE, /* should not happen ! */
[TCP_RST_WAIT] = TCP_CLOSE,
};

int tcp_close_state(struct sock *sk)
Expand Down
2 changes: 1 addition & 1 deletion net/ipv4/tcp_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ static void tcp_keepalive_timer (unsigned long data)

tcp_mstamp_refresh(tp);

if (tp->send_mp_fclose) {
if (tp->send_mp_fclose && sk->sk_state == TCP_RST_WAIT) {
if (icsk->icsk_retransmits >= MPTCP_FASTCLOSE_RETRIES) {
tcp_write_err(sk);
goto out;
Expand Down

0 comments on commit d0b3246

Please sign in to comment.