From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) (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 BDB552DAFAB for ; Fri, 7 Nov 2025 02:52:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762483940; cv=none; b=DzNAnVm60x3om29DabkeYA3CCym4dsUYE2L6Vf7NvNVcOhWA9DSIJrCxW4EftPddNdknTU6bkvQmnjMHz5LROklRxiomL29Ah21ZSqyE0xKmJyiaX3NGS+SCVpuYzws47jQzrKjOoiiffD/e8QCRCBHkD5kN9PVcV5zoMgR6H9U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762483940; 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=jZ9KUutBxFw46Ip1BaPbtyBK1jnf9VpZ7MWUzooR7Q8D/03KI++3jOHR6S7pFg0T4NXN+J/+uycItBgUe00sGzeatX8xGjEdybmyQOPu2nhgzgQpOudVeTwzD2gpKaxF0TY4Dj43x74JoXy9msMAlQR2X15vq3UU0/c8b6hcyn0= 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=209.85.128.172 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-yw1-f172.google.com with SMTP id 00721157ae682-7864cef1976so3977687b3.0 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=kUqbVNbnZ39SFBdcpxvh3NTAPuDbINx1lyssnlFI0Kyv3Tm9/Q0wNWH9PQoPJ86o2a +bMV0nOhBNOOyXFeUw+dI23NSu/SpLtG2RCQGpHTp8xwzMIi673aPVva3qLawZJtw2ce 7bJfZn+GFurqf8tzHSb1TuuATBjz7LaSHccgJhOYBIIVI/rWhyGn4S1r3/danOGhBSz6 3tDU4dLFaMM6umzD4e+rll4E3sVM8ygxBQq08RauCBQQLhBegUq0VI1/WSvnf/G1pdF1 V9qwgHRtzOS9LtanJIcthgNp//El3JPxrn+xdh7QOidVhi/AtgZXTCyuPIX0VXcJLZ00 uycg== X-Forwarded-Encrypted: i=1; AJvYcCVNgdXlgbvOCMf49E3Olks3GHquqFfGUjQRmTbgxG3Lzpfh4DyRFdw43rpBU6IwYxuz2V4=@vger.kernel.org X-Gm-Message-State: AOJu0YwRUTBo395w0W8Liez527FQDIBPWP9H5RNtsrFvHb1JjFJ4LgVw YpjIha7S7kXKdauyYqzLBwAHhc6IQiJa51mUczFYzJthpIcM41HL2q5+ X-Gm-Gg: ASbGncvp31quJGIL71U4A2enu33mFLdyIQ7nV/+2Kk6DNRUknbFlC5reYRPZtQ86BPp r0z+AymbegWK0Ng1gq6GtIbYWcm5lh8e0uwPeEbiiakIsX5a/0dAE3bUrgEJoTyCgXWw8m+UffH u1x8tSFAotyXlHZkx2DlpGoLZVNKVtR8bXVJ2YtxtFi+FhO/ddpq0lhuTxKr5DGn6iG8HZrMoTj 4fASqh7Qv3oqlnG2P2Znxcm3wHxHwKXXMtX2YQ2aefW8xZfKEcLWAoN3X0EEhZAHpJ+b7j1xbfb mM6Bqxu2ItNlvqJALEqrf6U26Z2IEVl6cT0+owi+rFS3fuK9YKHPszhp2b48bajp/zIt2TzQvQq ivDpsBmgpZp9Ggva77iwzoTiJc+Esk9rylBXHKt2LsDI0K16bcHLSvZo7MOAwUMloy/E+84A+bt +Nu6uX5SzjyVQE2R9yCn6mfY7J9eM3aNEiKD7G 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: kvm@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