Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp5092289qtf; Thu, 22 Jun 2023 08:13:11 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7AlztUXjd73GELBkjs/yU9wmP2ADMpAsq1JSfvzFYF2gII4XPogxHaV0C+xSG43I54f0p1 X-Received: by 2002:a17:902:8214:b0:1b0:3742:e718 with SMTP id x20-20020a170902821400b001b03742e718mr10980226pln.25.1687446791507; Thu, 22 Jun 2023 08:13:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687446791; cv=none; d=google.com; s=arc-20160816; b=CesaPAbUbZywt31690YlbggHiEZKagiM7909Tzp8J6dmRAovmND6W83/d9kM2qAuUZ M+lXodyIjmTu8YuRTGMaSrBaZ6UXkz0nEffTs3CBiYpIwO6zPFiLOZeuN56WBhzhignh tslEn2qg8/zMY62Bh7q8DfwdhaSq2WG5jYur/7fWJ5KO30f10IIqZOnF/rnVODne8y/z W2FmDuDFuXazlunkB4IE5sCZ7Ty+/z7hckMcFMtPubc53wCMiMUPCmFfT7RTNhaQ9wc9 CXKXOXJBfx8h22h1psAdoRAIHUXcKT5lzTod2gkNl4WUf8Ca9+sJeMUGR0hT0GTQTAgb lRCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=StWTcZ4+l9QPhbORn1PrY5bDL4InPF3vO5n1F8OE0xo=; b=bD1Cf28ShMHcJvMHZNes1dCEdCfSPll2qknpvoJJ5BMtcHijOvkcgF/3xPfmrQGqyr AH7n9L2zXjmuCkSvELSu/zt73WcI9ew59jmP0MOC+O4ObZLDaf1N2OwMNFbaxNo2y12j qKc7lyfa+BDKque1mf2UB72MOnY3uKygEYue+QEtL6zyJc4Q/fnPzKRDawVy4u8KTL0L nrr+9AVe06CSX0h7yx3VHmERN0wkfh56Q5fNqWCWXJUdpdfd9QSxP5+RMGF4FtAvp3yb 9kbut4oLtZrNADSNuAuubFBFMGGoHSqOHpLZoTFrhq9QhWjByJV1bfHA2kVCuyh2FQ+f MSrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IGQGjzns; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a7-20020a170902ecc700b001b559aa99bfsi7121580plh.455.2023.06.22.08.12.59; Thu, 22 Jun 2023 08:13:11 -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=@redhat.com header.s=mimecast20190719 header.b=IGQGjzns; 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=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232125AbjFVO6v (ORCPT + 99 others); Thu, 22 Jun 2023 10:58:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231799AbjFVO6Z (ORCPT ); Thu, 22 Jun 2023 10:58:25 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD9910F2 for ; Thu, 22 Jun 2023 07:57:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1687445856; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=StWTcZ4+l9QPhbORn1PrY5bDL4InPF3vO5n1F8OE0xo=; b=IGQGjznsbYFIdxMVyWYZ9G7N9Gn66LDTHJOoqGdywaQ0eBJvXmym3jfY+CmOqSBprzEXJd 9KKh5PhGeSQSlq31adoxcm3JHWz8YJM6cE6Xr/JTo1/MNm/KLG7wnAij0tC6T07WiedYke 1KuNDt2lCsnnGOQAGqwpVgV0ztG8GrY= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-54-MNjY96tlMc-tXSgqP9lyew-1; Thu, 22 Jun 2023 10:57:30 -0400 X-MC-Unique: MNjY96tlMc-tXSgqP9lyew-1 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-30793c16c78so10825524f8f.3 for ; Thu, 22 Jun 2023 07:57:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687445846; x=1690037846; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=StWTcZ4+l9QPhbORn1PrY5bDL4InPF3vO5n1F8OE0xo=; b=Y295hZCjbvAKWaUMf8l/7PYHzs43e9wDuX18nx5zr9z2ekuaTEngK8XTEwytFjSSBz qYgMleIyYTwdvLwm5pFGBDTVkoqgC515pCoJSV4GyRQCss12xnK+98j9sw6cW9yE72W2 jvuY7RnmlJSsjMKSqIbDuENsy49FW7mKVpJhzSZS3Fy1a92xrcYcHP7dnZERREeGAYaK g2uZRjWgN0djEzpwUQj3mqf/mJCQKgA823WIMQkqhIUixCigwz6nDYLTPqjihsl2Vlvs FqAoCgAqOrkOcsLkjGf5L2hWGLGcJz4Esk5aftfxawJSReUDGKE0pYgI/ZaWZDi3rTXW JDJg== X-Gm-Message-State: AC+VfDxfXs33452VRe0fwqEbvnINaZPjgxH4v5AV3Ac6d7yl0D23H0HM Itmo0EIMBK2S7lXVK8r45DCaGqLDj/Q7LMsxMfnvwnys1gyrRuscx5i1zf/Rl/bp162VKMEstX9 0nE9lBqiGokvubeWvJ3CQZ+kP X-Received: by 2002:adf:cf11:0:b0:30a:e435:63a6 with SMTP id o17-20020adfcf11000000b0030ae43563a6mr19252163wrj.4.1687445846767; Thu, 22 Jun 2023 07:57:26 -0700 (PDT) X-Received: by 2002:adf:cf11:0:b0:30a:e435:63a6 with SMTP id o17-20020adfcf11000000b0030ae43563a6mr19252133wrj.4.1687445846476; Thu, 22 Jun 2023 07:57:26 -0700 (PDT) Received: from sgarzare-redhat (host-87-11-6-160.retail.telecomitalia.it. [87.11.6.160]) by smtp.gmail.com with ESMTPSA id e10-20020a5d65ca000000b002f28de9f73bsm7231665wrw.55.2023.06.22.07.57.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 07:57:25 -0700 (PDT) Date: Thu, 22 Jun 2023 16:57:22 +0200 From: Stefano Garzarella To: Bobby Eshleman Cc: Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Bryan Tan , Vishnu Dasa , VMware PV-Drivers Reviewers , Dan Carpenter , Simon Horman , Krasnov Arseniy , kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hyperv@vger.kernel.org, bpf@vger.kernel.org Subject: Re: [PATCH RFC net-next v4 2/8] vsock: refactor transport lookup code Message-ID: References: <20230413-b4-vsock-dgram-v4-0-0cebbb2ae899@bytedance.com> <20230413-b4-vsock-dgram-v4-2-0cebbb2ae899@bytedance.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20230413-b4-vsock-dgram-v4-2-0cebbb2ae899@bytedance.com> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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 On Sat, Jun 10, 2023 at 12:58:29AM +0000, Bobby Eshleman wrote: >Introduce new reusable function vsock_connectible_lookup_transport() >that performs the transport lookup logic. > >No functional change intended. > >Signed-off-by: Bobby Eshleman >--- > net/vmw_vsock/af_vsock.c | 25 ++++++++++++++++++------- > 1 file changed, 18 insertions(+), 7 deletions(-) Reviewed-by: Stefano Garzarella > >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index ffb4dd8b6ea7..74358f0b47fa 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -422,6 +422,22 @@ static void vsock_deassign_transport(struct vsock_sock *vsk) > vsk->transport = NULL; > } > >+static const struct vsock_transport * >+vsock_connectible_lookup_transport(unsigned int cid, __u8 flags) >+{ >+ const struct vsock_transport *transport; >+ >+ if (vsock_use_local_transport(cid)) >+ transport = transport_local; >+ else if (cid <= VMADDR_CID_HOST || !transport_h2g || >+ (flags & VMADDR_FLAG_TO_HOST)) >+ transport = transport_g2h; >+ else >+ transport = transport_h2g; >+ >+ return transport; >+} >+ > /* Assign a transport to a socket and call the .init transport callback. > * > * Note: for connection oriented socket this must be called when vsk->remote_addr >@@ -462,13 +478,8 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > break; > case SOCK_STREAM: > case SOCK_SEQPACKET: >- if (vsock_use_local_transport(remote_cid)) >- new_transport = transport_local; >- else if (remote_cid <= VMADDR_CID_HOST || !transport_h2g || >- (remote_flags & VMADDR_FLAG_TO_HOST)) >- new_transport = transport_g2h; >- else >- new_transport = transport_h2g; >+ new_transport = vsock_connectible_lookup_transport(remote_cid, >+ remote_flags); > break; > default: > return -ESOCKTNOSUPPORT; > >-- >2.30.2 >