From owner-svn-src-all@freebsd.org Thu Jan 9 03:52:51 2020 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 6654F226360; Thu, 9 Jan 2020 03:52:51 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 47tXJM27MJz4Y5r; Thu, 9 Jan 2020 03:52:51 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 445B122CED; Thu, 9 Jan 2020 03:52:51 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0093qpSY052790; Thu, 9 Jan 2020 03:52:51 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0093qpd4052789; Thu, 9 Jan 2020 03:52:51 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202001090352.0093qpd4052789@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 9 Jan 2020 03:52:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r356536 - head/sys/net X-SVN-Group: head X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: head/sys/net X-SVN-Commit-Revision: 356536 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 09 Jan 2020 03:52:51 -0000 Author: kevans Date: Thu Jan 9 03:52:50 2020 New Revision: 356536 URL: https://svnweb.freebsd.org/changeset/base/356536 Log: if_vmove: return proper error status if_vmove can fail if it lost a race and the vnet's already been moved. The callers (and their callers) can generally cope with this, but right now success is assumed. Plumb out the ENOENT from if_detach_internal if it happens so that the error's properly reported to userland. Reviewed by: bz, kp MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D22780 Modified: head/sys/net/if.c Modified: head/sys/net/if.c ============================================================================== --- head/sys/net/if.c Thu Jan 9 02:03:17 2020 (r356535) +++ head/sys/net/if.c Thu Jan 9 03:52:50 2020 (r356536) @@ -274,7 +274,7 @@ static void if_attach_internal(struct ifnet *, int, st static int if_detach_internal(struct ifnet *, int, struct if_clone **); static void if_siocaddmulti(void *, int); #ifdef VIMAGE -static void if_vmove(struct ifnet *, struct vnet *); +static int if_vmove(struct ifnet *, struct vnet *); #endif #ifdef INET6 @@ -1257,7 +1257,7 @@ finish_vnet_shutdown: * unused if_index in target vnet and calls if_grow() if necessary, * and finally find an unused if_xname for the target vnet. */ -static void +static int if_vmove(struct ifnet *ifp, struct vnet *new_vnet) { struct if_clone *ifc; @@ -1283,7 +1283,7 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet) */ rc = if_detach_internal(ifp, 1, &ifc); if (rc != 0) - return; + return (rc); /* * Unlink the ifnet from ifindex_table[] in current vnet, and shrink @@ -1327,6 +1327,7 @@ if_vmove(struct ifnet *ifp, struct vnet *new_vnet) #endif CURVNET_RESTORE(); + return (0); } /* @@ -1337,6 +1338,7 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, ch { struct prison *pr; struct ifnet *difp; + int error; /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); @@ -1372,13 +1374,14 @@ if_vmove_loan(struct thread *td, struct ifnet *ifp, ch CURVNET_RESTORE(); /* Move the interface into the child jail/vnet. */ - if_vmove(ifp, pr->pr_vnet); + error = if_vmove(ifp, pr->pr_vnet); - /* Report the new if_xname back to the userland. */ - sprintf(ifname, "%s", ifp->if_xname); + /* Report the new if_xname back to the userland on success. */ + if (error == 0) + sprintf(ifname, "%s", ifp->if_xname); prison_free(pr); - return (0); + return (error); } static int @@ -1387,6 +1390,7 @@ if_vmove_reclaim(struct thread *td, char *ifname, int struct prison *pr; struct vnet *vnet_dst; struct ifnet *ifp; + int error; /* Try to find the prison within our visibility. */ sx_slock(&allprison_lock); @@ -1422,14 +1426,15 @@ if_vmove_reclaim(struct thread *td, char *ifname, int } /* Get interface back from child jail/vnet. */ - if_vmove(ifp, vnet_dst); + error = if_vmove(ifp, vnet_dst); CURVNET_RESTORE(); - /* Report the new if_xname back to the userland. */ - sprintf(ifname, "%s", ifp->if_xname); + /* Report the new if_xname back to the userland on success. */ + if (error == 0) + sprintf(ifname, "%s", ifp->if_xname); prison_free(pr); - return (0); + return (error); } #endif /* VIMAGE */