VSOCK: do not disconnect socket when peer has shutdown SEND only
Subsystems (6)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Stefan Hajnoczi
maintainerPATCH 11/30 VSOCK: do not disconnect socket when peer has shutdown SEND only
From: Ian Campbell <[email protected]>
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.
--- net/vmw_vsock/af_vsock.c | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-)
net/vmw_vsock/af_vsock.c +1 -20
@@ -1809,27 +1809,8 @@ vsock_stream_recvmsg(struct kiocb *kiocb,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.9.3
Stefan Hajnoczi
maintainerPATCH 28/30 vsock/virtio: fix src/dst cid format
In reply to a message not in the archiveFrom: "Michael S. Tsirkin" <[email protected]>
These fields are 64 bit, using le32_to_cpu and friends on these will not do the right thing.
Fix this up.
--- net/vmw_vsock/virtio_transport_common.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
net/vmw_vsock/virtio_transport_common.c +7 -7
@@ -605,9 +605,9 @@ static int virtio_transport_reset_no_sock(struct virtio_vsock_pkt *pkt)return 0 ; pkt =virtio_transport_alloc_pkt (&info,0 , -le32_to_cpu (pkt->hdr.dst_cid), +le64_to_cpu (pkt->hdr.dst_cid),le32_to_cpu (pkt->hdr.dst_port), -le32_to_cpu (pkt->hdr.src_cid), +le64_to_cpu (pkt->hdr.src_cid),le32_to_cpu (pkt->hdr.src_port));if (!pkt)return -ENOMEM ;
@@ -822,7 +822,7 @@ virtio_transport_send_response(struct vsock_sock *vsk,struct virtio_vsock_pkt_info info = { .op =VIRTIO_VSOCK_OP_RESPONSE , .type =VIRTIO_VSOCK_TYPE_STREAM , - .remote_cid =le32_to_cpu (pkt->hdr.src_cid), + .remote_cid =le64_to_cpu (pkt->hdr.src_cid), .remote_port =le32_to_cpu (pkt->hdr.src_port), .reply = true, };
@@ -862,9 +862,9 @@ virtio_transport_recv_listen(struct sock *sk, struct virtio_vsock_pkt *pkt) child->sk_state =SS_CONNECTED ; vchild =vsock_sk (child); -vsock_addr_init (&vchild->local_addr,le32_to_cpu (pkt->hdr.dst_cid), +vsock_addr_init (&vchild->local_addr,le64_to_cpu (pkt->hdr.dst_cid),le32_to_cpu (pkt->hdr.dst_port)); -vsock_addr_init (&vchild->remote_addr,le32_to_cpu (pkt->hdr.src_cid), +vsock_addr_init (&vchild->remote_addr,le64_to_cpu (pkt->hdr.src_cid),le32_to_cpu (pkt->hdr.src_port));vsock_insert_connected (vchild);
@@ -903,9 +903,9 @@ void virtio_transport_recv_pkt(struct virtio_vsock_pkt *pkt)struct sock *sk;bool space_available; -vsock_addr_init (&src,le32_to_cpu (pkt->hdr.src_cid), +vsock_addr_init (&src,le64_to_cpu (pkt->hdr.src_cid),le32_to_cpu (pkt->hdr.src_port)); -vsock_addr_init (&dst,le32_to_cpu (pkt->hdr.dst_cid), +vsock_addr_init (&dst,le64_to_cpu (pkt->hdr.dst_cid),le32_to_cpu (pkt->hdr.dst_port)); trace_virtio_transport_recv_pkt(src.svm_cid, src.svm_port,
Signature · 1 line
2.9.3