From patchwork Sat Jun 3 20:49:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arseniy Krasnov X-Patchwork-Id: 102908 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp1841036vqr; Sat, 3 Jun 2023 13:56:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7XSVQm3GDwAl3E1zQGt8qG9g32AcbnZJCcMC5f+c6WTmxjcR/QBIiwUQ0BwrUdvuXZnP55 X-Received: by 2002:a05:6358:e494:b0:123:4843:e7ea with SMTP id by20-20020a056358e49400b001234843e7eamr10301967rwb.21.1685825778630; Sat, 03 Jun 2023 13:56:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685825778; cv=none; d=google.com; s=arc-20160816; b=h/Kmc2yvdd2ClKQzcTJ5XwANPbZHCSqlN8yJkuJ7cLqtQFagXLivMLjM6SMEsdr//9 6wwXRRZ1gr593U+3Q3y+GX2jU41d1kOcY6qSgUra0W8m1Y6HYY/ANzlqpodGwl8zg/Hk tRJS6mOrlTl8QZUxceXTSDv8M5m7SFEqz6MzZCSKXGSNw0flGlN8b+kKG8mK+BAxXzd6 o8Ld+IZAAe/c8HxVuHTYKAAsW/FCe+zN1q1Op92f02dlf694M9Hag47ncVO+Qe1Ly3XD bzDeLWBIfpc+9q3rIEjWd/6iM9zDufZwyFLJb8ZHhKYBe8ZQeFXFTN8Kd6F7GAxbOXsA D+MA== 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=ApoSi7ZfTEhQVGLgapLVsvDQGAGgUMVtdzLvgIwP5vU=; b=yxXUV/gTzWzOVCgfD4zyc37p/Ymx/CM5gEsokr3wndY2dM+oJNsY1XoWSFCgTpPRDL UfgjyVXeEYb8hAcbpk2weUoNHoMbUW6Rda1NP1osiHvn0+9suXFObs5hypFuQyc4DXBr p5MJR4t1xP3Yw2Aat8cYV+FcPqmHoTwi8v+3es8FkgrPtFIHwZyykI/Mgvl6f0IlmRy+ GBQlfkKOLccDsnqCCmNV2Kx8+alIRySY+NS7MmaT7pyaUfsb1xAtJ9J8ICfC9v+7YqD1 3ikoJ+Kz07yMMHlYfmRymRiRinlEZ4TqF1rszEqPsNiKIRLevAJ4FvYwjxL15r2mSQ1f aYWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=AtVJ9LHY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qi2-20020a17090b274200b00256a6aab74esi4916607pjb.111.2023.06.03.13.56.06; Sat, 03 Jun 2023 13:56:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@sberdevices.ru header.s=mail header.b=AtVJ9LHY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=sberdevices.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232651AbjFCUzQ (ORCPT + 99 others); Sat, 3 Jun 2023 16:55:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230084AbjFCUy6 (ORCPT ); Sat, 3 Jun 2023 16:54:58 -0400 Received: from mx.sberdevices.ru (mx.sberdevices.ru [45.89.227.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01AA5B3; Sat, 3 Jun 2023 13:54:55 -0700 (PDT) Received: from s-lin-edge02.sberdevices.ru (localhost [127.0.0.1]) by mx.sberdevices.ru (Postfix) with ESMTP id E21A95FD37; Sat, 3 Jun 2023 23:54:47 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sberdevices.ru; s=mail; t=1685825687; bh=ApoSi7ZfTEhQVGLgapLVsvDQGAGgUMVtdzLvgIwP5vU=; h=From:To:Subject:Date:Message-ID:MIME-Version:Content-Type; b=AtVJ9LHYCx6rZSQS+YMDX5FaJbjdJxUrIEQ1YaCWynDCrMbEBlEfoKr1DYMS2Sub6 /HMXGkJS0o9xZFnLGQTRLswCddVWe7MYxm3FYN95KkPfdwzma4E6n251rr8XUFjAVR YfX2ftHGxjH4VWAUNnk8ngHJ+5f4pO+ZKmQuF2b0NQT4oZKKohvWWI2TxMH42efJHe kolX/+GqXDSoxE7cozf1cDcTK+YQzKzKFUTSaSR9Ig5pA4zFVAPkntVLdQd5DOU7ad lo9n0yT1SzjUKzfoNY6JtI9kQbYlBZFgw25V5ADfFGXZxhsRX5GKtOV7YvqnDubhD9 pQd48J4Waj8pQ== Received: from S-MS-EXCH01.sberdevices.ru (S-MS-EXCH01.sberdevices.ru [172.16.1.4]) by mx.sberdevices.ru (Postfix) with ESMTP; Sat, 3 Jun 2023 23:54:47 +0300 (MSK) 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: , , , , , , , Arseniy Krasnov Subject: [RFC PATCH v4 07/17] vsock: read from socket's error queue Date: Sat, 3 Jun 2023 23:49:29 +0300 Message-ID: <20230603204939.1598818-8-AVKrasnov@sberdevices.ru> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> References: <20230603204939.1598818-1-AVKrasnov@sberdevices.ru> MIME-Version: 1.0 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/06/03 16:55:00 #21417531 X-KSMG-AntiVirus-Status: Clean, skipped X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767716451364836082?= X-GMAIL-MSGID: =?utf-8?q?1767716451364836082?= 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. Signed-off-by: Arseniy Krasnov --- include/linux/socket.h | 1 + net/vmw_vsock/af_vsock.c | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/linux/socket.h b/include/linux/socket.h index bd1cc3238851..d79efd026880 100644 --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -382,6 +382,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/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c index 45fd20c4ed50..07803d9fbf6d 100644 --- a/net/vmw_vsock/af_vsock.c +++ b/net/vmw_vsock/af_vsock.c @@ -110,6 +110,7 @@ #include #include #include +#include static int __vsock_bind(struct sock *sk, struct sockaddr_vm *addr); static void vsock_sk_destruct(struct sock *sk); @@ -2135,6 +2136,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, 0); + vsk = vsock_sk(sk); err = 0;