From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f42.google.com (mail-yx1-f42.google.com [74.125.224.42]) (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 E6C1923C503 for ; Tue, 16 Dec 2025 01:22:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.42 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765848130; cv=none; b=ugjdbJu9OmHjSXBBromUZ4iQ8OvAEHGm+gronEMBYO0Nhy4WBq93yW3Vb5hgctc4GPN2YxOAyOGoO07Dt/zy3NJcTavzo/6f6pa3aYcGU9ELxqJTUp+X7LX2Vfq7otwpjfI9cbUUs7KgMEvHBrQlesKxF/kBOZmt3q8irWUQYw0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765848130; c=relaxed/simple; bh=KhTpBrq3o1OcDzqZyQ5v6akeq46HasfcRLGJ5YYrEKI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fgohb1LTFnrGciUm/GSsAylewnmzv5sRVPvnUkZduGbuTYlyV4k66pT2cJHodw7/SYCoj5pSsDy6i7MmhmULVJf0NRsHDVe33l4ayt5EbZQTc0XXOUsrbwCtA9ABmo/nxNc0CN1vwOWXKTHXuJMoG6TJjM/mhftE0L+SJZGPn2E= 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=E85KftC4; arc=none smtp.client-ip=74.125.224.42 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="E85KftC4" Received: by mail-yx1-f42.google.com with SMTP id 956f58d0204a3-640e065991dso3243132d50.3 for ; Mon, 15 Dec 2025 17:22:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765848127; x=1766452927; 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=lI4+C9X3I7yvyc2773MJlpz/r2L4renU7eOoChO1rz0=; b=E85KftC4BWZfUx89LtZEIH8y7/RxFdxyiOLkF/oGhurra3KCTuuTJmFT29mGuDqhmC ekGXhRUT8UCkCdfhC1g+OBDvcWXLE7x4vuiTCBNxq/6/oSLmJxCCudHAeg9dtOwTLhP7 2zVPhEafOkBq3IsFm0xmc8K0M1DRgZab9KpcWlxKImXXLmk7i5/EZoqvUdSVy3d3keUq u09A5L3XTMi7GhosnNUH3ITVQbgUophG9kNdAB/9iUGr5yLfZURBwoHfkZj6DwpuDSOf Ox+M5hZD4MSgsMS29AuTiQo4tbX85GGZR9einVh9K+y4ecgUvbTD8aF1JF8NPyJMEC5K PiHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765848127; x=1766452927; 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=lI4+C9X3I7yvyc2773MJlpz/r2L4renU7eOoChO1rz0=; b=d1qxbyCX6tVG5ySWLYsx9A6O7GHvLXtTprVE2ut5hhFthsvjDZ9Q13Aq4+v7cBuptT fJe7qAXMvWaeW1T3d3J3NsdjtNiYy0npktG0eyTpzQePBqQ9GMnBX3RpH/BoJFpHP9eG 25gP9m5Cpy1ku8d7GIfR/cdGkUsJcxiifCQLUDIBqXh6Z42ztkgss4Wt7arv6jXSl3hO LwPJMDxl/jKfdB1O5fvyqjKY1BmgZPQ3GqOVrEbQvaIcLIJXIUspRTRB2nJv5rulfbK9 bMuVEZKDBIAuj/bJtqPESORW/N3O/Sc/kE/7lBXOukUzBKYOiFCFb8gLn15jKnvgwMU8 4GYA== X-Forwarded-Encrypted: i=1; AJvYcCVuaSfX7iQrPwcD/7q4JbEaOCTkuvwfXRqBIM8Nfm3oPQvQHpBY4MHOflUiuREPA4ne4CRn3O58GXXJ4hQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyeuZ+Rv3BCijIIBgmgSnyfDleW9OQRh0HONrRPpXzWUksQ9AF9 rOwSvoOBbZZfKMwr7zQh9pZb2rdsRnqOfm/9b7XYpzN4U1s9acQgY4g7 X-Gm-Gg: AY/fxX4cbRYHwcK4R0myZ6xpCpeORhtZvsU7A0b1KVSHE+/K5yCR34owprXivoHcklY uuUffCGEjLqbZiNOz0vy7K+GDZ/pbH+Ur6Wb8lzBieLigWn4rP2aJSO6OLLAUzuE5xPrBIU/mja r88Kt77Pz9y8ezyrMg+i4VeQ93se7ixP5q1/NFa4C2RWr9om9l0YtmcWW4LsjNZ41EGcs+vOyzo cwa5QqK4GGXl8hcrIQj0wl/lJnuy/hQfTp69BlVVab060UyXXQJzGQFRCV/tHFuvyKMQ9nC1MNW N71Pjf15ZjbWP7TO46/0T7z1MCfKRKO3ow7Dkxl6VVXebYhbJ+OeUa/YutwXa0LTjktyWeWA5OE KKy9kkyvCunn2ySh8S45xJhmSN2kupxU+Y0mKpM2yPrvmhAIT4CXkeypuzkL+c1cLDzROufzEzW 3luP4g/0r7me9YBA6mDeXBYEEh53BvCvQx0d9VyF1UyvXzQEI= X-Google-Smtp-Source: AGHT+IHFuEiGcW0GH4lABrKUUSbE6qv7huuMOYC9DtT8UyxlS9XUtUukZA6W5M9Qt9zONS5q8T2xVg== X-Received: by 2002:a05:690e:128c:b0:63f:ab00:1a07 with SMTP id 956f58d0204a3-64555643a56mr9274950d50.49.1765848124847; Mon, 15 Dec 2025 17:22:04 -0800 (PST) Received: from devvm11784.nha0.facebook.com ([2a03:2880:25ff:58::]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78e748cecd9sm34175187b3.9.2025.12.15.17.22.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Dec 2025 17:22:04 -0800 (PST) Date: Mon, 15 Dec 2025 17:22:02 -0800 From: Bobby Eshleman To: Stefano Garzarella Cc: Paolo Abeni , "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 Mon, Dec 15, 2025 at 03:11:22PM +0100, Stefano Garzarella wrote: > On Fri, Dec 12, 2025 at 07:26:15AM -0800, Bobby Eshleman wrote: > > 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? > > Hi Bobby, AFAIK Paolo was at LPC, so there could be some delay. > > FYI I'll be off from Dec 25 to Jan 6, so if we want to do an RFC in the > middle, I'll do my best to take a look before my time off. > > Thanks, > Stefano > Sounds like a plan, thanks! Best, Bobby