Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp260460pxy; Wed, 21 Apr 2021 02:16:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2ewQyPdzborS709XpqC+CpjraPaxAzS8YsZ+KfWmwGVgKa51ldvlW9cLJZb6UrEhimUJA X-Received: by 2002:a17:907:16a9:: with SMTP id hc41mr24897075ejc.84.1618996570270; Wed, 21 Apr 2021 02:16:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618996570; cv=none; d=google.com; s=arc-20160816; b=rxMohm7YAjpaZhwaoMjHQTfJAEyipwPseU5BDYnXWSamtv34D7SvJD2Hp6fNqggkvx QcftKukzyaOlYpJH7ztED0RBixaCxIwzXQISYFY15eEbv3uIanB77+hMOD38XLN4Vo09 GgzRLuXw2kpRxTXCEMHWXSy5X360wZYq0xc16o+g9Jyx/ywyPw4AsK6wzSTcttfPh6Eh 5epeoOBeX88wwCr+Q/aCakEqytC1kF+Xg588Ty5Vj+5es7JUr7AT47ZnG2ksbCtMZNHR oxmhuvvVeSr4LYsR1Kbh2g+3UcuxJu1Eh6DCW5g/MKxoNs9cksDs1bnj6+NwqkaftBT3 xGrw== 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=JFQIJ+5CqCy4do+wsQBitgOFibPbQLAGAyXiYakCXZc=; b=wnVOYiMgYa1Y+dGvoIau0nXdRC+O9rMBGSmd6DrQmG3o+s8JBrQNuZolL6nH0cc+Ul HK4lyycg11MFRzNpGn0PQ7wWmLE3DTNC/dgIe7CdBHgqwy8dIQofRDEm6Xxx9h8HVYLm af2wZv/2X4YVHm0SGP15wD0gXVx+nfUQ0nQR7PsRB7QFU2XqRgVmKV3sX9sTTvCekAEI WnCfXU7rsDX4GQbgrRIe6TO1FRTcEB+lYg7LpsYVtB/p2hmmZ9rRHC5U//IZg6KEjiUE 66zx9KX7l+K4gSIUV6bvZPCaGNfAiDcRSRQ5XM1Cfpa9ZN3ZoX/Pv25nSh3gRZwbWIAa x5qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=R9ILyV6S; 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 ds10si1544808ejc.415.2021.04.21.02.15.45; Wed, 21 Apr 2021 02:16:10 -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=R9ILyV6S; 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 S237794AbhDUJNL (ORCPT + 99 others); Wed, 21 Apr 2021 05:13:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:33794 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235170AbhDUJNJ (ORCPT ); Wed, 21 Apr 2021 05:13:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1618996356; 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=JFQIJ+5CqCy4do+wsQBitgOFibPbQLAGAyXiYakCXZc=; b=R9ILyV6SbJsrVR3/VhTuDgm81qnuL90wF8Cd1QFexDXYDSa1ha7T49a364ArxKxQ5EAZrv XmjhdJDKoWixGy0THawJ1SA6dGSEKauybw29jA9nzQoKUTCwSXwigOpj0eNTGwB5Ic2voJ M5CrsZvJ8gz3MwOz5TRUEnsweuaIzJc= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-246-g1ce9MIJO2CZeG9jJ4QYlA-1; Wed, 21 Apr 2021 05:12:34 -0400 X-MC-Unique: g1ce9MIJO2CZeG9jJ4QYlA-1 Received: by mail-ed1-f70.google.com with SMTP id bf25-20020a0564021a59b0290385169cebf8so7288508edb.8 for ; Wed, 21 Apr 2021 02:12:34 -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=JFQIJ+5CqCy4do+wsQBitgOFibPbQLAGAyXiYakCXZc=; b=TrgOi/L42J4jyxA2loe6Gv8v48oOsbx1HhmYhrcxdYABT/JwXJ0QCm867/bA9/gyx2 3iFz4PQk4a9Pxkb1p3PE1ZeN61J2db7nPVqzFVlcIfbGt7FDU6YA94FS4WaAvrE1H0/g cZJwyJKWqHqFB4Ej9LFbFjA1E+xWEkaffxkHhCk02uzNG5Z6faQJAhRtx4ReiNGT264i 8KBlZE7rvhnAKLsygjAbDenAA6Zgm6OSALsgSM6MpaARAX5gFMvwXS9WHKH7UpbmGdJ+ mimEsk9n3kvgyRVoSzH2LnvtuW/bNBT4lrrfNa1NBDa/UKIcYsknDhJQgiVP9PXA8qTv JADw== X-Gm-Message-State: AOAM530e76UUnhkauhHRJx394yoLoiuAqKsn0QxSL0MurylgLgAOsdJr Gr71bj2twHJlw0SDl0m12nzVUWcCuJ9GlnLCSLsuhhR6AHkPfInhTDArvR8T2Thv9SqlIXeT4Jm StFcBSonXlCUXBkf7tjrro8e7 X-Received: by 2002:a50:fb0a:: with SMTP id d10mr24562930edq.146.1618996352006; Wed, 21 Apr 2021 02:12:32 -0700 (PDT) X-Received: by 2002:a50:fb0a:: with SMTP id d10mr24562907edq.146.1618996351808; Wed, 21 Apr 2021 02:12:31 -0700 (PDT) Received: from steredhat (host-79-34-249-199.business.telecomitalia.it. [79.34.249.199]) by smtp.gmail.com with ESMTPSA id dc24sm1725846ejb.123.2021.04.21.02.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Apr 2021 02:12:31 -0700 (PDT) Date: Wed, 21 Apr 2021 11:12:28 +0200 From: Stefano Garzarella To: Arseny Krasnov Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Colin Ian King , Andra Paraschiv , Norbert Slusarek , Alexander Popov , kvm , Linux Virtualization , netdev , kernel list , stsp , Krasnov Arseniy Subject: Re: [RFC PATCH v8 13/19] virtio/vsock: rest of SOCK_SEQPACKET support Message-ID: References: <20210413123954.3396314-1-arseny.krasnov@kaspersky.com> <20210413124528.3404287-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210413124528.3404287-1-arseny.krasnov@kaspersky.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Apr 13, 2021 at 03:45:25PM +0300, Arseny Krasnov wrote: >This adds rest of logic for SEQPACKET: >1) Send SHUTDOWN on socket close for SEQPACKET type. >2) Set SEQPACKET packet type during send. >3) 'seqpacket_allow' flag to virtio transport. >4) Set 'VIRTIO_VSOCK_SEQ_EOR' bit in flags for last > packet of message. > >Signed-off-by: Arseny Krasnov >--- >v7 -> v8: > - MSG_EOR handling is removed, i didn't found exact description about > how it works in POSIX. > - SEQ_BEGIN, SEQ_END, etc. now removed. > > include/linux/virtio_vsock.h | 6 ++++++ > net/vmw_vsock/virtio_transport_common.c | 16 ++++++++++++++-- > 2 files changed, 20 insertions(+), 2 deletions(-) > >diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h >index 02acf6e9ae04..f00a01bfdd7e 100644 >--- a/include/linux/virtio_vsock.h >+++ b/include/linux/virtio_vsock.h >@@ -68,6 +68,8 @@ struct virtio_transport { > > /* Takes ownership of the packet */ > int (*send_pkt)(struct virtio_vsock_pkt *pkt); >+ >+ bool seqpacket_allow; > }; > > ssize_t >@@ -80,6 +82,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 572869fef832..4c5b63601308 100644 >--- a/net/vmw_vsock/virtio_transport_common.c >+++ b/net/vmw_vsock/virtio_transport_common.c >@@ -74,6 +74,9 @@ virtio_transport_alloc_pkt(struct virtio_vsock_pkt_info *info, > err = memcpy_from_msg(pkt->buf, info->msg, len); > if (err) > goto out; >+ >+ if (info->msg->msg_iter.count == 0) >+ pkt->hdr.flags |= VIRTIO_VSOCK_SEQ_EOR; We should set the flag in info->flags and assign it using cpu_to_le32() or just the following: pkt->hdr.flags = cpu_to_le32(info->flags | VIRTIO_VSOCK_SEQ_EOR); > } > > trace_virtio_transport_alloc_pkt(src_cid, src_port, >@@ -187,7 +190,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)) >@@ -486,6 +489,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, >@@ -905,7 +917,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); > > list_for_each_entry_safe(pkt, tmp, &vvs->rx_queue, list) { >-- >2.25.1 >