Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1604520pxb; Mon, 22 Feb 2021 06:27:49 -0800 (PST) X-Google-Smtp-Source: ABdhPJwqkOJLqKQWisGe/FRgl74jOwkH8rUIB53V2jmg86+aZ+MmxrgVkhMkVrC2bHCgOS7AdRXn X-Received: by 2002:a17:906:2991:: with SMTP id x17mr13697725eje.367.1614004069783; Mon, 22 Feb 2021 06:27:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614004069; cv=none; d=google.com; s=arc-20160816; b=ToAhMl8lJJoVUdXpST7z3i92kzeeu96byLKdEUsC3mQUDYrBhoJ1n2tzqvI5WCfy8o 8cLdvUc6y3CifLkYHymB9ouIaORa2JxxiCBFbDisNXfqB2R5REY6MbIkJxjWr++QyfKo idJiArQkY+AUdDGsdlKS+ceoKtg5pG15jLFvkom1KlgwBKVaLCdSnHEd3J/7cfvBsTfe jLdKb7FJ33XWAKi9mVnOExyyXZ0uAAi7ZjTJCEedlFDJYy0gFuxOf0tZ+WBw4LXhsXar +CtGnIS9QHtQgT72wwyfLP3dWiCRM61hNWQ8CIgx6QU3SH+S0rYbK/OZ8HvXJ9LeIClw xxCA== 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=C4ob/HwZY6JToPa6OIARFnOVuWbb8EWH4Jtjs9jshMI=; b=jpPUAdxpSCc/4+YkLKcd2ujzQ4E0LCS2UHGIu4GcIAcqEXmsjxgIODJP0ioGdkcFGO jmjinpjZcgR7kMcMUB+CD/AOfuEOuOFOUfc4sPel2Hj0GaAMsja3fktE+ENDNaxbwNLH Ruo6ISkbABnOR0ZDH3GpiMk1gGOQYR9dE/phEr/SYH939xV2VkgYZdOGaNjc//h8g7w6 LD5EmF+2cUr7ZMxKR7Zdck+f7F01uvC9LYueCkW+T6yV0T8Hq7Cpn5r5TtE6XgQIFN32 KDm07pIlWWT4sob3TbLQL32Mvngz9JFjoqaYWr4IrP5Yrchx/yg2Daz2UGvbPkWHyLXn dcfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ZJzeBd3F; 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 bc27si6587232edb.331.2021.02.22.06.27.27; Mon, 22 Feb 2021 06:27:49 -0800 (PST) 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=ZJzeBd3F; 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 S232633AbhBVOX6 (ORCPT + 99 others); Mon, 22 Feb 2021 09:23:58 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32072 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231982AbhBVONx (ORCPT ); Mon, 22 Feb 2021 09:13:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1614003146; 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=C4ob/HwZY6JToPa6OIARFnOVuWbb8EWH4Jtjs9jshMI=; b=ZJzeBd3FVu9OByQEluSXqLAxIaaA+l8rj3B7FAUNatpqBwKy5wI7Ak6GGvRUxbLDT9EsYc pJWPkcz9eTGJGPBhHDMGuBu7t4DHMxM2w8Wune7o4q6umXgKkEYMWe7rubfC9HrvXtM9qU 7FzrvRRnrY47BlS6D/5s3Dx4w4zR7Uo= Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-275-Qbm7owRRPHGd4HXjpaXsmw-1; Mon, 22 Feb 2021 09:12:24 -0500 X-MC-Unique: Qbm7owRRPHGd4HXjpaXsmw-1 Received: by mail-wr1-f71.google.com with SMTP id j12so554775wrt.9 for ; Mon, 22 Feb 2021 06:12:23 -0800 (PST) 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=C4ob/HwZY6JToPa6OIARFnOVuWbb8EWH4Jtjs9jshMI=; b=OpRjqZT3promThODSW/Gs3eosdUwmecIb0tMG4X3IAeQgXcRDQMjimRXoVrynQelfT m6ATW3rc4gR+COb4z9a/v7dtsvnsxskySx00TobCY8s2u0TJL0WnsNmshtcRA0GmHoop vLXeDkxVgvl8bfZ1rypwoQx8XmXapMx0BpFue6PT8DeL7qmpusNEqwYIAsSYMK5docj7 KTBlUJKboC6Gw9F6FYA62DZo77rtGZdBSgv2+XbEoLX7aSS+5sjwdShLks1Xsf2xdu7K wEmN4gnQggNMHSdrbisznwmP6t+COIWqJ3KtCnGW3OzA16NHrFkpx2lAqfM8ZsIbj+DW 7gzQ== X-Gm-Message-State: AOAM532R+Vt8fEraP7Ic5B6N0PeNFFkfhbzkhvedadQfCv7ryHkissBI /iIFwI6MQ1u8u3npSvjfpRz04ew5KS2Qc+JhI4Qg+0wSkcphX0Vr2GVgWjq8nnck4LUxmTl+mfj pJFz8ike1iJjbPyN4uwuHatUC X-Received: by 2002:a5d:5441:: with SMTP id w1mr21614570wrv.366.1614003142875; Mon, 22 Feb 2021 06:12:22 -0800 (PST) X-Received: by 2002:a5d:5441:: with SMTP id w1mr21614537wrv.366.1614003142640; Mon, 22 Feb 2021 06:12:22 -0800 (PST) Received: from steredhat (host-79-34-249-199.business.telecomitalia.it. [79.34.249.199]) by smtp.gmail.com with ESMTPSA id i1sm25218726wmq.12.2021.02.22.06.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Feb 2021 06:12:22 -0800 (PST) Date: Mon, 22 Feb 2021 15:12:19 +0100 From: Stefano Garzarella To: Arseny Krasnov Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Andra Paraschiv , Norbert Slusarek , Colin Ian King , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, stsp2@yandex.ru, oxffffaa@gmail.com Subject: Re: [RFC PATCH v5 07/19] af_vsock: rest of SEQPACKET support Message-ID: <20210222141219.nvw4323sizvsud5d@steredhat> References: <20210218053347.1066159-1-arseny.krasnov@kaspersky.com> <20210218053831.1067678-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20210218053831.1067678-1-arseny.krasnov@kaspersky.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 18, 2021 at 08:38:28AM +0300, Arseny Krasnov wrote: >This does rest of SOCK_SEQPACKET support: >1) Adds socket ops for SEQPACKET type. >2) Allows to create socket with SEQPACKET type. > >Signed-off-by: Arseny Krasnov >--- > net/vmw_vsock/af_vsock.c | 36 +++++++++++++++++++++++++++++++++++- > 1 file changed, 35 insertions(+), 1 deletion(-) > >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index f352cd9d91ce..f4b02c6d35d1 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -452,6 +452,7 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > new_transport = transport_dgram; > break; > case SOCK_STREAM: >+ case SOCK_SEQPACKET: > if (vsock_use_local_transport(remote_cid)) > new_transport = transport_local; > else if (remote_cid <= VMADDR_CID_HOST || !transport_h2g || >@@ -484,6 +485,14 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > if (!new_transport || !try_module_get(new_transport->module)) > return -ENODEV; > >+ if (sk->sk_type == SOCK_SEQPACKET) { >+ if (!new_transport->seqpacket_seq_send_len || >+ !new_transport->seqpacket_seq_send_eor || >+ !new_transport->seqpacket_seq_get_len || >+ !new_transport->seqpacket_dequeue) We must release the module reference acquired above: module_put(new_transport->module); >+ return -ESOCKTNOSUPPORT; >+ } >+ > ret = new_transport->init(vsk, psk); > if (ret) { > module_put(new_transport->module); >@@ -684,6 +693,7 @@ static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr) > > switch (sk->sk_socket->type) { > case SOCK_STREAM: >+ case SOCK_SEQPACKET: > spin_lock_bh(&vsock_table_lock); > retval = __vsock_bind_connectible(vsk, addr); > spin_unlock_bh(&vsock_table_lock); >@@ -769,7 +779,7 @@ static struct sock *__vsock_create(struct net *net, > > static bool sock_type_connectible(u16 type) > { >- return type == SOCK_STREAM; >+ return (type == SOCK_STREAM) || (type == SOCK_SEQPACKET); > } > > static void __vsock_release(struct sock *sk, int level) >@@ -2191,6 +2201,27 @@ static const struct proto_ops vsock_stream_ops = { > .sendpage = sock_no_sendpage, > }; > >+static const struct proto_ops vsock_seqpacket_ops = { >+ .family = PF_VSOCK, >+ .owner = THIS_MODULE, >+ .release = vsock_release, >+ .bind = vsock_bind, >+ .connect = vsock_connect, >+ .socketpair = sock_no_socketpair, >+ .accept = vsock_accept, >+ .getname = vsock_getname, >+ .poll = vsock_poll, >+ .ioctl = sock_no_ioctl, >+ .listen = vsock_listen, >+ .shutdown = vsock_shutdown, >+ .setsockopt = vsock_connectible_setsockopt, >+ .getsockopt = vsock_connectible_getsockopt, >+ .sendmsg = vsock_connectible_sendmsg, >+ .recvmsg = vsock_connectible_recvmsg, >+ .mmap = sock_no_mmap, >+ .sendpage = sock_no_sendpage, >+}; >+ > static int vsock_create(struct net *net, struct socket *sock, > int protocol, int kern) > { >@@ -2211,6 +2242,9 @@ static int vsock_create(struct net *net, struct socket *sock, > case SOCK_STREAM: > sock->ops = &vsock_stream_ops; > break; >+ case SOCK_SEQPACKET: >+ sock->ops = &vsock_seqpacket_ops; >+ break; > default: > return -ESOCKTNOSUPPORT; > } >-- >2.25.1 >