Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp7013768pxb; Wed, 17 Feb 2021 21:50:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJyYM6rP6gf8y1sUV4wAqU8unriRwLk5Lc31HTlZa4/1WqgGHZnu2gVAsFV8JBmOJ6LY5apV X-Received: by 2002:a05:6402:304f:: with SMTP id bu15mr2395467edb.259.1613627458180; Wed, 17 Feb 2021 21:50:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613627458; cv=none; d=google.com; s=arc-20160816; b=ZmRf2dNHwvunhJI2Or2VtF5qjYFsbrqbU1fV0LrUXWVMkaSAky0EREQFFg0TzeKFHM IZWgQzEbkjKpYoAJmEMMmXy9ksw2t98sV7k4fp/f+cHI+2/6WfXnon7GR7SxMo7CRi3p lC9mzCM4d0P7P2jaAX+C/xQJIj250ShdboPAEtAuSmuJG4WMMLByva3qHgIlgUGwRhab oq5bYJczvgwwLhqyKr3iwaSrT85l0oiWEMjLu8TJfUzaOuPVxtAcH6Z5nAvNcuoAjOOa XOQN75ii8oJ5inNlDjrOxmKufpZvVamNN1dkbz2ufQ0iuSqtIEfbSfYnpeqHWB1B6pyZ lhUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9w750HnDFoE6S43pBuMem2EUpOJULOR98eyRQlp41ck=; b=YJiniFIcC022Ljz+MyBzjkIrTh5zJPGNSbylVod4kwsymq0kx2wliMOsgA4ouyp6WF oZT29pLXehazNskTQDHTmD/WHencjeMuLW97JgI62qCKR53wKwLQeaveaDHmcbdiD1SN z7pFY2+AXV0SCG3QSZ7uCx5d2hhMXLpq21zU6VHdbI7qcAZ7Mti5B6tuvrG9NKn2v2Lf p641+hLM+Xz3FP5ZQWtTJtX/azXus8FioKfhA2tHwGqaTL01RM0S+5VEJh4ZuL7e6OUN gIyHXHu/EMc+MnyqXDl8VLrJIE67RDZZ8basHl8tNc6s5p0HDKoAbyYKTLatUYHk6kTh qJ1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kaspersky.com header.s=mail202102 header.b=JH3DcAU2; 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=REJECT sp=REJECT dis=NONE) header.from=kaspersky.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t1si2822135ejd.359.2021.02.17.21.50.29; Wed, 17 Feb 2021 21:50:58 -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=@kaspersky.com header.s=mail202102 header.b=JH3DcAU2; 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=REJECT sp=REJECT dis=NONE) header.from=kaspersky.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231650AbhBRFsV (ORCPT + 99 others); Thu, 18 Feb 2021 00:48:21 -0500 Received: from mx13.kaspersky-labs.com ([91.103.66.164]:44828 "EHLO mx13.kaspersky-labs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230368AbhBRFkj (ORCPT ); Thu, 18 Feb 2021 00:40:39 -0500 Received: from relay13.kaspersky-labs.com (unknown [127.0.0.10]) by relay13.kaspersky-labs.com (Postfix) with ESMTP id 6E48B5214DE; Thu, 18 Feb 2021 08:38:43 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaspersky.com; s=mail202102; t=1613626723; bh=9w750HnDFoE6S43pBuMem2EUpOJULOR98eyRQlp41ck=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=JH3DcAU2/qdYCScip2lbE8fuH2CRDKuVWvGbwEXNKLIroZ9FpF/4bboYxoP3WaAZL Xgm5tR8czNENvcAVClCQtpTwTvqeWmkExDUANbRFRhYfivciHzojWRLPz7bMraVJ3D 5OmpqmAjWjYhTbRhqauaU3AiDjiEEw7CkY4ZsZWt/w2K+5WAZOfiEZpNWyBgAYZ1dA 85/LtnTAY4hVGey73VElF91+y3YlYxQDc/55eZ8rzxriYYIL4CV6+YFzSne+aEqc20 Y5FkuaZ0XR2FL9UuzuFn1F0GbZxoU/RyoiNhPlrgCK0UadRClobscb/Rz3dU0yQUTh 9Fpb/TUGOfFtg== Received: from mail-hq2.kaspersky.com (unknown [91.103.66.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client CN "mail-hq2.kaspersky.com", Issuer "Kaspersky MailRelays CA G3" (verified OK)) by mailhub13.kaspersky-labs.com (Postfix) with ESMTPS id DFD7852146C; Thu, 18 Feb 2021 08:38:42 +0300 (MSK) Received: from arseniy-pc.avp.ru (10.64.68.128) by hqmailmbx3.avp.ru (10.64.67.243) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2044.4; Thu, 18 Feb 2021 08:38:37 +0300 From: Arseny Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Arseny Krasnov , Jorgen Hansen , Andra Paraschiv , Norbert Slusarek , Colin Ian King CC: , , , , , Subject: [RFC PATCH v5 07/19] af_vsock: rest of SEQPACKET support Date: Thu, 18 Feb 2021 08:38:28 +0300 Message-ID: <20210218053831.1067678-1-arseny.krasnov@kaspersky.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210218053347.1066159-1-arseny.krasnov@kaspersky.com> References: <20210218053347.1066159-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.64.68.128] X-ClientProxiedBy: hqmailmbx3.avp.ru (10.64.67.243) To hqmailmbx3.avp.ru (10.64.67.243) X-KSE-ServerInfo: hqmailmbx3.avp.ru, 9 X-KSE-AntiSpam-Interceptor-Info: scan successful X-KSE-AntiSpam-Version: 5.9.16, Database issued on: 02/06/2021 23:52:08 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 10 X-KSE-AntiSpam-Info: Lua profiles 161679 [Feb 06 2021] X-KSE-AntiSpam-Info: LuaCore: 422 422 763e61bea9fcfcd94e075081cb96e065bc0509b4 X-KSE-AntiSpam-Info: Version: 5.9.16.0 X-KSE-AntiSpam-Info: Envelope from: arseny.krasnov@kaspersky.com X-KSE-AntiSpam-Info: {Prob_from_in_msgid} X-KSE-AntiSpam-Info: {Tracking_date, moscow} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: Rate: 10 X-KSE-AntiSpam-Info: Status: not_detected X-KSE-AntiSpam-Info: Method: none X-KSE-Antiphishing-Info: Clean X-KSE-Antiphishing-ScanningType: Deterministic X-KSE-Antiphishing-Method: None X-KSE-Antiphishing-Bases: 02/06/2021 23:55:00 X-KSE-AttachmentFiltering-Interceptor-Info: no applicable attachment filtering rules found X-KSE-Antivirus-Interceptor-Info: scan successful X-KSE-Antivirus-Info: Clean, bases: 06.02.2021 21:17:00 X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit X-KSE-AttachmentFiltering-Interceptor-Info: no applicable attachment filtering rules found X-KSE-BulkMessagesFiltering-Scan-Result: InTheLimit X-KLMS-Rule-ID: 52 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Status: not scanned, disabled by settings X-KLMS-AntiSpam-Interceptor-Info: not scanned X-KLMS-AntiPhishing: Clean, bases: 2021/02/18 04:51:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2021/02/18 04:31:00 #16269527 X-KLMS-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) + 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