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 12, 2021
1 parent 68b3a93 commit f5ffd6e
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 @@ -3332,7 +3332,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 @@ -3365,6 +3365,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 f5ffd6e

Please sign in to comment.