Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1170636pxj; Sat, 8 May 2021 09:34:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzahrNYPu2ryq7IepBlia7CE/XVf66QZ//5pYDhlDPLZ6ryH+G9qkz16RJR8xYzVDaUkSB+ X-Received: by 2002:a17:906:79c8:: with SMTP id m8mr16709912ejo.260.1620491659142; Sat, 08 May 2021 09:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620491659; cv=none; d=google.com; s=arc-20160816; b=ajtOO+602zoUhTxvhvVdu6YbuTM9wpj75Ds3DjzH+ZL9mSCTH7eOv/neF9j+yHLJVs vDkpb/edTNjNFi+jEo5qgjhz1Bk7wtf8f9h+8DX97ueorF7Bl1llVdhlORbEAo+65O+4 B46jgNm/it877SwpPO4XiL1JD2DQmunEjf1g/rrXc2Mhh4/y2MwobjW2LBb3B6MKBKfs pIwoDgMIp2Ww0YHLMY+2vE2l5z/pv7dEtTTJC2JCJ4eEbG2XuUtCSeRyimzSJZAVQSCC GldUqGFRXKPeCGDgVVTtWUj/eKDvZBZCnRkuGgdL6sTRwUuc7TCSp1JtyN8954AxNBq2 Ijtg== 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=O2X8HgczlbY3D5QaoIUjuA/wlpLEw+fTp5ccpcFwpck=; b=g+ytodGpwdYdwT1+gT48JTQO9ckPgOX5+A8uC5aYnkSAHbey59Vpss7LdeyLukgGba J2hUVAQUyrMx5F6NmYu91vM7OPRes7MJkWdoniVwVTk8umfZgHM1wsMjvLm58pgm9Tnc Y+G8eqSAO5g3mXfFnEAQCq+ocDG/iVrkGLI2CBY6YEgsFTfleINUa2jnJIk8NiweueGN SVHeLKlgyw1CC2D74HlIjHBlB+oIGnPK01Fx9N0/dXzWpQ1WLBreF+yq8kPgK7m7G9Da zIUjLvpbytDyQL1DCxrmQZ4gzngoaIY0kWWZo58WOFHwnB7gEewFGIq/jpGJR+73mg2s 7jZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kaspersky.com header.s=mail202102 header.b="5/MKreaD"; 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 y15si8359597edm.338.2021.05.08.09.33.55; Sat, 08 May 2021 09:34:19 -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=@kaspersky.com header.s=mail202102 header.b="5/MKreaD"; 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 S229739AbhEHQdq (ORCPT + 99 others); Sat, 8 May 2021 12:33:46 -0400 Received: from mx13.kaspersky-labs.com ([91.103.66.164]:62453 "EHLO mx13.kaspersky-labs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbhEHQdp (ORCPT ); Sat, 8 May 2021 12:33:45 -0400 Received: from relay13.kaspersky-labs.com (unknown [127.0.0.10]) by relay13.kaspersky-labs.com (Postfix) with ESMTP id C48A6520FF0; Sat, 8 May 2021 19:32:37 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaspersky.com; s=mail202102; t=1620491557; bh=O2X8HgczlbY3D5QaoIUjuA/wlpLEw+fTp5ccpcFwpck=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=5/MKreaDhaWdwfiwEdOMwq4MLfhdVXQz2RTxUj557GW8MS7J6D4sgpFgaghwIcrwc n5ImauVdi6c+saGasvx9VP2+aHKCHJqfPaH0O1qAAlo2i0hDt1ga5y8i99glGsKPrd f5De10K7Wh2J6LVwRjLamiAiorATwakltk7K0UfT5XfReBiCY374w8OOiunUKTORVC vmgOCfUI1UFqskkHzXfsuMVtEkQSo0WN4akuqgIA4PxmGGTIyOeCTQEy7X7cKI9kbS nqElzGHtbtFGKmfM0/8/Ow+7Y4dluzSsinhFuq6aF9jI+CleIfJVVs+JibnKOcQmEA BnjrXSc7HZaRQ== 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 09698520F1A; Sat, 8 May 2021 19:32:36 +0300 (MSK) Received: from arseniy-pc.avp.ru (10.64.68.129) 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.2176.2; Sat, 8 May 2021 19:32:36 +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 , Norbert Slusarek CC: , , , , , Subject: [RFC PATCH v9 01/19] af_vsock: update functions for connectible socket Date: Sat, 8 May 2021 19:32:14 +0300 Message-ID: <20210508163217.3430707-1-arseny.krasnov@kaspersky.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210508163027.3430238-1-arseny.krasnov@kaspersky.com> References: <20210508163027.3430238-1-arseny.krasnov@kaspersky.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.64.68.129] 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.20, Database issued on: 05/08/2021 16:21:10 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 10 X-KSE-AntiSpam-Info: Lua profiles 163552 [May 08 2021] X-KSE-AntiSpam-Info: Version: 5.9.20.0 X-KSE-AntiSpam-Info: Envelope from: arseny.krasnov@kaspersky.com X-KSE-AntiSpam-Info: LuaCore: 445 445 d5f7ae5578b0f01c45f955a2a751ac25953290c9 X-KSE-AntiSpam-Info: {Prob_from_in_msgid} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: 127.0.0.199:7.1.2;arseniy-pc.avp.ru:7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;kaspersky.com:7.1.1 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: 05/08/2021 16:24: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: 08.05.2021 12:32: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/05/08 15:50:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2021/05/08 12:32:00 #16600610 X-KLMS-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This prepares af_vsock.c for SEQPACKET support: some functions such as setsockopt(), getsockopt(), connect(), recvmsg(), sendmsg() are shared between both types of sockets, so rename them in general manner. Signed-off-by: Arseny Krasnov Reviewed-by: Stefano Garzarella --- net/vmw_vsock/af_vsock.c | 64 +++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 30 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 92a72f0e0d94..7dd8e70d78cd 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -604,8 +604,8 @@ static void vsock_pending_work(struct work_struct *work) /**** SOCKET OPERATIONS ****/ -static int __vsock_bind_stream(struct vsock_sock *vsk, - struct sockaddr_vm *addr) +static int __vsock_bind_connectible(struct vsock_sock *vsk, + struct sockaddr_vm *addr) { static u32 port; struct sockaddr_vm new_addr; @@ -685,7 +685,7 @@ static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr) switch (sk->sk_socket->type) { case SOCK_STREAM: spin_lock_bh(&vsock_table_lock); - retval = __vsock_bind_stream(vsk, addr); + retval = __vsock_bind_connectible(vsk, addr); spin_unlock_bh(&vsock_table_lock); break; @@ -768,6 +768,11 @@ static struct sock *__vsock_create(struct net *net, return sk; } +static bool sock_type_connectible(u16 type) +{ + return type == SOCK_STREAM; +} + static void __vsock_release(struct sock *sk, int level) { if (sk) { @@ -786,7 +791,7 @@ static void __vsock_release(struct sock *sk, int level) if (vsk->transport) vsk->transport->release(vsk); - else if (sk->sk_type == SOCK_STREAM) + else if (sock_type_connectible(sk->sk_type)) vsock_remove_sock(vsk); sock_orphan(sk); @@ -948,7 +953,7 @@ static int vsock_shutdown(struct socket *sock, int mode) lock_sock(sk); if (sock->state == SS_UNCONNECTED) { err = -ENOTCONN; - if (sk->sk_type == SOCK_STREAM) + if (sock_type_connectible(sk->sk_type)) goto out; } else { sock->state = SS_DISCONNECTING; @@ -961,7 +966,7 @@ static int vsock_shutdown(struct socket *sock, int mode) sk->sk_shutdown |= mode; sk->sk_state_change(sk); - if (sk->sk_type == SOCK_STREAM) { + if (sock_type_connectible(sk->sk_type)) { sock_reset_flag(sk, SOCK_DONE); vsock_send_shutdown(sk, mode); } @@ -1016,7 +1021,7 @@ static __poll_t vsock_poll(struct file *file, struct socket *sock, if (!(sk->sk_shutdown & SEND_SHUTDOWN)) mask |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; - } else if (sock->type == SOCK_STREAM) { + } else if (sock_type_connectible(sk->sk_type)) { const struct vsock_transport *transport; lock_sock(sk); @@ -1263,8 +1268,8 @@ static void vsock_connect_timeout(struct work_struct *work) sock_put(sk); } -static int vsock_stream_connect(struct socket *sock, struct sockaddr *addr, - int addr_len, int flags) +static int vsock_connect(struct socket *sock, struct sockaddr *addr, + int addr_len, int flags) { int err; struct sock *sk; @@ -1414,7 +1419,7 @@ static int vsock_accept(struct socket *sock, struct socket *newsock, int flags, lock_sock(listener); - if (sock->type != SOCK_STREAM) { + if (!sock_type_connectible(sock->type)) { err = -EOPNOTSUPP; goto out; } @@ -1491,7 +1496,7 @@ static int vsock_listen(struct socket *sock, int backlog) lock_sock(sk); - if (sock->type != SOCK_STREAM) { + if (!sock_type_connectible(sk->sk_type)) { err = -EOPNOTSUPP; goto out; } @@ -1535,11 +1540,11 @@ static void vsock_update_buffer_size(struct vsock_sock *vsk, vsk->buffer_size = val; } -static int vsock_stream_setsockopt(struct socket *sock, - int level, - int optname, - sockptr_t optval, - unsigned int optlen) +static int vsock_connectible_setsockopt(struct socket *sock, + int level, + int optname, + sockptr_t optval, + unsigned int optlen) { int err; struct sock *sk; @@ -1617,10 +1622,10 @@ static int vsock_stream_setsockopt(struct socket *sock, return err; } -static int vsock_stream_getsockopt(struct socket *sock, - int level, int optname, - char __user *optval, - int __user *optlen) +static int vsock_connectible_getsockopt(struct socket *sock, + int level, int optname, + char __user *optval, + int __user *optlen) { int err; int len; @@ -1688,8 +1693,8 @@ static int vsock_stream_getsockopt(struct socket *sock, return 0; } -static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, - size_t len) +static int vsock_connectible_sendmsg(struct socket *sock, struct msghdr *msg, + size_t len) { struct sock *sk; struct vsock_sock *vsk; @@ -1828,10 +1833,9 @@ static int vsock_stream_sendmsg(struct socket *sock, struct msghdr *msg, return err; } - static int -vsock_stream_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, - int flags) +vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, + int flags) { struct sock *sk; struct vsock_sock *vsk; @@ -2007,7 +2011,7 @@ static const struct proto_ops vsock_stream_ops = { .owner = THIS_MODULE, .release = vsock_release, .bind = vsock_bind, - .connect = vsock_stream_connect, + .connect = vsock_connect, .socketpair = sock_no_socketpair, .accept = vsock_accept, .getname = vsock_getname, @@ -2015,10 +2019,10 @@ static const struct proto_ops vsock_stream_ops = { .ioctl = sock_no_ioctl, .listen = vsock_listen, .shutdown = vsock_shutdown, - .setsockopt = vsock_stream_setsockopt, - .getsockopt = vsock_stream_getsockopt, - .sendmsg = vsock_stream_sendmsg, - .recvmsg = vsock_stream_recvmsg, + .setsockopt = vsock_connectible_setsockopt, + .getsockopt = vsock_connectible_getsockopt, + .sendmsg = vsock_connectible_sendmsg, + .recvmsg = vsock_connectible_recvmsg, .mmap = sock_no_mmap, .sendpage = sock_no_sendpage, }; -- 2.25.1