From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f45.google.com (mail-yx1-f45.google.com [74.125.224.45]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00CFE2F60A1 for ; Fri, 12 Dec 2025 15:26:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553185; cv=none; b=nUejcPwLCrfybp6iFqZzZKlQVFPKu7kdA+m9B6pwIv0YRWR0plCustDVoOeFUjo3xIoLjoAqIrJsXmyD46MfWz4cgYkqnduAA6fE5Frt875IY/Bf51MEkswtPDtldPlt7iMQIXlMXFjjtk+Iqys5mzjV+9kGK+qqgThyvkWSNa8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765553185; c=relaxed/simple; bh=260eGi6QkxDk8QQfOLsKhm09EI+KZGuf0yseurtGq/Y=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OLigXLWZ7pzDttfB2r2UA3TfzGmk8GFUZ96qtBWKLUUvcQ61LirmOXqm/dIiN/dKjldFT0vHBRP6zGpIM+r7HMxoxjlMmyK1V9BrYp2puTE6uc9K43mEpSylh72KEYrpo+49fokAcXJ2OtzfwvUSkHgaXkdcES04FSZpSVZI0Fg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FnNSwg4J; arc=none smtp.client-ip=74.125.224.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FnNSwg4J" Received: by mail-yx1-f45.google.com with SMTP id 956f58d0204a3-64455a2a096so1172322d50.3 for ; Fri, 12 Dec 2025 07:26:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765553182; x=1766157982; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=IK+CEXtkA15N8VNwOIEfZTiLVNxEPNXHwf9eEh9q2mY=; b=FnNSwg4JbGsXkFe2tJ+5wJjgau4I9z1jnEAOZjvIh8PXvGDoAjUCWWLmSpFH/N82gY ks3SKSB4ltqh8wZT6J060+2vd396uQqB/mO7viVGUwRYaszMJ3Hs6XWWew9C1RTByoDk 5gAKq9Hcy3WSv2OAoMdqu5h+mhp/7kKMJ+Ot6eKE20kHrCmNFPOOEaRjLiAjdxc4tCKl kfbybaS35zpMVppWtd2/nNOPqkFAWdxc0v6WvqBYIbQnAB8I1wYx4DrxpzSR5mjaBMHE sNCze75T+kVtEK1ywH0wbBsBhtSfD4w9BT9W/Jsl9MB7+W8JOgLk8x3JKGd0P7qBom7b w//g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765553182; x=1766157982; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IK+CEXtkA15N8VNwOIEfZTiLVNxEPNXHwf9eEh9q2mY=; b=I0AYacTXpMx4/fKsS6J/ffRl/f6loKL96N2X5nWlrX+7P3nnTm+LiLWtmpQqHUU2mT v9ZTZwfYw9C5gACA3GJBKbQklw349vetDxvB2o3AU2YGZcgA5oQDRtyCAFXFmFiqSBPG a014RM5Lg7krdo7Su0RIdffUW9xLNabfl5fYRW82TwcLimUT2adZKhV/EUhBPuZ5lDAS kH44Qd8rUs4uyfzxboQg3sUICCVOMlsWBqKe3f/Ldkwb0SLq11yvOZvkGokBgk/2DvC3 IJUvM3iKMHAl1oiCx+04wVcUsBoqaaa8owYQ/BkGhIyntzRAeqLYx4y9SaIbsn+O8aG8 kkpA== X-Forwarded-Encrypted: i=1; AJvYcCW/iHbdXn+O0Fz8adRChm6Gf740WAEF9ZamCJVs/9EhbOQIFogkMnbLVl7r/jzfTVtfprm5pENw7Vow0eE=@vger.kernel.org X-Gm-Message-State: AOJu0YzxNTvUq+HLUc5uNLGdSKLC20GKKJuga+cJqFIWC5tF5BtWsSXS HKJrcTB2/hWa76OqmH9HI4EF8W6YI3ic/P42TfJRvfnBEX/DSbmXQjsN X-Gm-Gg: AY/fxX7VRpwrflfB0LvdmU6dxZTHatlfZJ8HRDsdb7mLvDWnE6uVB34g30OvUs4Yf6B W+qgFRmLxtb2ELehLvFfYa9mALWRZcOSnwZBfcMmwErkdZwI6liUpJI9DRpT+1iY6guPouTbcyp dNAf4m47QyipExpfv7sfYs9tF2A6q7E2y7R+94f83UIfRW2vvBmMN4GvMD483ZYytr1rt7eY8r/ WvvzxIqJtV5BLADhP8ux9G72Akw3seShPxRScbsf69YwT7wO5tuf2J8BBTnMPGaGrUWHCVxTngG GLy6E9+trs3E7+pE5bs5HZIsrn1AYfEy3OQx+gTOURRbojnK8M6RCB9oT2lWhFZmuknpSAXMFya 5ISIKcAaDy5j/3mDuyjqwmmECPyOQYm3bggTCRNOFCEgnMDir89C4/t4pArQOdZPn/KfiYgnKFR 0ZUn7l96F4n7DsM+KCWrGJ70iZ8DYjhUkZBttlhmmCalcdf1p8P6jCO7PCNQOpvOvA7Yw= X-Google-Smtp-Source: AGHT+IHPDxMRz+sSHQa8GJSWOVqErHefuxKsetCMbgKHq77F9IKQFOzGirnG2+UwGG15ipBxTc+SEQ== X-Received: by 2002:a05:690c:7402:b0:789:61ca:88f6 with SMTP id 00721157ae682-78e66cab887mr39877247b3.4.1765553181789; Fri, 12 Dec 2025 07:26:21 -0800 (PST) Received: from devvm11784.nha0.facebook.com ([2a03:2880:25ff:3::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-64477d3a32bsm2613584d50.5.2025.12.12.07.26.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Dec 2025 07:26:21 -0800 (PST) Date: Fri, 12 Dec 2025 07:26:15 -0800 From: Bobby Eshleman To: Paolo Abeni Cc: Stefano Garzarella , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Simon Horman , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Eugenio =?iso-8859-1?Q?P=E9rez?= , Xuan Zhuo , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Bryan Tan , Vishnu Dasa , Broadcom internal kernel review list , Shuah Khan , linux-kernel@vger.kernel.org, virtualization@lists.linux.dev, netdev@vger.kernel.org, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, linux-kselftest@vger.kernel.org, berrange@redhat.com, Sargun Dhillon , Bobby Eshleman Subject: Re: [PATCH net-next v12 04/12] vsock: add netns support to virtio transports Message-ID: References: <20251126-vsock-vmtest-v12-0-257ee21cd5de@meta.com> <20251126-vsock-vmtest-v12-4-257ee21cd5de@meta.com> <6cef5a68-375a-4bb6-84f8-fccc00cf7162@redhat.com> <06b7cfea-d366-44f7-943e-087ead2f25c2@redhat.com> Precedence: bulk X-Mailing-List: linux-hyperv@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: On Tue, Dec 02, 2025 at 02:01:04PM -0800, Bobby Eshleman wrote: > On Tue, Dec 02, 2025 at 09:47:19PM +0100, Paolo Abeni wrote: > > On 12/2/25 6:56 PM, Bobby Eshleman wrote: > > > On Tue, Dec 02, 2025 at 11:18:14AM +0100, Paolo Abeni wrote: > > >> On 11/27/25 8:47 AM, Bobby Eshleman wrote: > > >>> @@ -674,6 +689,17 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file) > > >>> goto out; > > >>> } > > >>> > > >>> + net = current->nsproxy->net_ns; > > >>> + vsock->net = get_net_track(net, &vsock->ns_tracker, GFP_KERNEL); > > >>> + > > >>> + /* Store the mode of the namespace at the time of creation. If this > > >>> + * namespace later changes from "global" to "local", we want this vsock > > >>> + * to continue operating normally and not suddenly break. For that > > >>> + * reason, we save the mode here and later use it when performing > > >>> + * socket lookups with vsock_net_check_mode() (see vhost_vsock_get()). > > >>> + */ > > >>> + vsock->net_mode = vsock_net_mode(net); > > >> > > >> I'm sorry for the very late feedback. I think that at very least the > > >> user-space needs a way to query if the given transport is in local or > > >> global mode, as AFAICS there is no way to tell that when socket creation > > >> races with mode change. > > > > > > Are you thinking something along the lines of sockopt? > > > > I'd like to see a way for the user-space to query the socket 'namespace > > mode'. > > > > sockopt could be an option; a possibly better one could be sock_diag. Or > > you could do both using dumping the info with a shared helper invoked by > > both code paths, alike what TCP is doing. > > >> Also I'm a bit uneasy with the model implemented here, as 'local' socket > > >> may cross netns boundaris and connect to 'local' socket in other netns > > >> (if I read correctly patch 2/12). That in turns AFAICS break the netns > > >> isolation. > > > > > > Local mode sockets are unable to communicate with local mode (and global > > > mode too) sockets that are in other namespaces. The key piece of code > > > for that is vsock_net_check_mode(), where if either modes is local the > > > namespaces must be the same. > > > > Sorry, I likely misread the large comment in patch 2: > > > > https://lore.kernel.org/netdev/20251126-vsock-vmtest-v12-2-257ee21cd5de@meta.com/ > > > > >> Have you considered instead a slightly different model, where the > > >> local/global model is set in stone at netns creation time - alike what > > >> /proc/sys/net/ipv4/tcp_child_ehash_entries is doing[1] - and > > >> inter-netns connectivity is explicitly granted by the admin (I guess > > >> you will need new transport operations for that)? > > >> > > >> /P > > >> > > >> [1] tcp allows using per-netns established socket lookup tables - as > > >> opposed to the default global lookup table (even if match always takes > > >> in account the netns obviously). The mentioned sysctl specify such > > >> configuration for the children namespaces, if any. > > > > > > I'll save this discussion if the above doesn't resolve your concerns. > > I still have some concern WRT the dynamic mode change after netns > > creation. I fear some 'unsolvable' (or very hard to solve) race I can't > > see now. A tcp_child_ehash_entries-like model will avoid completely the > > issue, but I understand it would be a significant change over the > > current status. > > > > "Luckily" the merge window is on us and we have some time to discuss. Do > > you have a specific use-case for the ability to change the netns mode > > after creation? > > > > /P > > I don't think there is a hard requirement that the mode be change-able > after creation. Though I'd love to avoid such a big change... or at > least leave unchanged as much of what we've already reviewed as > possible. > > In the scheme of defining the mode at creation and following the > tcp_child_ehash_entries-ish model, what I'm imagining is: > - /proc/sys/net/vsock/child_ns_mode can be set to "local" or "global" > - /proc/sys/net/vsock/child_ns_mode is not immutable, can change any > number of times > > - when a netns is created, the new netns mode is inherited from > child_ns_mode, being assigned using something like: > > net->vsock.ns_mode = > get_net_ns_by_pid(current->pid)->child_ns_mode > > - /proc/sys/net/vsock/ns_mode queries the current mode, returning > "local" or "global", returning value of net->vsock.ns_mode > - /proc/sys/net/vsock/ns_mode and net->vsock.ns_mode are immutable and > reject writes > > Does that align with what you have in mind? Hey Paolo, I just wanted to sync up on this one. Does the above align with what you envision? Best, Bobby