From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yx1-f50.google.com (mail-yx1-f50.google.com [74.125.224.50]) (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 B901625D53C for ; Fri, 7 Nov 2025 02:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.224.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762483941; cv=none; b=DtXGQBafN5f/tYQ7aeG0H3B4WaJ4ZPWTStYcowOs1gs0XlNzGttQdtGBHOhiLNA8a5c1IdCKN2kjNOBOvuVtIgsIcqA4GHplBXUmwwxtvB/8PtFve4DzyFTMO5MT+59AJ+GnoMXfHp2zZ2Ix6OWFqi8bqqjhqX480Mf3v5V6Tac= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762483941; c=relaxed/simple; bh=LGZkf7YP6OLV6kK3Rv7CYUIiRvg3i+u7/aOFPhkBPKg=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=URxQYwFCpE26Omkd30aroVDCj1xQOXNE8NIBHU1uTNFtOBBO7lnqxJiLi70YPrIcWxNW9s6yQVAkAAk50q2DEKqBKqXDydrUBl+cTJURUnjsnMnLTY6YTpp9a7eM6o9lHKzSEfu05QzmwuqZjMSGhQFg57RdinGUSgFBttZuY28= 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=kJF2I0X1; arc=none smtp.client-ip=74.125.224.50 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="kJF2I0X1" Received: by mail-yx1-f50.google.com with SMTP id 956f58d0204a3-63e336b1ac4so390458d50.1 for ; Thu, 06 Nov 2025 18:52:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762483938; x=1763088738; 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=to+M3YH5XNWJ8sgc76iueqXwuR+T+gGj83wJZ0qaDfw=; b=kJF2I0X1AKqT9qXyqG+VcidrqeN5gvl0jJRs2IONlijFLouYtf02uxAT5wGnSrLEpN Tp8/Zk2GFMhBzcmxkrkU9iHoerpdmNlyI+SIRMdHSdG34P9nOmE4VR6alI7kqLDI7TGQ zyyV7eZDwNMWoPK557DH6O7DpBHedIX0MoSdobE1CllqN7uIIgbXl7rOKBTTeGBMVyDy c3qte+sOn7hqBWkEohW+68dxlsTdQ8bcAW81aVvEfEVdG74BUsUvEj3tcmUgBCnsvfK6 8SzLU8EwY+KiJfYM6GKiTvic+s0pTs7NfwYOT6NEnZpxAX0FIUso1KGlABN5oDqJpyin f2Xg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762483938; x=1763088738; 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=to+M3YH5XNWJ8sgc76iueqXwuR+T+gGj83wJZ0qaDfw=; b=WP5u/kPXIrZfPaIC8ZABTBuidGYTIVDBWSELQ7sDX+vxGlsMYih3rfnJJzkJquXwb3 gXVdYDRaNK4pzQzM3CcX1jpTwnlYxydSk6LcKj2QeCL6zJe2mFUbBYUH8p10necL2jlN IB/k/cu8CrRgh27CBKNT0yv945sav6iIw7De/qW5HdUu6+kObJ3A3iphcyXHJOTsVNO1 NWOuKiroee7fSiNsCi9pZp5MQpM8kU7AP1yd5zxgoFlNDGSzSh5dRB6nGzW04vDcbrTd r3CT3jxokZU4txJh0pjY9OyUU3VVNQch+g2fYtvtsNNAPMl1Mhk0CZzksx+WzMCraNQE gHIA== X-Forwarded-Encrypted: i=1; AJvYcCUdnF/3kjdAb7/ku2D7rmj8HOCDfkku9jPVdlqP0qWqk3/4RG4CQ/7t1PofuzDtoJh9sOWGtqZuya5VDDw=@vger.kernel.org X-Gm-Message-State: AOJu0Yyx2gFWNLy4Z2O323wlLH0HpXkXRVpqHfv06s48Mhz9+G5AvPEI EKalYmcWXl7/V1U35fAaBjTgJwQSYVRx+RJ5zaAq3DS2IlqUZgmhtfzI X-Gm-Gg: ASbGncuHfUYThaIi8jcKxLxUYhGoBHp6DUrM3t2TOTSNFVjWzVhymhRIPalwtyvF70b FtNCr9gXliVB8z4f9U2gKmOHr5f4bzk6MK3yds4l+R5f+EeuF0/Ha+09UgvONGgyggId7nNt4xZ EB3CP0bXcu7nJxMopWOjI11Jsa+E6KHS55l2AKwfpMrzQ52d8Tgv/O9o+z/Gu5AvI8Yootztlxp ynISi4wAzLQPu0nnjVwb9mOuuxbDvj9rh/ftyoUlGkxXpWzeeBPgGBJ5X79uBdMJyFYtQKyocJw kpyPszK1hC1NeN223H5AZTfKOiV8MJUtn58VflcKj4da5g4PAg4ltR1GG9UmzOhVrgwqZ1jkbc/ FTEq5QwVa7VsC+w3zCQBIKw1V80LQAUICAKZteHoMjK2L5hsjot8ceY43tUYwLqtgYDyP91phhG hcS2hziinB/QudNHEbH+aU68UiH5jy3CX9BFzs X-Google-Smtp-Source: AGHT+IEjmJ3F7jVxmWzAKOE8ZCFLH8yvuCjB7m8mU8An6yxSyAVDGX/tJUnPe0dCIHSXZMA38QvYjg== X-Received: by 2002:a05:690e:4185:b0:63e:1563:4801 with SMTP id 956f58d0204a3-640c9d699f7mr96467d50.22.1762483937682; Thu, 06 Nov 2025 18:52:17 -0800 (PST) Received: from devvm11784.nha0.facebook.com ([2a03:2880:25ff:41::]) by smtp.gmail.com with ESMTPSA id 956f58d0204a3-640b5ca70f7sm1358837d50.12.2025.11.06.18.52.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Nov 2025 18:52:17 -0800 (PST) Date: Thu, 6 Nov 2025 18:52:15 -0800 From: Bobby Eshleman To: Stefano Garzarella Cc: Shuah Khan , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , "K. Y. Srinivasan" , Haiyang Zhang , Wei Liu , Dexuan Cui , Bryan Tan , Vishnu Dasa , Broadcom internal kernel review list , virtualization@lists.linux.dev, netdev@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, linux-hyperv@vger.kernel.org, berrange@redhat.com, Bobby Eshleman Subject: Re: [PATCH net-next v8 06/14] vsock/virtio: add netns to virtio transport common Message-ID: References: <20251023-vsock-vmtest-v8-0-dea984d02bb0@meta.com> <20251023-vsock-vmtest-v8-6-dea984d02bb0@meta.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 Content-Disposition: inline In-Reply-To: On Thu, Nov 06, 2025 at 05:20:05PM +0100, Stefano Garzarella wrote: > On Thu, Oct 23, 2025 at 11:27:45AM -0700, Bobby Eshleman wrote: > > From: Bobby Eshleman > > > > Enable network namespace support in the virtio-vsock common transport > > layer by declaring namespace pointers in the transmit and receive > > paths. > > > > The changes include: > > 1. Add a 'net' field to virtio_vsock_pkt_info to carry the namespace > > pointer for outgoing packets. > > 2. Store the namespace and namespace mode in the skb control buffer when > > allocating packets (except for VIRTIO_VSOCK_OP_RST packets which do > > not have an associated socket). > > 3. Retrieve namespace information from skbs on the receive path for > > lookups using vsock_find_connected_socket_net() and > > vsock_find_bound_socket_net(). > > > > This allows users of virtio transport common code > > (vhost-vsock/virtio-vsock) to later enable namespace support. > > > > Signed-off-by: Bobby Eshleman > > --- > > Changes in v7: > > - add comment explaining the !vsk case in virtio_transport_alloc_skb() > > --- > > include/linux/virtio_vsock.h | 1 + > > net/vmw_vsock/virtio_transport_common.c | 21 +++++++++++++++++++-- > > 2 files changed, 20 insertions(+), 2 deletions(-) > > > > diff --git a/include/linux/virtio_vsock.h b/include/linux/virtio_vsock.h > > index 29290395054c..f90646f82993 100644 > > --- a/include/linux/virtio_vsock.h > > +++ b/include/linux/virtio_vsock.h > > @@ -217,6 +217,7 @@ struct virtio_vsock_pkt_info { > > u32 remote_cid, remote_port; > > struct vsock_sock *vsk; > > struct msghdr *msg; > > + struct net *net; > > u32 pkt_len; > > u16 type; > > u16 op; > > diff --git a/net/vmw_vsock/virtio_transport_common.c b/net/vmw_vsock/virtio_transport_common.c > > index dcc8a1d5851e..b8e52c71920a 100644 > > --- a/net/vmw_vsock/virtio_transport_common.c > > +++ b/net/vmw_vsock/virtio_transport_common.c > > @@ -316,6 +316,15 @@ static struct sk_buff *virtio_transport_alloc_skb(struct virtio_vsock_pkt_info * > > info->flags, > > zcopy); > > > > + /* > > + * If there is no corresponding socket, then we don't have a > > + * corresponding namespace. This only happens For VIRTIO_VSOCK_OP_RST. > > + */ > > So, in virtio_transport_recv_pkt() should we check that `net` is not set? > > Should we set it to NULL here? > Sounds good to me. > > + if (vsk) { > > + virtio_vsock_skb_set_net(skb, info->net); > > Ditto here about the net refcnt, can the net disappear? > Should we use get_net() in some way, or the socket will prevent that? > As long as the socket has an outstanding skb it can't be destroyed and so will have a reference to the net, that is after skb_set_owner_w() and freeing... so I think this is okay. But, maybe we could simplify the implied relationship between skb, sk, and net by removing the VIRTIO_VSOCK_SKB_CB(skb)->net entirely, and only ever referring to sock_net(skb->sk)? I remember originally having a reason for adding it to the cb, but my hunch is it that it was probably some confusion over the !vsk case. WDYT? [...] > > > > return virtio_transport_send_pkt_info(vsk, &info); > > @@ -1578,7 +1593,9 @@ static bool virtio_transport_valid_type(u16 type) > > void virtio_transport_recv_pkt(struct virtio_transport *t, > > struct sk_buff *skb) > > { > > + enum vsock_net_mode net_mode = virtio_vsock_skb_net_mode(skb); > > struct virtio_vsock_hdr *hdr = virtio_vsock_hdr(skb); > > + struct net *net = virtio_vsock_skb_net(skb); > > Okay, so this is where the skb net is read, so why we touch the virtio-vsock > driver (virtio_transport.c) in the other patch where we changed just > af_vsock.c? > > IMO we should move that change here, or in a separate commit. > Or maybe I missed some dependency :-) > 100% agree. > Thanks, > Stefano > Thanks! -Bobby