Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp2764186rdb; Fri, 22 Sep 2023 07:50:36 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHff8KOhXJ8FN+NJGCU1jaFuU2L0aDx+j0dGT44lAJjQjRy3vCSUTqpqNZMhNFiDGQd8OBd X-Received: by 2002:a05:6808:6da:b0:3a7:540f:ca96 with SMTP id m26-20020a05680806da00b003a7540fca96mr8010475oih.4.1695394236362; Fri, 22 Sep 2023 07:50:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695394236; cv=none; d=google.com; s=arc-20160816; b=nCbJOW1QabF1UEz90aPXokLpGF1x8p2zJPTHdTWmWW6PCV+/549IK4aJ1BfE/KEU1L JiGRlB16NFy6WEDOxM2CJ8S98PcZmGmtQ7rPqejxRjuu3fDtc7eq4QJkZe/yHWZYis5f F1dAI+40ZhqygklH3Efm+sA31u20VNP0aZNCVkn40rWjjM6v3Cjb4DRfhnQXo3ZEZoSt 7ae1bqh+0TsOvFqfUrepxxU0T2RPECsn5aC0mrFb4PXKSbwVU+owu17AIOrau93XXVlq W9z4DBJlyjTtV3hH8MVHQ5dVXO4H4FnIaK3gvOC6j8aqaK+nJsbmDET5le3492NAViQe MYMw== 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:dkim-filter; bh=ucQ5J3kddO4tOPd0QjgadrTOZY9KNSh2ycNCTudGEcI=; fh=wIHqZpOIuzcidDZ82yQbOZuyHJty7uvaWDEh/efoVzA=; b=WP7o1AgsO+UlJNyRv5UOwu9ugfo/9LyuafPf6hC0MYyKxUifsurZ6463Qj/VG2jdGz Ya36xu7jbKnVriTmHFCdVj/FcJreICmRX15dT0sNssJLjrgkfaFtjDLBr3JnUqBH8i4M kz3hyr0QObdtdpDhTgR2XSboPfSdpzSjH6BeoFn9fPQ1LWd0Rl81lEJAfqLaOWCXZ2KD PSm22YaBYbx7Oo32w8pPT+eA5JP8XTiG+lSdLbFNneKvlBV7MYPpY/udDY0+BJ/KXN+b GSGh+nv/Z/yjpyPoVNlQhYFwd2x9LlaNkMptlWGgFdcDrslMEKNj9sVgWvenIhDBCkP/ SSPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=JjtoSWde; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id m65-20020a633f44000000b00578d016422esi3938619pga.821.2023.09.22.07.50.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Sep 2023 07:50:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@salutedevices.com header.s=mail header.b=JjtoSWde; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=salutedevices.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id DD1CF8377B8E; Thu, 21 Sep 2023 22:32:11 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231136AbjIVFb4 (ORCPT + 99 others); Fri, 22 Sep 2023 01:31:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229564AbjIVFbx (ORCPT ); Fri, 22 Sep 2023 01:31:53 -0400 Received: from mx1.sberdevices.ru (mx2.sberdevices.ru [45.89.224.132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 621F9196; Thu, 21 Sep 2023 22:31:45 -0700 (PDT) Received: from p-infra-ksmg-sc-msk02 (localhost [127.0.0.1]) by mx1.sberdevices.ru (Postfix) with ESMTP id 38691120008; Fri, 22 Sep 2023 08:31:43 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.sberdevices.ru 38691120008 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=salutedevices.com; s=mail; t=1695360703; bh=ucQ5J3kddO4tOPd0QjgadrTOZY9KNSh2ycNCTudGEcI=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type:From; b=JjtoSWdeQKLpSzZeVAhqK+DfPAwjAKnRAoZBcP1a94FWIqpzWQ2Dq501zu0vAB+AL DW9vYcTeZ7XVX8Qwh+vxVkhdtOHkWHbucFw0YVv+bFl/0kLkCBSNIdJl6Lki5WoxGC UFV7Mp2n8KrKTwaP8VJgQV9It8ytVTZWsPI9PquEuR3caS/vg4qVIAKpJtF0h6kq9n 7YiokoZ8A6dVR4nRnw8N3jn9lb5Na7j59dI+kkkrUKjXiYqwg3Xj//TAEewyh5yNri rVusR2Cl7FrfcmoMNXfkPrzty12WBnd22Cx0e9qQ9JKLoOW/29WkMtHllYjnNey2od bAvdkVwFrpFlQ== Received: from p-i-exch-sc-m01.sberdevices.ru (p-i-exch-sc-m01.sberdevices.ru [172.16.192.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.sberdevices.ru (Postfix) with ESMTPS; Fri, 22 Sep 2023 08:31:43 +0300 (MSK) Received: from localhost.localdomain (100.64.160.123) by p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.30; Fri, 22 Sep 2023 08:31:42 +0300 From: Arseniy Krasnov To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "Michael S. Tsirkin" , Jason Wang , Bobby Eshleman CC: , , , , , , Subject: [PATCH net-next v1 02/12] vsock: read from socket's error queue Date: Fri, 22 Sep 2023 08:24:18 +0300 Message-ID: <20230922052428.4005676-3-avkrasnov@salutedevices.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230922052428.4005676-1-avkrasnov@salutedevices.com> References: <20230922052428.4005676-1-avkrasnov@salutedevices.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [100.64.160.123] X-ClientProxiedBy: p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) To p-i-exch-sc-m01.sberdevices.ru (172.16.192.107) X-KSMG-Rule-ID: 10 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Lua-Profiles: 180033 [Sep 21 2023] X-KSMG-AntiSpam-Version: 5.9.59.0 X-KSMG-AntiSpam-Envelope-From: avkrasnov@salutedevices.com X-KSMG-AntiSpam-Rate: 0 X-KSMG-AntiSpam-Status: not_detected X-KSMG-AntiSpam-Method: none X-KSMG-AntiSpam-Auth: dkim=none X-KSMG-AntiSpam-Info: LuaCore: 534 534 808c2ea49f7195c68d40844e073217da4fa0d1e3, {Tracking_from_domain_doesnt_match_to}, 100.64.160.123:7.1.2;127.0.0.199:7.1.2;salutedevices.com:7.1.1;p-i-exch-sc-m01.sberdevices.ru:5.0.1,7.1.1;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1, FromAlignment: s, ApMailHostAddress: 100.64.160.123 X-MS-Exchange-Organization-SCL: -1 X-KSMG-AntiSpam-Interceptor-Info: scan successful X-KSMG-AntiPhishing: Clean X-KSMG-LinksScanning: Clean X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 2.0.1.6960, bases: 2023/09/22 02:22:00 #21944311 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Thu, 21 Sep 2023 22:32:12 -0700 (PDT) This adds handling of MSG_ERRQUEUE input flag in receive call. This flag is used to read socket's error queue instead of data queue. Possible scenario of error queue usage is receiving completions for transmission with MSG_ZEROCOPY flag. This patch also adds new defines: 'SOL_VSOCK' and 'VSOCK_RECVERR'. Signed-off-by: Arseniy Krasnov --- Changelog: v5(big patchset) -> v1: * R-b tag removed, due to added defines to 'include/uapi/linux/vsock.h'. Both 'SOL_VSOCK' and 'VSOCK_RECVERR' are needed by userspace, so they were placed to 'include/uapi/linux/vsock.h'. At the same time, the same define for 'SOL_VSOCK' was placed to 'include/linux/socket.h'. This is needed because this file contains SOL_XXX defines for different types of socket, so it prevents situation when another new SOL_XXX will use constant 287. include/linux/socket.h | 1 + include/uapi/linux/vsock.h | 9 +++++++++ net/vmw_vsock/af_vsock.c | 6 ++++++ 3 files changed, 16 insertions(+) create mode 100644 include/uapi/linux/vsock.h diff --git a/include/linux/socket.h b/include/linux/socket.h index 39b74d83c7c4..cfcb7e2c3813 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -383,6 +383,7 @@ struct ucred { #define SOL_MPTCP 284 #define SOL_MCTP 285 #define SOL_SMC 286 +#define SOL_VSOCK 287 /* IPX options */ #define IPX_TYPE 1 diff --git a/include/uapi/linux/vsock.h b/include/uapi/linux/vsock.h new file mode 100644 index 000000000000..b25c1347a3b8 --- /dev/null +++ b/include/uapi/linux/vsock.h @@ -0,0 +1,9 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +#ifndef _UAPI_LINUX_VSOCK_H +#define _UAPI_LINUX_VSOCK_H + +#define SOL_VSOCK 287 + +#define VSOCK_RECVERR 1 + +#endif /* _UAPI_LINUX_VSOCK_H */ diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index d841f4de33b0..4fd11bf34bc7 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -110,6 +110,8 @@ #include #include #include +#include +#include static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr); static void vsock_sk_destruct(struct sock *sk); @@ -2137,6 +2139,10 @@ vsock_connectible_recvmsg(struct socket *sock, struct msghdr *msg, size_t len, int err; sk = sock->sk; + + if (unlikely(flags & MSG_ERRQUEUE)) + return sock_recv_errqueue(sk, msg, len, SOL_VSOCK, VSOCK_RECVERR); + vsk = vsock_sk(sk); err = 0; -- 2.25.1