Skip to content

Commit

Permalink
vsock/virtio: set SOCK_DONE on peer shutdown
Browse files Browse the repository at this point in the history
Set the SOCK_DONE flag to match the TCP_CLOSING state when a peer has
shut down and there is nothing left to read.

This fixes the following bug:
1) Peer sends SHUTDOWN(RDWR).
2) Socket enters TCP_CLOSING but SOCK_DONE is not set.
3) read() returns -ENOTCONN until close() is called, then returns 0.

Signed-off-by: Stephen Barber <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
Stephen Barber authored and davem330 committed Jun 15, 2019
1 parent 760c80b commit 42f5cda
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion net/vmw_vsock/virtio_transport_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -871,8 +871,10 @@ virtio_transport_recv_connected(struct sock *sk,
if (le32_to_cpu(pkt->hdr.flags) & VIRTIO_VSOCK_SHUTDOWN_SEND)
vsk->peer_shutdown |= SEND_SHUTDOWN;
if (vsk->peer_shutdown == SHUTDOWN_MASK &&
vsock_stream_has_data(vsk) <= 0)
vsock_stream_has_data(vsk) <= 0) {
sock_set_flag(sk, SOCK_DONE);
sk->sk_state = TCP_CLOSING;
}
if (le32_to_cpu(pkt->hdr.flags))
sk->sk_state_change(sk);
break;
Expand Down

0 comments on commit 42f5cda

Please sign in to comment.