From patchwork Mon Apr 3 11:24:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 13198084 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0D5F4C761A6 for ; Mon, 3 Apr 2023 11:28:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232446AbjDCL2I (ORCPT ); Mon, 3 Apr 2023 07:28:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231966AbjDCL2H (ORCPT ); Mon, 3 Apr 2023 07:28:07 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6A27812053; Mon, 3 Apr 2023 04:27:51 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id C5A775FD22; Mon, 3 Apr 2023 14:27:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1680521269; bh=IT8v0HROiXE98eFOBlkbvJKsX4eGIdzHHzOWFB5UhsM=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=XpyVQ5f0Mu7e/D8l9CfMGthvfxgoiPgxcMVZRjwL1QDaQU60hZm0Mllrk61kkNGJa o6Fm2ysFL1+9GpzLKYw5Jy3/Usl/tlzMYXM8dRWwN1lmSCkzuTswQmMjfaHb/cXCQr j95fXPFV+YuF6g9ASaR88yvjVvG0+Hw8UB2JgUk+U/K+3TF6kAxqqrRGJlq0zwmeo6 sSvQZoWD+WsRP+cROH7TYCR4uD1HgAvjH1u/hXHiEG/tbunEami+wC2lvh1B0jM0aP lZqr/mwuyZ1T+JJ5+e/3/KGmk/FDxcBimuOe88oBgOk1GbP3Hza4tHO2Y+E2XuQOlS 4TL5GOAvEuwMw== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 3 Apr 2023 14:27:49 +0300 (MSK) Message-ID: <2cfe98c9-0b47-d50a-0570-70e6d4af281e@sberdevices.ru> Date: Mon, 3 Apr 2023 14:24:17 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US In-Reply-To: <0d20e25a-640c-72c1-2dcb-7a53a05e3132@sberdevices.ru> To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bobby Eshleman , Bryan Tan , Vishnu Dasa CC: , , , , , , , From: Arseniy Krasnov Subject: [PATCH net-next v4 1/3] vsock/vmci: convert VMCI error code to -ENOMEM on receive X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/04/03 05:35:00 #21028078 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This adds conversion of VMCI specific error code to general -ENOMEM. It is preparation for the next patch, which changes af_vsock.c behaviour on receive to pass value returned from transport to the user. Signed-off-by: Arseniy Krasnov Reviewed-by: Vishnu Dasa Reviewed-by: Stefano Garzarella --- net/vmw_vsock/vmci_transport.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/net/vmw_vsock/vmci_transport.c b/net/vmw_vsock/vmci_transport.c index 36eb16a40745..a5375c97f5b0 100644 --- a/net/vmw_vsock/vmci_transport.c +++ b/net/vmw_vsock/vmci_transport.c @@ -1831,10 +1831,17 @@ static ssize_t vmci_transport_stream_dequeue( size_t len, int flags) { + ssize_t err; + if (flags & MSG_PEEK) - return vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0); + err = vmci_qpair_peekv(vmci_trans(vsk)->qpair, msg, len, 0); else - return vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0); + err = vmci_qpair_dequev(vmci_trans(vsk)->qpair, msg, len, 0); + + if (err < 0) + err = -ENOMEM; + + return err; } static ssize_t vmci_transport_stream_enqueue( From patchwork Mon Apr 3 11:25:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 13198085 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3F830C76196 for ; Mon, 3 Apr 2023 11:28:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232463AbjDCL2s (ORCPT ); Mon, 3 Apr 2023 07:28:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33290 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232238AbjDCL2r (ORCPT ); Mon, 3 Apr 2023 07:28:47 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B127C4224; Mon, 3 Apr 2023 04:28:45 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 079385FD22; Mon, 3 Apr 2023 14:28:44 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1680521324; bh=PMQoUlr6fMnlWZgvIkETHRIUvgj+Tiz5vrh8HAFCAUw=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=smc6Tp11ta3Y/nEm69dGlKm9EAdjP20xwlU97Fdk7gE5GLNoyWDSl27ygH0prTMBL SgKzriCBXY0GLdzgHJnQJeS5H9xzrgm6hbczABAiFlSFmv6ccz727eDVyQlfk7Y+wv kKIDtHBRZUYyjG8r+kORqYKzC/Py8TyYwEs/yM4plsik4tyLuucW6aD6/BBxYaYgLu XLTK8RBgSOXDF1pwbE5hPdVuwiZMAY+Ng8HsRAQG2hGnBqLPNL39eNw7gHRx35Fpki SxO7lIWNn8t4GSPeXdxtO12Byav1R3VgA6cZdAUqBkc8v8J0RITmvdMawRUXG9C2xG 3GMmdICjYsuVA== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 3 Apr 2023 14:28:43 +0300 (MSK) Message-ID: <067371c8-f5a8-59a5-9485-cee85e3d27ef@sberdevices.ru> Date: Mon, 3 Apr 2023 14:25:12 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US In-Reply-To: <0d20e25a-640c-72c1-2dcb-7a53a05e3132@sberdevices.ru> To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bobby Eshleman , Bryan Tan , Vishnu Dasa CC: , , , , , , , From: Arseniy Krasnov Subject: [PATCH net-next v4 2/3] vsock: return errors other than -ENOMEM to socket X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH02.sberdevices.ru (172.16.1.5) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/04/03 05:35:00 #21028078 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This removes behaviour, where error code returned from any transport was always switched to ENOMEM. This works in the same way as: commit c43170b7e157 ("vsock: return errors other than -ENOMEM to socket"), but for receive calls. Signed-off-by: Arseniy Krasnov Reviewed-by: Stefano Garzarella --- net/vmw_vsock/af_vsock.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 5f2dda35c980..413407bb646c 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -2043,7 +2043,7 @@ static int __vsock_stream_recvmsg(struct sock *sk, struct msghdr *msg, read = transport->stream_dequeue(vsk, msg, len - copied, flags); if (read < 0) { - err = -ENOMEM; + err = read; break; } @@ -2094,7 +2094,7 @@ static int __vsock_seqpacket_recvmsg(struct sock *sk, struct msghdr *msg, msg_len = transport->seqpacket_dequeue(vsk, msg, flags); if (msg_len < 0) { - err = -ENOMEM; + err = msg_len; goto out; } From patchwork Mon Apr 3 11:26:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 13198087 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45100C761A6 for ; Mon, 3 Apr 2023 11:29:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232476AbjDCL35 (ORCPT ); Mon, 3 Apr 2023 07:29:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35120 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232506AbjDCL3z (ORCPT ); Mon, 3 Apr 2023 07:29:55 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1ABFFF09; Mon, 3 Apr 2023 04:29:51 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id 350B45FD22; Mon, 3 Apr 2023 14:29:50 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1680521390; bh=Q1dSLV0WkKrQTTWvKTXPk9LEK5CXRc1NRkFMGJRvt8g=; h=Message-ID:Date:MIME-Version:To:From:Subject:Content-Type; b=j2qzNll/6/dpzx/30RXAHTNPRE9oE6UumpNtp+olyKJef2hhZe4rvWSwSB7+m7PiM PaFtiCYpc8JFGkLU/vMER89UN/Uf8unbGIcvFS4YnuYJE4gsAxf16vb4PYM9mm4cih wYErFyXFdgzMk4llX009YDO0uUgdC/qAR3k9k+h1FxBgn76jA4xC3HcnUyHObrCkdY QEVy4flZTOVuuBKgV0njrsck+7mokGmFLcVc0XCWlJDUbqUWfcQPAYngo02showNkD yiOLwigGwcDZJpa/n34XHOS597DTi5R8Zcgi8NYwkPzRZbG4pagP3JYKymKijL5dE8 Q8hQ3xnbynw3Q== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Mon, 3 Apr 2023 14:29:49 +0300 (MSK) Message-ID: <0c4d433d-104d-f3e6-94c7-297c2ed557c0@sberdevices.ru> Date: Mon, 3 Apr 2023 14:26:18 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Content-Language: en-US In-Reply-To: <0d20e25a-640c-72c1-2dcb-7a53a05e3132@sberdevices.ru> To: Stefan Hajnoczi , Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Bobby Eshleman , Bryan Tan , Vishnu Dasa CC: , , , , , , , From: Arseniy Krasnov Subject: [PATCH net-next v4 3/3] vsock/test: update expected return values X-Originating-IP: [172.16.1.6] X-ClientProxiedBy: S-MS-EXCH01.sberdevices.ru (172.16.1.4) To S-MS-EXCH01.sberdevices.ru (172.16.1.4) X-KSMG-Rule-ID: 4 X-KSMG-Message-Action: clean X-KSMG-AntiSpam-Status: not scanned, disabled by settings X-KSMG-AntiSpam-Interceptor-Info: not scanned X-KSMG-AntiPhishing: not scanned, disabled by settings X-KSMG-AntiVirus: Kaspersky Secure Mail Gateway, version 1.1.2.30, bases: 2023/04/03 05:35:00 #21028078 X-KSMG-AntiVirus-Status: Clean, skipped Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org This updates expected return values for invalid buffer test. Now such values are returned from transport, not from af_vsock.c. Signed-off-by: Arseniy Krasnov Reviewed-by: Stefano Garzarella --- tools/testing/vsock/vsock_test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/testing/vsock/vsock_test.c b/tools/testing/vsock/vsock_test.c index 3de10dbb50f5..a91d0ef963be 100644 --- a/tools/testing/vsock/vsock_test.c +++ b/tools/testing/vsock/vsock_test.c @@ -723,7 +723,7 @@ static void test_seqpacket_invalid_rec_buffer_server(const struct test_opts *opt exit(EXIT_FAILURE); } - if (errno != ENOMEM) { + if (errno != EFAULT) { perror("unexpected errno of 'broken_buf'"); exit(EXIT_FAILURE); } @@ -887,7 +887,7 @@ static void test_inv_buf_client(const struct test_opts *opts, bool stream) exit(EXIT_FAILURE); } - if (errno != ENOMEM) { + if (errno != EFAULT) { fprintf(stderr, "unexpected recv(2) errno %d\n", errno); exit(EXIT_FAILURE); }