From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=67.231.153.30 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796159195; b=RmsTHJkn9OoaXhDOhfB+dGEQ2jhAP9xrqGLlZD3c8oPYLK00vJqF0ea7DYms8oVZUGNb pWdQAZAbnpuMWV23DkMumJNItYZIDr9c5/ycw6bRp6+ZigQt8Dj5Eiz6C+bmtJKHu2Vra +1sgTIfS/cHf2TvCXnSuCMRoKBcjp9U8oP7DtHKczhO9AIFOk63oMu5oX7QGOoWgN/2aN XwP2mW8jVofjV8mgxODumo2xBBB369zfzH076infHcBcAsW3dQ5v4Q9IAdoADC0OS9Lbr DqRM7+Dd8n1SiOaM3PYUJAsqWa3JkP5v6Y4SuoA9m6nB+I5IQerAaecfDFiRx9xMZXA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796159195; h=DMARC-Filter:Received:DKIM-Signature:Received:Received:Date:From:To: CC:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-Originating-IP: X-Proofpoint-ORIG-GUID:X-Proofpoint-Spam-Details-Enc: X-Proofpoint-Spam-Info:X-Authority-Analysis:X-Proofpoint-GUID: X-Proofpoint-Virus-Version; bh=XWt7YIV33luiUMx25XePIlFpu7NbQ4SVr22t2kzX8rQ=; b=x2y/+lCWUadQ1j7KN7pPrxSIg7WQCqVjXlxWyzyrzpE5kb4XyKuB3zlVxCCSsM6oNdTc Y0IMEaHiRWxKR7zlkXgi0rIpYbvrhb7Cm2EV4PId4Tdiw+axp96dti/6Qglceu9wWpOqP PU+69wDyNHmHLaCxBeZKxy+PqsDDvYpm92yM5ZktKpm+NzZ8SbD9AsBwFXUARofNgWWvr BhzLN4Vf1YabMk+GrOKShsFHeD5U7HLj5OGvA1JyQKXtZOJvdLkcXUbf7Lh55nZOnTum0 YnfdPNzc1ElpGG/SEAoLtOHnheEIjiZqALPA/0l4bWJHSeSCHUrttn3iOCZbaRaC+Kw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=meta.com; spf=pass smtp.mailfrom=meta.com; dkim=pass header.d=meta.com header.i=@meta.com header.a=rsa-sha256 header.s=pps82601-s2048-2026-q3 header.b=FiYXbY6L; arc=none smtp.remote-ip=67.231.153.30 Received: from mx0a-00082601.pphosted.com (mx0b-00082601.pphosted.com [67.231.153.30]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 79BA0606A320; Tue, 1 Dec 2026 21:06:34 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 79BA0606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=meta.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=meta.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=meta.com header.i=@meta.com header.a=rsa-sha256 header.s=pps82601-s2048-2026-q3 header.b=FiYXbY6L Received: from pps.filterd (m0001303.ppops.net [127.0.0.1]) by m0001303.ppops.net (8.18.1.11/8.18.1.11) with ESMTP id 6B1J0VnF1580431; Tue, 1 Dec 2026 13:05:57 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meta.com; h=cc :content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to; s=pps82601-s2048-2026-q3; bh=XWt7YIV33lu iUMx25XePIlFpu7NbQ4SVr22t2kzX8rQ=; b=FiYXbY6LU8uJG2KMTlePOsslw8Q pwFwBACVWR1xoHsZJgdmiF8TFxvsgVYT5nouP8D1VX78r64uRpzqtkFw2XanmcH7 H7GIHQbT3Qx3Lzt+QBjE0LL9DIFF9HBjNcaaCcQrlfKST7Hotq9bUlVqrnN3fqsH oo4Vy+KytB3AeD2omK3pcULo0t0HMuMoO2p1VYfxPWVQ7ZAEqHIomNrsjKIAjVAn AH+8Yn7SlaM1baVHtmKUGXXtVtE3WiBLJ5yXW4bFNzJLUxP405qIMUq4bXdxPri0 oEqyP6ywInQOgr+4jZQ5UMwuEvESRQCcYjkoY44CR0vYFunGm4fT3sFy3/Q== Received: from maileast.thefacebook.com ([163.114.135.16]) by m0001303.ppops.net (PPS) with ESMTPS id 4j9s4uwp1m-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT); Tue, 01 Dec 2026 13:05:57 -0800 (PST) Received: from localhost (2620:10d:c0a8:1b::30) by mail.thefacebook.com (2620:10d:c0a9:6f::237c) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.2.2562.56; Tue, 1 Dec 2026 21:05:56 +0000 Date: Tue, 1 Dec 2026 13:05:55 -0800 From: Bobby Eshleman To: Michal Luczaj CC: Stefano Garzarella , "David S. Miller" , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Stefan Hajnoczi , "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Eugenio =?iso-8859-1?Q?P=E9rez?= , Shuah Khan , Randy Dunlap , Donald Hunter , Eric Dumazet , George Zhang , Andy King , Dmitry Torokhov , Willem de Bruijn , , , , , , , , Subject: Re: [PATCH net-next v8 4/7] vsock: add a netlink command to assign the g2h device to a netns Message-ID: References: <20261130-vsock-guest-ns-v8-0-5fff852d325b@meta.com> <20261130-vsock-guest-ns-v8-4-5fff852d325b@meta.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: X-Proofpoint-ORIG-GUID: 9hx1omB7yETg2D6eHBwC9bzymyjCudxC X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYxMjAxMDA4NCBTYWx0ZWRfX7yN86C1K3jtI lk7hWPJoPvfoTTvld6u7dspsPK2RJ2unOsA62KYrQ6nMeOrrpnpHSpOnvQ5jk0SLgD/U6+LP+1R 4vlwN2pizrN5X2ss6X9yUW4wsVRO5pKATRRRDLZwtUjhJi8i7E497/d3SlnuukkgoGAsVEb4Cem GFfANzbKiDsracPNGLwJ41+KJjPnzc9HU9TEpZjjBzIelmZpLPE2Phl5Dr2F7PoPzbQXB2NW1Ap QrfvaHwhgbsbT4/QCwZ9BJVA/XRAkzB5R1cPG83H+JaZ/7GoA+IxIpQnZomuV3EaGWy7Pyp5aY/ LDnrSz2vBPGftDWZImXI8uEvttPYUeqvRRSv8I9IF0V+ED/YlMy8LfJqELQZJ1uq9Qgh86LaDPH oCEEvN3IoPppilVtU8UEYul4mUcScBHqdTdOqilKp275wJTCtR4p9sYuCYF6oNF1hlLVKeiZBxl lq6r0eXGZxS2kOERAjA== X-Proofpoint-Spam-Info: AW1haW4tMjYxMjAxMDA4NCBTYWx0ZWRfXyhcZw4AjvPhP IluvJ1bP1WdFB9ANvRBZJ9CjGVdvNO5te5KN8GLCKlZSvLpmp+UnKx4W7c+d8KWTLwxqDlZRHzw iJCSpj9Xhso+29YBqWsCJ0Jb5lk06zw= X-Authority-Analysis: v=2.4 cv=c+w+0h9l c=1 sm=1 tr=0 ts=6b0f36b5 cx=c_pps a=MfjaFnPeirRr97d5FC5oHw==:117 a=MfjaFnPeirRr97d5FC5oHw==:17 a=kj9zAlcOel0A:10 a=pUM-KoujPXoA:10 a=VkNPw1HP01LnGYTKEx00:22 a=7x6HtfJdh03M6CCDgxCd:22 a=_78whYxrdx1mplLwxq1U:22 a=xJ5ZKgryoKWtXFi_b2kA:9 a=CjuIK1q_8ugA:10 X-Proofpoint-GUID: 9hx1omB7yETg2D6eHBwC9bzymyjCudxC X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.138,FMLib:17.12.100.49 definitions=2026-12-01_04,2026-12-01_01,2025-10-01_01 On Tue, Dec 01, 2026 at 05:19:31PM +0100, Michal Luczaj wrote: > On 12/1/26 02:06, Bobby Eshleman wrote: > > +/* Reset @sk if it can no longer reach the g2h device, as an unplug of the > > + * device does (see virtio_vsock_reset_sock()). > > + */ > > +static void vsock_g2h_reset_unreachable_sk(struct sock *sk) > > +{ > > + if (sk->sk_state == TCP_CLOSE || vsock_g2h_reachable_sk(vsock_sk(sk))) > > + return; > > + > > + sk->sk_state = TCP_CLOSE; > > + sk->sk_err = ECONNRESET; > > + sk_error_report(sk); > > +} > > ... > > > +/* Move the g2h device to @net, which keeps @net alive until the device leaves > > + * again. Returns -ENODEV if no g2h transport is loaded, -EOPNOTSUPP if the > > + * loaded one cannot be moved, and -EADDRINUSE if a guest in @net already uses > > + * the device's CID. > > + */ > > +static int vsock_g2h_net_assign(struct net *net, struct sk_buff *msg, > > + struct genl_info *info) > > +{ > > + struct netlink_ext_ack *extack = info->extack; > > + netns_tracker old_tracker; > > + struct net *old; > > + int ret; > > + > > + mutex_lock(&vsock_register_mutex); > > + > > + ret = -ENODEV; > > + if (!transport_g2h) { > > + NL_SET_ERR_MSG(extack, "no guest-to-host transport is loaded"); > > + goto unlock; > > + } > > + > > + ret = -EOPNOTSUPP; > > + if (!vsock_net_assignable(transport_g2h)) { > > + NL_SET_ERR_MSG(extack, > > + "the loaded guest-to-host transport does not support namespace assignment"); > > + goto unlock; > > + } > > + > > + if (transport_h2g && !transport_h2g->has_remote_cid) { > > + NL_SET_ERR_MSG(extack, > > + "the loaded host-to-guest transport cannot check the device's CID"); > > + goto unlock; > > + } > > + > > + ret = -EADDRINUSE; > > + if (transport_h2g && > > + transport_h2g->has_remote_cid(net, > > + transport_g2h->get_local_cid())) { > > + NL_SET_ERR_MSG(extack, > > + "a guest in the target namespace already uses the device's CID"); > > + goto unlock; > > + } > > + > > + ret = vsock_nl_dev_netns_fill(msg, info, net); > > + if (ret) > > + goto unlock; > > + > > + ret = genlmsg_reply(msg, info); > > + msg = NULL; > > + if (ret) > > + goto unlock; > > + > > + old = vsock_g2h_net_swap(net, &old_tracker); > > + > > + /* See vsock_maybe_set_connected() comment about synchronizing with > > + * connecting sockets. > > + */ > > + vsock_for_each_connected_socket(transport_g2h, > > + vsock_g2h_reset_unreachable_sk); > > + > > Are you sure a lockless (sk_lock-wise) reset is the right approach? I was > hoping we could "reuse" vsock_g2h_reset_unreachable() from v7 to finally > fix all those lockless transport resets. With this version, instead, we're > introducing more lockless socket state writes. > > thanks, > Michal I definitely agree with that goal. But since the lockless resets are a broader vsock issue (virtio_vsock_reset_sock(), vhost_vsock_reset_orphans(), vmci_transport_handle_detach()), I'd like to treat them as pre-existing for this series and fix socket state handling across vsock in follow-up patches. Long term I agree with using lock_sock(), but in this series AFAICT it mostly just prevents an inconsistent state that doesn't affect the user much (mid-sweep RX RST resulting in TCP_CLOSING instead of TCP_CLOSE, w/ ECONNRESET). I'm just not sure I see a big enough win to justify the extra complexity of iterator functions, the extra mutex, etc... (additional ~75 lines of code) for this series in particular. Best, Bobby