Skip to content

Commit

Permalink
mptcp: fix poll after shutdown
Browse files Browse the repository at this point in the history
The current mptcp_poll() implementation gives unexpected
results after shutdown(SEND_SHUTDOWN) and and when the msk
status is TCP_CLOSE.

Set the correct mask.

Reviewed-by: Mat Martineau <[email protected]>
Signed-off-by: Paolo Abeni <[email protected]>
  • Loading branch information
Paolo Abeni authored and jenkins-tessares committed Feb 7, 2021
1 parent e0d489b commit 928f65d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -3317,7 +3317,7 @@ static __poll_t mptcp_check_writeable(struct mptcp_sock *msk)
struct sock *sk = (struct sock *)msk;

if (unlikely(sk->sk_shutdown & SEND_SHUTDOWN))
return 0;
return EPOLLOUT | EPOLLWRNORM;

if (sk_stream_is_writeable(sk))
return EPOLLOUT | EPOLLWRNORM;
Expand Down Expand Up @@ -3350,6 +3350,8 @@ static __poll_t mptcp_poll(struct file *file, struct socket *sock,
mask |= mptcp_check_readable(msk);
mask |= mptcp_check_writeable(msk);
}
if (sk->sk_shutdown == SHUTDOWN_MASK || state == TCP_CLOSE)
mask |= EPOLLHUP;
if (sk->sk_shutdown & RCV_SHUTDOWN)
mask |= EPOLLIN | EPOLLRDNORM | EPOLLRDHUP;

Expand Down

0 comments on commit 928f65d

Please sign in to comment.