Skip to contentSkip to conversation

VSOCK: do not disconnect socket when peer has shutdown SEND only

PATCH In review Ian Campbell 3 participants 3 messages May 4, 2016 – May 6, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 VSOCK: do not disconnect socket when peer has shutdown SEND only

The peer may be expecting a reply having sent a request and then done a shutdown(SHUT_WR), so tearing down the whole socket at this point seems wrong and breaks for me with a client which does a SHUT_WR.

Looking at other socket family's stream_recvmsg callbacks doing a shutdown here does not seem to be the norm and removing it does not seem to have had any adverse effects that I can see.

I'm using Stefan's RFC virtio transport patches, I'm unsure of the impact on the vmci transport.

Cc "David S. Miller" <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Claudio Imbrenda <[email protected]>
Cc Andy King <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Jorgen Hansen <[email protected]>
Cc Adit Ranadive <[email protected]>
---
 net/vmw_vsock/af_vsock.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
net/vmw_vsock/af_vsock.c +1 -20
index 1e5f5ed..7a25150 100644
@@ -1789,27 +1789,8 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 	else if (sk->sk_shutdown & RCV_SHUTDOWN)
 		err = 0;
 
-	if (copied > 0) {
-		/* We only do these additional bookkeeping/notification steps
-		 * if we actually copied something out of the queue pair
-		 * instead of just peeking ahead.
-		 */
-
-		if (!(flags & MSG_PEEK)) {
-			/* If the other side has shutdown for sending and there
-			 * is nothing more to read, then modify the socket
-			 * state.
-			 */
-			if (vsk->peer_shutdown & SEND_SHUTDOWN) {
-				if (vsock_stream_has_data(vsk) <= 0) {
-					sk->sk_state = SS_UNCONNECTED;
-					sock_set_flag(sk, SOCK_DONE);
-					sk->sk_state_change(sk);
-				}
-			}
-		}
+	if (copied > 0)
 		err = copied;
-	}
 
 out:
 	release_sock(sk);
Signature · 1 line
2.8.1
#1 lore raw
Quoted 7 lines · Ian Campbell

The peer may be expecting a reply having sent a request and then done a shutdown(SHUT_WR), so tearing down the whole socket at this point seems wrong and breaks for me with a client which does a SHUT_WR.

Looking at other socket family's stream_recvmsg callbacks doing a shutdown here does not seem to be the norm and removing it does not seem to have had any adverse effects that I can see.

Seems fine to me.

Quoted 52 lines

I'm using Stefan's RFC virtio transport patches, I'm unsure of the impact on the vmci transport.

Cc "David S. Miller" <[email protected]>
Cc Stefan Hajnoczi <[email protected]>
Cc Claudio Imbrenda <[email protected]>
Cc Andy King <[email protected]>
Cc Dmitry Torokhov <[email protected]>
Cc Jorgen Hansen <[email protected]>
Cc Adit Ranadive <[email protected]>
---
 net/vmw_vsock/af_vsock.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)
net/vmw_vsock/af_vsock.c +1 -20
index 1e5f5ed..7a25150 100644
@@ -1789,27 +1789,8 @@ vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
 	else if (sk->sk_shutdown & RCV_SHUTDOWN)
 		err = 0;
 
-	if (copied > 0) {
-		/* We only do these additional bookkeeping/notification steps
-		 * if we actually copied something out of the queue pair
-		 * instead of just peeking ahead.
-		 */
-
-		if (!(flags & MSG_PEEK)) {
-			/* If the other side has shutdown for sending and there
-			 * is nothing more to read, then modify the socket
-			 * state.
-			 */
-			if (vsk->peer_shutdown & SEND_SHUTDOWN) {
-				if (vsock_stream_has_data(vsk) <= 0) {
-					sk->sk_state = SS_UNCONNECTED;
-					sock_set_flag(sk, SOCK_DONE);
-					sk->sk_state_change(sk);
-				}
-			}
-		}
+	if (copied > 0)
 		err = copied;
-	}
 
 out:
 	release_sock(sk);
Signature · 1 line
2.8.1
maintainer
#2 lore raw
In reply to Ian Campbell

From: Ian Campbell <[email protected]>
Date: Wed, 4 May 2016 14:21:53 +0100

Quoted 4 lines

The peer may be expecting a reply having sent a request and then done a shutdown(SHUT_WR), so tearing down the whole socket at this point seems wrong and breaks for me with a client which does a SHUT_WR.

Quoted 8 lines

Looking at other socket family's stream_recvmsg callbacks doing a shutdown here does not seem to be the norm and removing it does not seem to have had any adverse effects that I can see.

I'm using Stefan's RFC virtio transport patches, I'm unsure of the impact on the vmci transport.

Applied and queued up for -stable, thanks.