Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp4231535pxf; Tue, 23 Mar 2021 06:11:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyq1cy87m5Fx7WkTSViYJDBUqRmDF7XxRDqk9UA0qMQ2bJWYRAflZ+/2eJLAqXgCGHTK1Yz X-Received: by 2002:a17:906:d8c6:: with SMTP id re6mr4672348ejb.311.1616505070716; Tue, 23 Mar 2021 06:11:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1616505070; cv=none; d=google.com; s=arc-20160816; b=fvhEabtky+Ho/TckHt+6N/G0gNvWZzfTB2WuggnAjxBRpkMFcALCEzVXt88OSHqlr+ Q4Fxp0t5KGZLSTGCt5skXwjVUzoNswJCrhJBarmjT9XtSAasHIkU6BJZ4HI/NcKy3Z2e z3D7iu8LAS/sSICafNv/lKnvmwHJ0ZYcYpv2F+hmJFasvj/DAOvJqM59yaPOxEKvfo8I 1QRngxWhkVkxzQVwy1wGKJBtPZHdmRDccqJf9L9Hb16loaKZuZaQmi5/NcjGJ84BQmk1 0e2eqVrzxrJ4/vz+4OFgf7Mwb5wZ/JP0xGkZ6KL67vDNBfNU1NXwbuVvNmUvMw6kgf4L vWCQ== 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=6mKRrts4oV1cKdQ+DaGsBJr6pu1G5LW75JbNv3Kmwqg=; b=MJ4bxvhxJjD1L8u7aF+f1GzSkZVD63QOlOzSLZ+1/crIaYvhkvXvlXmQuBzYF6kx9f nPrLmxYqaeYgD7bbn5mOwQHXPXFAg4H9K5G0WZZpe7olwO0NoMFBE7nCYO0Xx+LXrP0k 7K4af2jwfFvw4Cqe6PY5NcfITbBkr5sbXTrT+0uGK6RvXf3WLPGW3+89sWIo/bNDkthk 8r6HpY+KMAKjaAIeBCZbZ5ReLkum57Ya5GrcmSCH+3FKy0QSH4/pkdzoZiJ/4vn7vfMk 23wdSLwBx3unaKRxRTwwotDbxodOXB10aIvDbUx5sbI/Ru5iGE1cNEJBJozEIJtMccwT Hu2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kaspersky.com header.s=mail202102 header.b=DaD764uK; 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 y21si13725799edo.16.2021.03.23.06.10.44; Tue, 23 Mar 2021 06:11: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=@kaspersky.com header.s=mail202102 header.b=DaD764uK; 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 S231362AbhCWNJj (ORCPT + 99 others); Tue, 23 Mar 2021 09:09:39 -0400 Received: from mx13.kaspersky-labs.com ([91.103.66.164]:46337 "EHLO mx13.kaspersky-labs.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231411AbhCWNJP (ORCPT ); Tue, 23 Mar 2021 09:09:15 -0400 Received: from relay13.kaspersky-labs.com (unknown [127.0.0.10]) by relay13.kaspersky-labs.com (Postfix) with ESMTP id 03B845216B8; Tue, 23 Mar 2021 16:09:08 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kaspersky.com; s=mail202102; t=1616504948; bh=6mKRrts4oV1cKdQ+DaGsBJr6pu1G5LW75JbNv3Kmwqg=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=DaD764uK8T+l9GWWfGDao2R2g+us7zE1yRZ/XosnPC1rQlfchzWGyNG5VOz+h8fbv s3jectlkVuYhFtaeKzaBEtrGC5oK01J7vq7ECwJdbtiChME5qw9fs6Xr7sCHTxTWsh nFK99r3p9LlhVt6pVQBo12Kq8tBFeCQkIvUsaW4nWbkP+EuvwuKXqsli1qMR1s8ijL cm1qD5LxnvOPVUjnt2hhUNh1mR3uuOm3jjXmvnGeW2+b+XOzv9Z6un8E/hJOIvxtlp wZEUahj3nQCdEG5EZNRLWfkes0q8cp78YhT++7wGo7KPjZzDS0OhC3VdkNWP1zxrTL HkS18WNFxrlPw== 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 20DE9521708; Tue, 23 Mar 2021 16:09:07 +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.2176.2; Tue, 23 Mar 2021 16:09:06 +0300 From: Arseny Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "Michael S. Tsirkin" , Jason Wang , "David S. Miller" , Jakub Kicinski , Jorgen Hansen , Andra Paraschiv , Colin Ian King , Norbert Slusarek , Jeff Vander Stoep , Alexander Popov CC: , , , , , , Subject: [RFC PATCH v7 01/22] af_vsock: update functions for connectible socket Date: Tue, 23 Mar 2021 16:08:34 +0300 Message-ID: <20210323130837.2459550-1-arseny.krasnov@kaspersky.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210323130716.2459195-1-arseny.krasnov@kaspersky.com> References: <20210323130716.2459195-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.20, Database issued on: 03/23/2021 12:55:25 X-KSE-AntiSpam-Status: KAS_STATUS_NOT_DETECTED X-KSE-AntiSpam-Method: none X-KSE-AntiSpam-Rate: 10 X-KSE-AntiSpam-Info: Lua profiles 162595 [Mar 23 2021] X-KSE-AntiSpam-Info: LuaCore: 437 437 85ecb8eec06a7bf2f475f889e784f42bce7b4445 X-KSE-AntiSpam-Info: Version: 5.9.20.0 X-KSE-AntiSpam-Info: Envelope from: arseny.krasnov@kaspersky.com X-KSE-AntiSpam-Info: {Prob_from_in_msgid} X-KSE-AntiSpam-Info: {Tracking_from_domain_doesnt_match_to} X-KSE-AntiSpam-Info: d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;arseniy-pc.avp.ru:7.1.1;127.0.0.199:7.1.2;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: 03/23/2021 12:58: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: 23.03.2021 11:46: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/03/23 11:43:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2021/03/23 11:40:00 #16480199 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 5546710d8ac1..656370e11707 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; @@ -767,6 +767,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) { @@ -785,7 +790,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); @@ -947,7 +952,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; @@ -960,7 +965,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); } @@ -1015,7 +1020,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); @@ -1262,8 +1267,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; @@ -1413,7 +1418,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; } @@ -1490,7 +1495,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; } @@ -1534,11 +1539,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; @@ -1616,10 +1621,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; @@ -1687,8 +1692,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; @@ -1827,10 +1832,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; @@ -2006,7 +2010,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, @@ -2014,10 +2018,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