From nobody Mon May 4 16:51:16 2026 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4g8SMn0NYcz6brK6 for ; Mon, 04 May 2026 16:51:17 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R13" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4g8SMm5hzpz3wGG for ; Mon, 04 May 2026 16:51:16 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777913476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Au7gABmffUhGbkYGRTyCOEV5VD+3aQ8D6cGtJlOfP3I=; b=rkItKGztRkzWKvIyMOyRtObkD2/l8di80ojb6jsoZd9w6gswvrxLEyytOQSrlYqlAOMDQt 5wk8kS+WjeKglCmVF4+ft+/OJ2pmd5yCNwkct1Df8WN10Gfd3cGMPFaef9fN3kJkOTA5OA yMNmE+z6/uaGLX+R+nkKFxLFjueeEtvSKrWNodhTxUvOp4re30S/dW2Z+tGB9JU1TMQOok TjKQkTV5ogL6B1Aw56n78cQz9tjwseT7tAUa2Fq1h81pThHS0WBu/BhEmroQEEn2J+o26H ++xGmpbTz1tWKtPKBjfXuJaxdCYXWFnNhMYHoyofzqxCDpSLwQhXB5jLLFi+jg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1777913476; a=rsa-sha256; cv=none; b=eNjivZB5JE2QSvm9C6bmxH7PD7nfVilusSyU1cqMAg4u5Tkas4kp/6gfWSOcj3NMfZqDSL 2J/R8Ay5OAS/F4fdvLZq0Ml1FSVR4WZy3CZRRoXwQrVFcgIzQorSsOfZ50X7+7nxF5fIgV 9rBOrsWom1LGm/51hqZ1G5MyQWJl3B40/NkfqHM3CPtclvJepbjMFT+SqLVX4hF2E/1Iki xmp1BiJnu4DGJ3/ctBTOAIcBjYmf2U/NYR1j2M5XEx8eWTz98wo26Qrim1+7noXjigGYrP lVuNViUVIm9lW6cSCchUhWI/w0hK1bcd34DbMBC5fNpvqtXGasdWI7/wAFq0mQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1777913476; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=Au7gABmffUhGbkYGRTyCOEV5VD+3aQ8D6cGtJlOfP3I=; b=dJeRE3ro9hvMoEwN/vEOjtUVb4VnStkGSzir7pEelbQOw4ZynAaVncjm/XcrckFLvRocpO hAHxWwnYyKoSbyfL9OjYjyrXW8i8qcQSXS351/WBM83HQwj2QIYGXsV87wYnWXiarRPM8n UKi48VofCFjGuhBhxwAJgd82LWbXmLsiOOBzViXkCqw+B781oaQipdpaekuP+kRt7htZrp trxctnqUjFigKMffeoOygrJ53jsv1xHOYh7bNnG7aWUwO32eL2uJXxquf4tNRDJdFoEBCi uXEshYE3LbopeUCDAF8+zt04fSioGIshl+2ehgwwRf635khEF7CLsR/a0A4lEw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4g8SMm5JNCzCrR for ; Mon, 04 May 2026 16:51:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 27310 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Mon, 04 May 2026 16:51:16 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Zhenlei Huang Subject: git: 328598079b56 - stable/14 - ifnet: Move SIOCSIFVNET from ifhwioctl() to ifioctl() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: zlei X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 328598079b56bb007d8baa065be603b992b4da6d Auto-Submitted: auto-generated Date: Mon, 04 May 2026 16:51:16 +0000 Message-Id: <69f8ce84.27310.34af862b@gitrepo.freebsd.org> The branch stable/14 has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=328598079b56bb007d8baa065be603b992b4da6d commit 328598079b56bb007d8baa065be603b992b4da6d Author: Zhenlei Huang AuthorDate: 2026-04-13 04:38:44 +0000 Commit: Zhenlei Huang CommitDate: 2026-05-04 16:49:41 +0000 ifnet: Move SIOCSIFVNET from ifhwioctl() to ifioctl() SIOCSIFVNET is not a hardware ioctl. Move it to where it belongs. Where here, rewrite the logic of checking whether we are moving the interface from and to the same vnet or not, since it is obviously not stable to access the interface's vnet, given the current thread may race with other threads those running if_vmove(). MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D55880 (cherry picked from commit 38bd7ef62f318f791e232e217855307a9d75efa0) (cherry picked from commit 477c3ba3673152e88ec5c50d8f45db24102bdf07) --- sys/net/if.c | 44 +++++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index c4c2df61dd1d..f34e35549e03 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1304,26 +1304,39 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet) * Move an ifnet to or from another child prison/vnet, specified by the jail id. */ static int -if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) +if_vmove_loan(struct thread *td, char *ifname, int jid) { struct prison *pr; - struct ifnet *difp; + struct ifnet *ifp, *difp; bool found; + MPASS(curthread == td); + MPASS(curvnet == TD_TO_VNET(td)); + + /* + * We check the existence of the interface, and will later try to + * unlink it from the "active" list, so it is sufficient to only + * hold a weak reference to it. + * Be aware that it is unsafe to access any member of it, until it + * is proven to be safe to ( say it was on the "active" list ). + */ + ifp = ifunit(ifname); + if (ifp == NULL) + return (ENXIO); + /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); pr = prison_find_child(td->td_ucred->cr_prison, jid); sx_sunlock(&allprison_lock); if (pr == NULL) return (ENXIO); - prison_hold_locked(pr); - mtx_unlock(&pr->pr_mtx); - - /* Do not try to move the iface from and to the same prison. */ - if (pr->pr_vnet == ifp->if_vnet) { - prison_free(pr); + /* Do not try to move the iface from and to the same vnet. */ + if (pr->pr_vnet == TD_TO_VNET(td)) { + mtx_unlock(&pr->pr_mtx); return (EEXIST); } + prison_hold_locked(pr); + mtx_unlock(&pr->pr_mtx); /* Make sure the named iface does not exists in the dst. prison/vnet. */ /* XXX Lock interfaces to avoid races. */ @@ -2701,15 +2714,6 @@ ifhwioctl(u_long cmd, struct ifnet *ifp, caddr_t data, struct thread *td) error = if_rename(ifp, new_name); break; -#ifdef VIMAGE - case SIOCSIFVNET: - error = priv_check(td, PRIV_NET_SETIFVNET); - if (error) - return (error); - error = if_vmove_loan(td, ifp, ifr->ifr_name, ifr->ifr_jid); - break; -#endif - case SIOCSIFMETRIC: error = priv_check(td, PRIV_NET_SETIFMETRIC); if (error) @@ -2997,6 +3001,12 @@ ifioctl(struct socket *so, u_long cmd, caddr_t data, struct thread *td) ifr = (struct ifreq *)data; switch (cmd) { #ifdef VIMAGE + case SIOCSIFVNET: + error = priv_check(td, PRIV_NET_SETIFVNET); + if (error == 0) + error = if_vmove_loan(td, ifr->ifr_name, ifr->ifr_jid); + goto out_noref; + case SIOCSIFRVNET: error = priv_check(td, PRIV_NET_SETIFVNET); if (error == 0)