From nobody Tue Feb 04 15:06:00 2025 X-Original-To: dev-commits-src-main@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 4YnRWr6qFkz5mxFw; Tue, 04 Feb 2025 15:06:00 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4YnRWr64f3z4GgW; Tue, 04 Feb 2025 15:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738681560; 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=5Lfg1wD7gHt/CCN0u1UXWt64gzyjeU9qpfaRyPh1tf4=; b=pZ33FHoZt8S3c3fKlEsnvSq7bziZcVQEL0MPCEFyBElX6Af+06q2C1ACK8EuBd4Ghor8aR ZpOY+HU+Yut60nCgdLDHjJHbH6LQ/DRLZlc6ES1+EISsW9xcABtVrcfu1dDfxgNNhYBU0L wXwkT02rphW+GO9XcwnJ9NZwombYBxVGpHmnq/bgTiedd0lhObUnddVxGS5SSLRvxiA24s JwZhT4wWxUP34UlRsUnOMGnwdKfNnGkLDr8PiWd0YeDOV16Xwhsy5ryOj+4fII1LUkb9if U1e9/OGVrpiASJ16P94/e7VVZzOYoOWm+B79b97eocnftHIYFsLSiWtWxPaGFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1738681560; 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=5Lfg1wD7gHt/CCN0u1UXWt64gzyjeU9qpfaRyPh1tf4=; b=vdEeZpOL7EN2aThTGH6571DWcdmLaG4PIqQZdjgUYz0PaN895ePjRnZ4rI7Ce1hhi70D1B 0T/NqkDpePhwdUyNdXSF3eelu7pR9MiYzKK/6pvfCFHovbAPIe44g54m9M3yVhUIuu5xh8 MRr2Ai4r4HfiUXd1uvcfs9HO3gXLUSdYUho5sGBoXY8A28R+fYwoCoEl1DTwCCeB7AnZKh UuCPc7nCZRgBMMoAjVST/Thbm1+QLjLh+dGqQ0OFSS2N9ebqCJlaVQv7R1UQnmGYeBvV9S EqxaaouDHtlGC2gQH8Hfietn03tc4V5Ffvik0QpNgbBLXuEd1loHFcvblIREIw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1738681560; a=rsa-sha256; cv=none; b=wU9Q+l94+qvCr30B94AYRlc1vgVUDnl6+ZHS4HMrvNE8UqZ5XoWhEAVhaBaYZCN4inVXX0 hbxGUfqSJPgFHBumGZ0Zee9Pv9jGlltFV/2UyDGeh+SO6yE5zdwLmRPVL8/OrCULDGnigd 82/92S37GhiPxszzUgPt2KRteNT/ejzGOIiQ1DK3sGxup5DVM9dB98pyKiAvzza3qcOq7H /C8ag98EAc0e2MeIq5SqVb4E4oeZsUTaTiPWOlFoAOHfANpYPNY8Sre9AbHEjZdYlJ6i9y IHP1HceyTcjvCWUpgNVoRO8zdhmjZ/Ycn3Mu0qvBZMnDONYCDb3BOM+OaVn+Aw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4YnRWr5HX2z1Q8n; Tue, 04 Feb 2025 15:06:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 514F60i9041394; Tue, 4 Feb 2025 15:06:00 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 514F60pw041391; Tue, 4 Feb 2025 15:06:00 GMT (envelope-from git) Date: Tue, 4 Feb 2025 15:06:00 GMT Message-Id: <202502041506.514F60pw041391@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Zhenlei Huang Subject: git: bb0348a17974 - main - ifnet: Make if_detach_internal() and if_vmove() void List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org 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/main X-Git-Reftype: branch X-Git-Commit: bb0348a17974d83671becbd32ea0e4bd2ea61906 Auto-Submitted: auto-generated The branch main has been updated by zlei: URL: https://cgit.FreeBSD.org/src/commit/?id=bb0348a17974d83671becbd32ea0e4bd2ea61906 commit bb0348a17974d83671becbd32ea0e4bd2ea61906 Author: Zhenlei Huang AuthorDate: 2025-02-04 15:04:59 +0000 Commit: Zhenlei Huang CommitDate: 2025-02-04 15:04:59 +0000 ifnet: Make if_detach_internal() and if_vmove() void if_detach_internal() never fail since change [1]. As a consequence, also does its caller if_vmove(). While here, remove a stall comment. No functional change intended. This reverts commit c7bab2a7ca9a6dae79f970c6730a19b65a1ed86e. [1] a779388f8bb3 if: Protect V_ifnet in vnet_if_return() Reviewed by: glebius MFC after: 3 days Differential Revision: https://reviews.freebsd.org/D48820 --- sys/net/if.c | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/sys/net/if.c b/sys/net/if.c index 08c59627b196..504550414bb7 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -285,12 +285,12 @@ static int if_getgroup(struct ifgroupreq *, struct ifnet *); static int if_getgroupmembers(struct ifgroupreq *); static void if_delgroups(struct ifnet *); static void if_attach_internal(struct ifnet *, bool); -static int if_detach_internal(struct ifnet *, bool); +static void if_detach_internal(struct ifnet *, bool); static void if_siocaddmulti(void *, int); static void if_link_ifnet(struct ifnet *); static bool if_unlink_ifnet(struct ifnet *, bool); #ifdef VIMAGE -static int if_vmove(struct ifnet *, struct vnet *); +static void if_vmove(struct ifnet *, struct vnet *); #endif #ifdef INET6 @@ -1113,7 +1113,7 @@ if_detach(struct ifnet *ifp) * on a vnet instance shutdown without this flag being set, e.g., when * the cloned interfaces are destoyed as first thing of teardown. */ -static int +static void if_detach_internal(struct ifnet *ifp, bool vmove) { struct ifaddr *ifa; @@ -1244,7 +1244,7 @@ finish_vnet_shutdown: ifp->if_afdata_initialized = 0; IF_AFDATA_UNLOCK(ifp); if (i == 0) - return (0); + return; SLIST_FOREACH(dp, &domains, dom_next) { if (dp->dom_ifdetach && ifp->if_afdata[dp->dom_family]) { (*dp->dom_ifdetach)(ifp, @@ -1252,8 +1252,6 @@ finish_vnet_shutdown: ifp->if_afdata[dp->dom_family] = NULL; } } - - return (0); } #ifdef VIMAGE @@ -1261,19 +1259,14 @@ finish_vnet_shutdown: * if_vmove() performs a limited version of if_detach() in current * vnet and if_attach()es the ifnet to the vnet specified as 2nd arg. */ -static int +static void if_vmove(struct ifnet *ifp, struct vnet *new_vnet) { - int rc; - /* * Detach from current vnet, but preserve LLADDR info, do not * mark as dead etc. so that the ifnet can be reattached later. - * If we cannot find it, we lost the race to someone else. */ - rc = if_detach_internal(ifp, true); - if (rc != 0) - return (rc); + if_detach_internal(ifp, true); /* * Perform interface-specific reassignment tasks, if provided by @@ -1288,7 +1281,6 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet) CURVNET_SET_QUIET(new_vnet); if_attach_internal(ifp, true); CURVNET_RESTORE(); - return (0); } /* @@ -1299,8 +1291,7 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) { struct prison *pr; struct ifnet *difp; - int error; - bool found __diagused; + bool found; bool shutdown; MPASS(ifindex_table[ifp->if_index].ife_ifnet == ifp); @@ -1347,16 +1338,15 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, char *ifname, int jid) } /* Move the interface into the child jail/vnet. */ - error = if_vmove(ifp, pr->pr_vnet); + if_vmove(ifp, pr->pr_vnet); - /* Report the new if_xname back to the userland on success. */ - if (error == 0) - sprintf(ifname, "%s", ifp->if_xname); + /* Report the new if_xname back to the userland. */ + sprintf(ifname, "%s", ifp->if_xname); sx_xunlock(&ifnet_detach_sxlock); prison_free(pr); - return (error); + return (0); } static int @@ -1365,7 +1355,7 @@ if_vmove_reclaim(struct thread *td, char *ifname, int jid) struct prison *pr; struct vnet *vnet_dst; struct ifnet *ifp; - int error, found __diagused; + int found __diagused; bool shutdown; /* Try to find the prison within our visibility. */ @@ -1406,16 +1396,15 @@ if_vmove_reclaim(struct thread *td, char *ifname, int jid) found = if_unlink_ifnet(ifp, true); MPASS(found); sx_xlock(&ifnet_detach_sxlock); - error = if_vmove(ifp, vnet_dst); + if_vmove(ifp, vnet_dst); sx_xunlock(&ifnet_detach_sxlock); CURVNET_RESTORE(); - /* Report the new if_xname back to the userland on success. */ - if (error == 0) - sprintf(ifname, "%s", ifp->if_xname); + /* Report the new if_xname back to the userland. */ + sprintf(ifname, "%s", ifp->if_xname); prison_free(pr); - return (error); + return (0); } #endif /* VIMAGE */