Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1b201b63 authored by Stephen Barber's avatar Stephen Barber Committed by Greg Kroah-Hartman
Browse files

vsock/virtio: set SOCK_DONE on peer shutdown



[ Upstream commit 42f5cda5eaf4396a939ae9bb43bb8d1d09c1b15c ]

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: default avatarStephen Barber <smbarber@chromium.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent b86a5ccd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -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;