Skip to content

Commit

Permalink
mptcp: fix state tracking for fallback socket
Browse files Browse the repository at this point in the history
We need to cope with some more state transition for
fallback sockets, or could still end-up moving to TCP_CLOSE
too early and avoid spooling some pending data

Fixes: e16163b ("mptcp: refactor shutdown and close")
Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
Paolo Abeni authored and jenkins-tessares committed Nov 20, 2020
1 parent 3b75adb commit 77ec7c2
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,9 @@ static void mptcp_check_for_eof(struct mptcp_sock *msk)
inet_sk_state_store(sk, TCP_CLOSE_WAIT);
break;
case TCP_FIN_WAIT1:
/* fallback sockets skip TCP_CLOSING - TCP will take care */
inet_sk_state_store(sk, TCP_CLOSING);
break;
case TCP_FIN_WAIT2:
inet_sk_state_store(sk, TCP_CLOSE);
break;
default:
Expand Down Expand Up @@ -2086,10 +2088,16 @@ static void __mptcp_check_send_data_fin(struct sock *sk)

WRITE_ONCE(msk->snd_nxt, msk->write_seq);

/* fallback socket will not get data_fin/ack, can move to close now */
if (__mptcp_check_fallback(msk) && sk->sk_state == TCP_LAST_ACK) {
inet_sk_state_store(sk, TCP_CLOSE);
mptcp_close_wake_up(sk);
/* fallback socket will not get data_fin/ack, can move to the next
* state now
*/
if (__mptcp_check_fallback(msk)) {
if ((1 << sk->sk_state) & (TCPF_CLOSING | TCPF_LAST_ACK)) {
inet_sk_state_store(sk, TCP_CLOSE);
mptcp_close_wake_up(sk);
} else if (sk->sk_state == TCP_FIN_WAIT1) {
inet_sk_state_store(sk, TCP_FIN_WAIT2);
}
}

__mptcp_flush_join_list(msk);
Expand Down

0 comments on commit 77ec7c2

Please sign in to comment.