Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp904653lqp; Thu, 23 May 2024 03:45:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXre/3ISYgtULERRU5xVwf3YtUZRKNuF7KZDtw9qEn1eZpBZ8fesbKUttUtWIvdraNSBbWAO2VXbIg3tyrBeb1UkH0qOFwx8mUMUDaBZA== X-Google-Smtp-Source: AGHT+IFsLhttw2hYn7wPQt9drVgUjryQZ6Oq2rkaOlf3Z0ENO76YSPth64TMJX8ZeZjp4hf80FHQ X-Received: by 2002:a05:6830:1e62:b0:6f0:e7ee:97b0 with SMTP id 46e09a7af769-6f66745166emr5226643a34.19.1716461130663; Thu, 23 May 2024 03:45:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716461130; cv=pass; d=google.com; s=arc-20160816; b=veJU+UvdjmliEW1XwWbHpECtn04eC5i1LLffGLHKj8RwP7TsyPe9oQQV0E7i6bmIk/ FFdYJUsOxInOAh3O9vbYH76IZC6OXHDeHwVyr/DW96tQhEI4OH9fKOhS1C5fMUAgJX5x i5RobHgtyBrL7m0JiHwW0zg28PwS6wuoRbLQunsWmSMG0aSbS7XEJQHC7wDRm1m5Poif j5l9C5c294j/R7Ml/nLwASOq+H3e1MJicAsgpABZXeGJZgCVT/MeM2GwHO0qob6LTsqH SCxYHt2lXmVxnziafqHQ5zR1i5IGW/TL7iPuPBp+cj2vT18x0gIXTsW/CvXVguO00Dx9 wm8w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Yv5h7KKLQiB1kTjmD5ZvIpsXpj/cTIUbqVMlOTTEPnc=; fh=35HLlOYY44Hu0QBc5CW2JNlb8a8bsYidBmtstnhTBxc=; b=u227APdM85YRT9NAjneUj4Vx+NFc2J86MvdbBaS0jeGh7iJwB8CR8lc8oFuvYs5Ou3 fdyR8kp0FQ5ij3z/dwjjV9rYeKg4/oHuhN+opVKA9JsFY+WjzTP8wV2C6381g3RwLs3R yGt+xIHqQFpj8g8+ZtjI2V77xs11vEcXis9JHOlbvuMYlz63i1vwsKf57Ctu6ViDd37p jNy/dEUstpTyAz6YgYlZE+b5xEThznnZDzpYuzqI7ietGOLncm76EqheqQaldIQn6cDV 4LFyYBErxVrjIOSdj1sYukoqzCxlqG+9qpFJBTW0luZqMxGpEd57zDZYiIhsVI9+uiRH XEKg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hLSk0J6A; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-187355-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id 41be03b00d2f7-634103f568csi27725065a12.362.2024.05.23.03.45.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:45:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-187355-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hLSk0J6A; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-187355-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-187355-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 3D7E3282220 for ; Thu, 23 May 2024 10:45:30 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93CF2149C5F; Thu, 23 May 2024 10:44:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="hLSk0J6A" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FA5D143740 for ; Thu, 23 May 2024 10:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716461083; cv=none; b=WeYUvL8sqdPr1UbG1U42dO68/x8WaYRXyAqjWgVks2yxxUQQx0zQZgtBxo3idDapPXk81iRIA6sas0Xh1X4Mbf/QHrDaS5LdO4p3GNceY3dr9W7uoLqnmNzdIYcbVL07joJdoverbuPUpfQawBrVF0fvj8rH50VR7QLS6M70VWA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716461083; c=relaxed/simple; bh=8J5hGb0K/YyvM6E2DOrFaBEUfUsOqvbKT6LuI8BfOIA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=lCoHvnxXszB0B2hIjE/W0CRvYgUiHnmRkYSXAB5h3BBQVlehMzJRV/wbDUCcUjTXL7QZjoZut10oUW4u5mLc0+auFmPJcPHFiibTc2ypXFIxVt9h894XCbQsZcrDU2Twi+HHFuYdynbbP0lTkRiGegCyocsZCLDDsH1sXGLlurQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=hLSk0J6A; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1716461081; 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=Yv5h7KKLQiB1kTjmD5ZvIpsXpj/cTIUbqVMlOTTEPnc=; b=hLSk0J6ApFVvgw1nYsP6vh20h0fmtGVyDXcAnmcJLmPfXON41DCZu4qnnXDh7kycslrnd0 wERYSeiBuXyhVfoNmw5mPfUvn/JWLl7bkpidQfhdLWR7QyssKtplOPJbvaGHrlu72DtmDQ F4wZxQFoXZLrUuqZFzoZM2S8j3BX8fo= Received: from mail-qt1-f199.google.com (mail-qt1-f199.google.com [209.85.160.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-280-r3xAOFO0Ph64j_C784cg0A-1; Thu, 23 May 2024 06:44:40 -0400 X-MC-Unique: r3xAOFO0Ph64j_C784cg0A-1 Received: by mail-qt1-f199.google.com with SMTP id d75a77b69052e-43d7cfc45abso183512791cf.0 for ; Thu, 23 May 2024 03:44:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716461079; x=1717065879; 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=Yv5h7KKLQiB1kTjmD5ZvIpsXpj/cTIUbqVMlOTTEPnc=; b=uouy3WlY+LZG7YlTj0YmaWEf0HeLIZixikqmcL5pCnjd3XXfE78uRs/wlNUEZN5NfN fiG4C88ISWNKf/hSXZbvlLBMtv0lZrSERE7F83ZkqwcRwVgOoO70JjiZ5COb0gQM2fhV RMtVCmOxT3/wWkrDcpRIMkHLS097XGD041jidaYrE9c6F6hlghvyRjQDgVo3d6wwcu8K kfbkgg/tpG3D/QF2RiRnejG5D6Hi+0R7t6Fad4ixm6mUhNkkJvTz9H0f/QsbGutOQ08D bI2xoEWzeKeJ8kRtBik3sAd2rzLmODhlRmlOR+s4kj5FTme0A2jprdhLVRNbxzzghWKa P8fA== X-Forwarded-Encrypted: i=1; AJvYcCXO8u0EFtZSSk6Ohtj9iuP7b0HmKuoqpA5uwZ0nv5VGDCF/yttFmbI7ycFsCmkPUn3fBzONAcjAUCslG2dOyRxSme/t5jNKkN+cs3q3 X-Gm-Message-State: AOJu0YxIaB4U0PMtvtLO/KVb0CBsDPRvBCrcIQMdgHvqGzSgMkH5iRdZ CfqTOGH49sRYSAhuaC5s6bqquY/4E4pmcYuL3/IA6swh7T0d5KhgZ1zx9iFrZPTY08GMHmX+9CE 9xqU4v5pPGc20GfNWnGjZusjQJI7PUhwkGPyNKYfsUy9XrdlV2DJTcn2XyzD1pw== X-Received: by 2002:a05:6214:4909:b0:6ab:8d61:935a with SMTP id 6a1803df08f44-6ab8d619555mr24589336d6.48.1716461079520; Thu, 23 May 2024 03:44:39 -0700 (PDT) X-Received: by 2002:a05:6214:4909:b0:6ab:8d61:935a with SMTP id 6a1803df08f44-6ab8d619555mr24589186d6.48.1716461079196; Thu, 23 May 2024 03:44:39 -0700 (PDT) Received: from sgarzare-redhat (host-79-53-30-109.retail.telecomitalia.it. [79.53.30.109]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6a15f179534sm142431096d6.17.2024.05.23.03.44.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 03:44:38 -0700 (PDT) Date: Thu, 23 May 2024 12:44:35 +0200 From: Stefano Garzarella To: Xuewei Niu Cc: stefanha@redhat.com, mst@redhat.com, davem@davemloft.net, kvm@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xuewei Niu Subject: Re: [RFC PATCH 4/5] vsock: seqpacket_allow adapts to multi-devices Message-ID: References: <20240517144607.2595798-1-niuxuewei.nxw@antgroup.com> <20240517144607.2595798-5-niuxuewei.nxw@antgroup.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20240517144607.2595798-5-niuxuewei.nxw@antgroup.com> On Fri, May 17, 2024 at 10:46:06PM GMT, Xuewei Niu wrote: >Adds a new argument, named "src_cid", to let them know which `virtio_vsock` >to be selected. > >Signed-off-by: Xuewei Niu >--- > include/net/af_vsock.h | 2 +- > net/vmw_vsock/af_vsock.c | 15 +++++++++++++-- > net/vmw_vsock/virtio_transport.c | 4 ++-- > net/vmw_vsock/vsock_loopback.c | 4 ++-- > 4 files changed, 18 insertions(+), 7 deletions(-) Same for this. > >diff --git a/include/net/af_vsock.h b/include/net/af_vsock.h >index 0151296a0bc5..25f7dc3d602d 100644 >--- a/include/net/af_vsock.h >+++ b/include/net/af_vsock.h >@@ -143,7 +143,7 @@ struct vsock_transport { > int flags); > int (*seqpacket_enqueue)(struct vsock_sock *vsk, struct msghdr *msg, > size_t len); >- bool (*seqpacket_allow)(u32 remote_cid); >+ bool (*seqpacket_allow)(u32 src_cid, u32 remote_cid); > u32 (*seqpacket_has_data)(struct vsock_sock *vsk); > > /* Notification. */ >diff --git a/net/vmw_vsock/af_vsock.c b/net/vmw_vsock/af_vsock.c >index da06ddc940cd..3b34be802bf2 100644 >--- a/net/vmw_vsock/af_vsock.c >+++ b/net/vmw_vsock/af_vsock.c >@@ -470,10 +470,12 @@ 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 int src_cid, remote_cid; > __u8 remote_flags; > int ret; > >+ remote_cid = vsk->remote_addr.svm_cid; >+ > /* If the packet is coming with the source and destination CIDs higher > * than VMADDR_CID_HOST, then a vsock channel where all the packets are > * forwarded to the host should be established. Then the host will >@@ -527,8 +529,17 @@ int vsock_assign_transport(struct vsock_sock *vsk, struct vsock_sock *psk) > return -ENODEV; > > if (sk->sk_type == SOCK_SEQPACKET) { >+ if (vsk->local_addr.svm_cid == VMADDR_CID_ANY) { >+ if (new_transport->get_default_cid) >+ src_cid = new_transport->get_default_cid(); >+ else >+ src_cid = new_transport->get_local_cid(); >+ } else { >+ src_cid = vsk->local_addr.svm_cid; >+ } >+ > if (!new_transport->seqpacket_allow || >- !new_transport->seqpacket_allow(remote_cid)) { >+ !new_transport->seqpacket_allow(src_cid, remote_cid)) { > module_put(new_transport->module); > return -ESOCKTNOSUPPORT; > } >diff --git a/net/vmw_vsock/virtio_transport.c b/net/vmw_vsock/virtio_transport.c >index 998b22e5ce36..0bddcbd906a2 100644 >--- a/net/vmw_vsock/virtio_transport.c >+++ b/net/vmw_vsock/virtio_transport.c >@@ -615,14 +615,14 @@ static struct virtio_transport virtio_transport = { > .can_msgzerocopy = virtio_transport_can_msgzerocopy, > }; > >-static bool virtio_transport_seqpacket_allow(u32 remote_cid) >+static bool virtio_transport_seqpacket_allow(u32 src_cid, u32 remote_cid) > { > struct virtio_vsock *vsock; > bool seqpacket_allow; > > seqpacket_allow = false; > rcu_read_lock(); >- vsock = rcu_dereference(the_virtio_vsock); >+ vsock = virtio_transport_get_virtio_vsock(src_cid); > if (vsock) > seqpacket_allow = vsock->seqpacket_allow; > rcu_read_unlock(); >diff --git a/net/vmw_vsock/vsock_loopback.c b/net/vmw_vsock/vsock_loopback.c >index 6dea6119f5b2..b94358f5bb2c 100644 >--- a/net/vmw_vsock/vsock_loopback.c >+++ b/net/vmw_vsock/vsock_loopback.c >@@ -46,7 +46,7 @@ static int vsock_loopback_cancel_pkt(struct vsock_sock *vsk) > return 0; > } > >-static bool vsock_loopback_seqpacket_allow(u32 remote_cid); >+static bool vsock_loopback_seqpacket_allow(u32 src_cid, u32 remote_cid); > static bool vsock_loopback_msgzerocopy_allow(void) > { > return true; >@@ -104,7 +104,7 @@ static struct virtio_transport loopback_transport = { > .send_pkt = vsock_loopback_send_pkt, > }; > >-static bool vsock_loopback_seqpacket_allow(u32 remote_cid) >+static bool vsock_loopback_seqpacket_allow(u32 src_cid, u32 remote_cid) > { > return true; > } >-- >2.34.1 >