When an MPTCP socket moves to TCP_CLOSE because its last subflow is closed, after the close timeout or not, sk_shutdown was not updated, and no error was set in most cases. A thread blocked in send() was then never woken up for good. Set SEND_SHUTDOWN in these cases: no more data can be sent. The blocked send() then returns EPIPE, as a send() called after the close timeout already does. Reporting another error first, e.g. ETIMEDOUT as TCP does after a timeout, would change the behaviour seen by the applications: this is left for net-next. This was reported on GitHub, with a reproducer: the only subflow dies by RTO, and send() was never woken up, while it returned ETIMEDOUT after a few seconds with TCP. With this patch, send() returns EPIPE after the subflow timeout (like TCP) and the close timeout (by default at 60 seconds). This is also validated with new Packetdrill tests, with the close timeout, and with a reset received in CLOSE_WAIT. Without this patch, send() stayed blocked in both cases: close_timeout_blocked_send.pkt:24: runtime error: exiting while a blocking system call is in progress close_wait_reset_blocked_send.pkt:25: runtime error: exiting while a blocking system call is in progress Fixes: 27e5ccc2d5a5 ("mptcp: fix dangling connection hang-up") Cc: stable@vger.kernel.org Closes: https://github.com/multipath-tcp/mptcp_net-next/issues/648 Signed-off-by: Matthieu Baerts (NGI0) --- net/mptcp/protocol.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/net/mptcp/protocol.c b/net/mptcp/protocol.c index 1f045348764a..e89ed0b1e421 100644 --- a/net/mptcp/protocol.c +++ b/net/mptcp/protocol.c @@ -2756,6 +2756,8 @@ static void __mptcp_close_ssk(struct sock *sk, struct sock *ssk, } else if (sk->sk_state != TCP_ESTABLISHED || msk->in_accept_queue) { mptcp_set_state(sk, TCP_CLOSE); + WRITE_ONCE(sk->sk_shutdown, + sk->sk_shutdown | SEND_SHUTDOWN); mptcp_close_wake_up(sk); } else { mptcp_start_tout_timer(sk); @@ -3247,6 +3249,7 @@ static void mptcp_worker(struct work_struct *work) mptcp_do_fastclose(sk); mptcp_for_each_subflow_safe(msk, subflow, tmp) __mptcp_close_ssk(sk, subflow->tcp_sock, subflow, 0); + WRITE_ONCE(sk->sk_shutdown, sk->sk_shutdown | SEND_SHUTDOWN); mptcp_close_wake_up(sk); } -- 2.55.0