Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp353015pxj; Thu, 3 Jun 2021 08:16:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdV/zGp+whQKIR7onTuT/qC/thiWBZiqAAvUf0q0C+wpSw8yNbS6Q22erH1mKxkpgsoZOz X-Received: by 2002:a17:906:b24a:: with SMTP id ce10mr103283ejb.83.1622733411713; Thu, 03 Jun 2021 08:16:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622733411; cv=none; d=google.com; s=arc-20160816; b=W+XFY8S66dhRwW8dAFnoV8EoHn0y8BAgky5jq8vkiC0MS4M3X4Q1XBvREm+XmZ6o+s onAdc62HInmLRbXXqfBBhv8M0LQr2eEMPgpoPmynAQBHZrUWuoGyR0TKW1kWbskjC7fj 79f03JHepIFUZNOtj9QMcWdaK0rvC2CECJa2Vm2OEhPVs2IpZQn9BUkHacaoPtrvcXeR bfkytzDJ6uREcvyVjZaMYOTkqzrGmFY+F538VwFhC080LTYjrf/4d3M91kEdvKu2bMsz bSjQeyCb5udDEvMHwkxY+qOYXfKztI6DVkDSi1RI6ykBKueilIDk+Qq6gnvgu22WtAMc XU5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=/TbnjPejbYwVan9HkOykuBL+tAV4BzyESSrfqanFgRE=; b=Pw4HQE3xPuh7IuFTOFnDnWoEBXdrPMGRwfGTm3ebNs2v/XNlYM72aE3VqCpVFTdfOQ CJUINi7sWk27gPvm4AsCUFu1PxUz9fxDwtTZrbfSS5Q58BzYTBj+DK9XUPNSCYIZNjUM 8fxWoH6QTLxPk8sB2qvBxMNwaKZyavmRQB8aDfX1KTCfLk7JDMKdEt8QHDrw5DyzOTeV M/YEaY/TCK2nQkzWrRoN5i82M6yYyZ4AwdxSo70damx2wSZNpblUJxss48odrxXmPGQs JOaFI3eDkfroA7iebGwPnH9t+E2zKb6pjmhkEiswbPpnvYF2w2rYWhb+BY45FWinRpHB hVVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G8G+/20/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si2437276ejx.635.2021.06.03.08.16.27; Thu, 03 Jun 2021 08:16:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G8G+/20/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231822AbhFCPQa (ORCPT + 99 others); Thu, 3 Jun 2021 11:16:30 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56867 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231376AbhFCPQ3 (ORCPT ); Thu, 3 Jun 2021 11:16:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1622733284; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=/TbnjPejbYwVan9HkOykuBL+tAV4BzyESSrfqanFgRE=; b=G8G+/20/tkQbMnXpvX8HFRinXvufLQ3bNOoduXVp/EJc1DCTRGJnyB7LDuEcpXEMI1LZiM Ph0PSJrX/4dorCOqQDsjK/IDHS5jlsRxoZqIvyeBtzMf75BffYVhHmvzus8cmPdzkBtgEZ GFXLUyaiBKMOk6hkz9A2eDues5yEudE= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-477-90nCQNhlMrCP299KXpXfqw-1; Thu, 03 Jun 2021 11:14:43 -0400 X-MC-Unique: 90nCQNhlMrCP299KXpXfqw-1 Received: by mail-ed1-f69.google.com with SMTP id a16-20020aa7cf100000b0290391819a774aso1392517edy.8 for ; Thu, 03 Jun 2021 08:14:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=/TbnjPejbYwVan9HkOykuBL+tAV4BzyESSrfqanFgRE=; b=LabvVATt5q0AfsjTithO2fjrYifNtBE5x0ef7ZiCwA/aOmtqq0mTBxfCuoprxvh9ne zOVIxRT6ns838u1EWs/xlshn9x/KqDpBCMIb4ltqp3lsec/kqHUAUDcQkTRu5DzUI3uU cnuaLQ/u6tLfEvM8EzFQmnnP1bBxwoggTWIj28flR4eiEPpC96g8MsZW6hJBkxca5FSY vHOrlAtQpp0yUB9eNBwflKMoZnBGuy/0SZRNnhlG7RTt73F+Xarj0sbKotiSQjUZXV28 6bna7EkM67/lPyfZRZi6wh/o3FZZGn0QTpUtTfVvaxlqpcbMQFJ7tzjLXD/bRvcCOiqm dJmA== X-Gm-Message-State: AOAM5337PTyXCxCWmG2YiLkGeF1rLrJRQ14KkgbBvY0fXdJ39/aw1Dxj CVd3OZ1dIarBTomy2r0UtMNys5J/rGjBH8v/6KGMyZL8DhMx5bI+/I44zYCRsXAQzhVEALuiFQY Q96PuXhHRQkHBonBP0n78EGRn X-Received: by 2002:a17:906:15c2:: with SMTP id l2mr102907ejd.348.1622733281791; Thu, 03 Jun 2021 08:14:41 -0700 (PDT) X-Received: by 2002:a17:906:15c2:: with SMTP id l2mr102880ejd.348.1622733281491; Thu, 03 Jun 2021 08:14:41 -0700 (PDT) Received: from steredhat ([5.170.129.82]) by smtp.gmail.com with ESMTPSA id v21sm1894572edt.48.2021.06.03.08.14.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Jun 2021 08:14:40 -0700 (PDT) Date: Thu, 3 Jun 2021 17:14:33 +0200 From: Stefano Garzarella To: Arseny Krasnov Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Andra Paraschiv , Colin Ian King , Norbert Slusarek , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, oxffffaa@gmail.com Subject: Re: [PATCH v10 13/18] virtio/vsock: rest of SOCK_SEQPACKET support Message-ID: <20210603151433.3tbiibmcfacpcjt2@steredhat> References: <20210520191357.1270473-1-arseny.krasnov@kaspersky.com> <20210520191840.1272290-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210520191840.1272290-1-arseny.krasnov@kaspersky.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 20, 2021 at 10:18:37PM +0300, Arseny Krasnov wrote: >Small updates to make SOCK_SEQPACKET work: >1) Send SHUTDOWN on socket close for SEQPACKET type. >2) Set SEQPACKET packet type during send. >3) Set 'VIRTIO_VSOCK_SEQ_EOR' bit in flags for last > packet of message. > >Signed-off-by: Arseny Krasnov >--- > v9 -> v10: > 1) Use 'msg_data_left()' instead of direct access to 'msg_hdr'. > 2) Commit message updated. > 3) Add check for socket type when setting SEQ_EOR bit. > > include/linux/virtio_vsock.h | 4 ++++ > net/vmw_vsock/virtio_transport_common.c | 18 ++++++++++++++++-- > 2 files changed, 20 insertions(+), 2 deletions(-) > >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h >index 02acf6e9ae04..7360ab7ea0af 100644 >--- a/include/linux/virtio_vsock.h >+++ b/include/linux/virtio_vsock.h >@@ -80,6 +80,10 @@ virtio_transport_dgram_dequeue(struct vsock_sock *vsk, > struct msghdr *msg, > size_t len, int flags); > >+int >+virtio_transport_seqpacket_enqueue(struct vsock_sock *vsk, >+ struct msghdr *msg, >+ size_t len); > ssize_t > virtio_transport_seqpacket_dequeue(struct vsock_sock *vsk, > struct msghdr *msg, >diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c >index a6f8b0f39775..f7a3281b3eab 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -74,6 +74,11 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info, > err = memcpy_from_msg(pkt->buf, info->msg, len); > if (err) > goto out; >+ >+ if (msg_data_left(info->msg) == 0 && >+ info->type == VIRTIO_VSOCK_TYPE_SEQPACKET) >+ pkt->hdr.flags = cpu_to_le32(info->flags | >+ VIRTIO_VSOCK_SEQ_EOR); `pkt->hdr.flags |= cpu_to_le32(VIRTIO_VSOCK_SEQ_EOR)` should be enough, no? Stefano > } > > trace_virtio_transport_alloc_pkt(src_cid, src_port, >@@ -187,7 +192,7 @@ static int virtio_transport_send_pkt_info(struct vsock_sock *vsk, > struct virtio_vsock_pkt *pkt; > u32 pkt_len = info->pkt_len; > >- info->type = VIRTIO_VSOCK_TYPE_STREAM; >+ info->type = virtio_transport_get_type(sk_vsock(vsk)); > > t_ops = virtio_transport_get_ops(vsk); > if (unlikely(!t_ops)) >@@ -478,6 +483,15 @@ virtio_transport_seqpacket_dequeue(struct vsock_sock *vsk, > } > EXPORT_SYMBOL_GPL(virtio_transport_seqpacket_dequeue); > >+int >+virtio_transport_seqpacket_enqueue(struct vsock_sock *vsk, >+ struct msghdr *msg, >+ size_t len) >+{ >+ return virtio_transport_stream_enqueue(vsk, msg, len); >+} >+EXPORT_SYMBOL_GPL(virtio_transport_seqpacket_enqueue); >+ > int > virtio_transport_dgram_dequeue(struct vsock_sock *vsk, > struct msghdr *msg, >@@ -912,7 +926,7 @@ void virtio_transport_release(struct vsock_sock *vsk) > struct sock *sk = &vsk->sk; > bool remove_sock = true; > >- if (sk->sk_type == SOCK_STREAM) >+ if (sk->sk_type == SOCK_STREAM || sk->sk_type == SOCK_SEQPACKET) > remove_sock = virtio_transport_close(vsk); > > if (remove_sock) { >-- >2.25.1 >