From owner-dev-commits-src-branches@freebsd.org Wed Feb 24 15:21:05 2021 Return-Path: Delivered-To: dev-commits-src-branches@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 91A2855FFF8; Wed, 24 Feb 2021 15:21:05 +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 "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Dm04K3khKz3Py7; Wed, 24 Feb 2021 15:21:05 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 733EC2E6DC; Wed, 24 Feb 2021 15:21:05 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 11OFL5Nm035990; Wed, 24 Feb 2021 15:21:05 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 11OFL5JM035989; Wed, 24 Feb 2021 15:21:05 GMT (envelope-from git) Date: Wed, 24 Feb 2021 15:21:05 GMT Message-Id: <202102241521.11OFL5JM035989@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Mark Johnston Subject: git: 4664afc05402 - stable/13 - iflib: Fix detach of pseudo interfaces MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: markj X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 4664afc05402abb8e572975ec65210bdcd8b2ea1 Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-branches@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commits to the stable branches of the FreeBSD src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 24 Feb 2021 15:21:05 -0000 The branch stable/13 has been updated by markj: URL: https://cgit.FreeBSD.org/src/commit/?id=4664afc05402abb8e572975ec65210bdcd8b2ea1 commit 4664afc05402abb8e572975ec65210bdcd8b2ea1 Author: Mark Johnston AuthorDate: 2021-02-19 22:08:34 +0000 Commit: Mark Johnston CommitDate: 2021-02-24 15:20:55 +0000 iflib: Fix detach of pseudo interfaces In commit 38bfc6dee33b we added an IFDI_DETACH() call to iflib_pseudo_deregister() since it looked like it was missing. One is present in the error-handling path of iflib_pseudo_register(). However, the detach actually comes from the DEVICE_DETACH() method for the above-mentioned device_t, so now we're calling IFDI_DETACH() twice when destroying a pseudo interface. Fix the problem by not calling IFDI_DETACH() from the device detach routine. This way we can ensure that iflib de-initialization always happens in a consistent order. It also ensures that you can't do silly things like "devctl detach ", which would previously detach the driver without tearing down the corresponding ifnet. PR: 253541 Reviewed by: erj Fixes: 38bfc6dee33b Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D28774 (cherry picked from commit 0f9544d03e89d180f94a7a84b110ec7d2b6c625a) --- sys/net/iflib_clone.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/sys/net/iflib_clone.c b/sys/net/iflib_clone.c index dc4ccbee659f..975873c4a19c 100644 --- a/sys/net/iflib_clone.c +++ b/sys/net/iflib_clone.c @@ -81,13 +81,11 @@ int iflib_pseudo_detach(device_t dev) { if_ctx_t ctx; - uint32_t ifc_flags; ctx = device_get_softc(dev); - ifc_flags = iflib_get_flags(ctx); - if ((ifc_flags & IFC_INIT_DONE) == 0) - return (0); - return (IFDI_DETACH(ctx)); + if ((iflib_get_flags(ctx) & IFC_IN_DETACH) == 0) + return (EBUSY); + return (0); } static device_t iflib_pseudodev;