Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3379079pxb; Sun, 7 Feb 2021 07:20:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9xJlhq8UJ14mpb+9cwMxxTywgBDnqFhBNC3sCIYWowA0oa97VuNkGV6ySz7+6Gn8XoSO8 X-Received: by 2002:a05:6402:5112:: with SMTP id m18mr13215145edd.129.1612711240544; Sun, 07 Feb 2021 07:20:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612711240; cv=none; d=google.com; s=arc-20160816; b=xQmA79hRk0AoecKUimSciGcTHQV7iOCfiw4ai1muCgKnUOTyfI+WlIJ/Xxk7kPNTwY Hd49IBEarHDgeiGtym6mT99HjBr5a55VWZZ8G3u8lx+L+cTUi+1Fq1eyXywEzIhAa+9B KhpNlomGtTMbaD57vlf1Hk9vlVqyuT6zGBFQ+QcSydQLGx0qwxs8qny0+9qnWVoHY1i7 fYyF1BI8115m5UgER5Rjqwy2uXDjBIwRObvQtjLk4u1dLdeXRpnqQ7+0/lIBF6swxlO0 DjWfoAj2jEJXuGIPnVWCsHwJ5PT7bqEo2HXQocBQCxwzHduefRha/HXhdAh8HJTXDcLt sIqA== 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=FfBBfXASkTvTmHKKEvE6DlRSJPgFYIOqDw2pyr6S14M=; b=0aUQKWe10twLSR6mQe6bYZGG1rUbpFmxHt/9UoyF2HpK3OuHRG4mRMpe1xz3FKgWby mRdSC8Ms397+DBoRl6rnI0WhOhdnaDtuWBveDn133pu5S9ZCW7C5nFT63FnMKTy6eeeo A5bf44OKbM3MjUNUdGQoYh75VCiTioKJSWWf5EK85BPks/lB+MBHovDgzmtobBHj6KR2 Ax/GMNc2IdwHgOXNIhZNk2hkE+cXZkj6l27TOYEY6G+7JOxxRNUkmXwvRXp1d9BfcDCE k58eavvmEvuqw6fdUIHTK9Wmsu9Co1RcHbAiN2ZoxE2wKsJ+V3d9M8Pg7/M21YMgihIi dUug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kaspersky.com header.s=mail header.b=SJOkMi1i; 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 x5si9077769ejv.626.2021.02.07.07.20.16; Sun, 07 Feb 2021 07:20:40 -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=mail header.b=SJOkMi1i; 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 S230186AbhBGPTD (ORCPT + 99 others); Sun, 7 Feb 2021 10:19:03 -0500 Received: from mx12.kaspersky-labs.com ([91.103.66.155]:12969 "EHLO mx12.kaspersky-labs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229939AbhBGPRS (ORCPT ); Sun, 7 Feb 2021 10:17:18 -0500 Received: from relay12.kaspersky-labs.com (unknown [127.0.0.10]) by relay12.kaspersky-labs.com (Postfix) with ESMTP id 4D23676587; Sun, 7 Feb 2021 18:16:24 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaspersky.com; s=mail; t=1612710984; bh=FfBBfXASkTvTmHKKEvE6DlRSJPgFYIOqDw2pyr6S14M=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=SJOkMi1ioLiqbzdDq619tWGQjHe6EHFW8wLiilub36HB+88LMyTnM9M2QKaax0a4S uudNxzPFjld3Ar5TOCc5GpdRB7CAnSvd32BEQwbWRgAou8NamimmZbPSRy8gO3Ufdc BGCV+nps33soN+xQFCjJG33fcsNA4Tg9NSRJ3ugU= 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 mailhub12.kaspersky-labs.com (Postfix) with ESMTPS id 1A4EC76595; Sun, 7 Feb 2021 18:16:24 +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; Sun, 7 Feb 2021 18:16:23 +0300 From: Arseny Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Arseny Krasnov , Jorgen Hansen , Colin Ian King , Andra Paraschiv , Jeff Vander Stoep CC: , , , , , Subject: [RFC PATCH v4 07/17] af_vsock: rest of SEQPACKET support Date: Sun, 7 Feb 2021 18:16:12 +0300 Message-ID: <20210207151615.805115-1-arseny.krasnov@kaspersky.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210207151259.803917-1-arseny.krasnov@kaspersky.com> References: <20210207151259.803917-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: hqmailmbx2.avp.ru (10.64.67.242) 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: 2/6/2021 9:17:00 PM 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/07 14:21:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2021/02/07 10:49:00 #16133380 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 | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index a033d3340ac4..c77998a14018 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 || @@ -459,6 +460,15 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) new_transport = transport_g2h; else new_transport = transport_h2g; + + if (sk->sk_type == SOCK_SEQPACKET) { + if (!new_transport || + !new_transport->seqpacket_seq_send_len || + !new_transport->seqpacket_seq_send_eor || + !new_transport->seqpacket_seq_get_len || + !new_transport->seqpacket_dequeue) + return -ESOCKTNOSUPPORT; + } break; default: return -ESOCKTNOSUPPORT; @@ -684,6 +694,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 +780,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) @@ -2199,6 +2210,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) { @@ -2219,6 +2251,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