From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49854C64E7A for ; Tue, 1 Dec 2020 16:25:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6F03208C3 for ; Tue, 1 Dec 2020 16:25:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="KGJwXdtU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726483AbgLAQZl (ORCPT ); Tue, 1 Dec 2020 11:25:41 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:39616 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725979AbgLAQZl (ORCPT ); Tue, 1 Dec 2020 11:25:41 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606839854; 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=gHS3kkYggRLy+5fMrWoIB0GgrNcrW36mXXiiHAGr4Pk=; b=KGJwXdtUVvlX5T0FcRPrtO2VLF8lJSuYwsXz2SzvBdCtZOcPf12zFCh29HHBD4Tv2nOIwj pNW0k5BihRUHcc8isbU57tCck6m0iDuq/oUDpnv2zP0MBy2VkbqqGL94Xcj6XcSdysEeFX BNlTy3NprrThKvkb5biPbyHKXx3xxcA= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-516-v2YW1THhOJS5rEuIk1Ut1Q-1; Tue, 01 Dec 2020 11:24:13 -0500 X-MC-Unique: v2YW1THhOJS5rEuIk1Ut1Q-1 Received: by mail-wr1-f72.google.com with SMTP id f4so1200474wru.21 for ; Tue, 01 Dec 2020 08:24:13 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gHS3kkYggRLy+5fMrWoIB0GgrNcrW36mXXiiHAGr4Pk=; b=t1MTutXpQCZvc+/D/9mITi3FF/9Z5rmeUkFBeQFvwgcjmg8O/r/i8HPtHPZwaj02qj ZwHrSmoRGa5IShi2658OdKEWd4Lic7xXV4VumduzxDAu/LSfYSpV090e7Kl1mgom4sSH vbdhCtKX5gdEP9L4U9hqR8jSYDc54owliUbdqdf3bYP5guqZchufrzThd/FZrPon0kiZ iNkOzFBNhBp6wdUSxAW35E/7CArNvkvO37ihw4atFSHBLchFM99EgDZIfeY5iwf9iq0t asL8fdTv+nuNZ/lV0jTQn6kxSqm7VLNle+PFM5h4g6N1x+WIl9Gll0yMOHadjhhB7Cf9 78wg== X-Gm-Message-State: AOAM531dRH0RpVoFqrRzGlLH+rC8Y38DPB0OTySBqMtdTUGklBXMVdUj t9ehaMoz0B3vrT+hrAjIdzFJabBmcBxW4h6OO5egJ5LDCtwyKGrprmCE8M2/vf2PfSbZLmasT0P Sx6B/TK1AN4CumZGVjynIorM9 X-Received: by 2002:adf:f88c:: with SMTP id u12mr4978107wrp.209.1606839806266; Tue, 01 Dec 2020 08:23:26 -0800 (PST) X-Google-Smtp-Source: ABdhPJzMzlkHaVe3TzHploDAHelHS+jFVLyPnEfjgtjahqXyoGh2s8BCarcKwuVJSImK4JNC0Xdt7Q== X-Received: by 2002:adf:f88c:: with SMTP id u12mr4978086wrp.209.1606839806086; Tue, 01 Dec 2020 08:23:26 -0800 (PST) Received: from steredhat (host-79-17-248-175.retail.telecomitalia.it. [79.17.248.175]) by smtp.gmail.com with ESMTPSA id a1sm41293wrv.61.2020.12.01.08.23.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Dec 2020 08:23:25 -0800 (PST) Date: Tue, 1 Dec 2020 17:23:23 +0100 From: Stefano Garzarella To: Andra Paraschiv Cc: netdev , linux-kernel , "David S . Miller" , David Duncan , Dexuan Cui , Alexander Graf , Jorgen Hansen , Jakub Kicinski , Stefan Hajnoczi , Vitaly Kuznetsov Subject: Re: [PATCH net-next v1 3/3] af_vsock: Assign the vsock transport considering the vsock address flag Message-ID: <20201201162323.gwfzktkwtu6x4eef@steredhat> References: <20201201152505.19445-1-andraprs@amazon.com> <20201201152505.19445-4-andraprs@amazon.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20201201152505.19445-4-andraprs@amazon.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 01, 2020 at 05:25:05PM +0200, Andra Paraschiv wrote: >The vsock flag has been set in the connect and (listen) receive paths. > >When the vsock transport is assigned, the remote CID is used to >distinguish between types of connection. > >Use the vsock flag (in addition to the CID) from the remote address to >decide which vsock transport to assign. For the sibling VMs use case, >all the vsock packets need to be forwarded to the host, so always assign >the guest->host transport if the vsock flag is set. For the other use >cases, the vsock transport assignment logic is not changed. > >Signed-off-by: Andra Paraschiv >--- > net/vmw_vsock/af_vsock.c | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index d10916ab45267..bafc1cb20abd4 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -419,16 +419,21 @@ static void vsock_deassign_transport(struct vsock_sock *vsk) > * (e.g. during the connect() or when a connection request on a listener > * socket is received). > * The vsk->remote_addr is used to decide which transport to use: >- * - remote CID == VMADDR_CID_LOCAL or g2h->local_cid or VMADDR_CID_HOST if >- * g2h is not loaded, will use local transport; >- * - remote CID <= VMADDR_CID_HOST will use guest->host transport; >- * - remote CID > VMADDR_CID_HOST will use host->guest transport; >+ * - remote flag == VMADDR_FLAG_SIBLING_VMS_COMMUNICATION, will always >+ * forward the vsock packets to the host and use guest->host transport; >+ * - otherwise, going forward with the remote flag default value: >+ * - remote CID == VMADDR_CID_LOCAL or g2h->local_cid or VMADDR_CID_HOST >+ * if g2h is not loaded, will use local transport; >+ * - remote CID <= VMADDR_CID_HOST or h2g is not loaded, will use >+ * guest->host transport; >+ * - remote CID > VMADDR_CID_HOST will use host->guest transport; > */ > int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > { > const struct vsock_transport *new_transport; > struct sock *sk = sk_vsock(vsk); > unsigned int remote_cid = vsk->remote_addr.svm_cid; >+ unsigned short remote_flag = vsk->remote_addr.svm_flag; > int ret; > > switch (sk->sk_type) { >@@ -438,6 +443,8 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > case SOCK_STREAM: > if (vsock_use_local_transport(remote_cid)) > new_transport = transport_local; >+ else if (remote_flag == VMADDR_FLAG_SIBLING_VMS_COMMUNICATION) Others flags can be added, so here we should use the bitwise AND operator to check if this flag is set. And what about merging with the next if clause? Thanks, Stefano >+ new_transport = transport_g2h; > else if (remote_cid <= VMADDR_CID_HOST || > !transport_h2g) > new_transport = transport_g2h; > else >-- >2.20.1 (Apple Git-117) >