From nobody Wed Sep 02 19:57:08 2026 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 4hZtmN3DVDz6qbdC for ; Wed, 02 Sep 2026 19:57:08 +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 "YR2" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4hZtmN2C3bz3VkS for ; Wed, 02 Sep 2026 19:57:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788379028; 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=iEB2tAG5LqTAZk0Ej6dU76rHA+55uKBpnat4tGNib10=; b=ExkuvoOUAPjGjKuYHoA1WBeC472FZzGwfgA0IlkMXgcgdeVSrFROaiy+EfMK08+kXLyz+1 taj3XGX1sqM2LK2Bae5uOaZtvqa7Q5ssJG+XbRevWv4z3SnVqH781xirkAVUq9XulFjfw2 Qrsw1jmtGZ2T/pH3i3ak2zI40HinmMr3tJOb87sWRjJ+wuAC22dc5CK5q3G4vRrGy6ajSF cBsVKgD1EQY896veysQHkqghpdhrNWV1tYHQ1c+veAiqdqkhb8r2WqCR4/IfstlG8fv2d9 AS74mLOnfS/OfEtg7Z1nrlsOTkEatdPY7xca1QJEBY/60gIFKD0dTRAxtwxDrA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788379028; a=rsa-sha256; cv=none; b=xMGCdQgCkuu6m87lCUWiY6YAPOwu6OagPPik85ddw5ksKSCafS8qFe/11rSFGNaOp/iq1G y4iEWXc1qc571lpWk6ZKG+bI5GACzstwsJT0pkIVAB/zIswSWDpqdzNewpFPLJveqWvikT 2zVH9B6e0tam32OBkRSmiwBsQHHwYSDHiGNwYoG15urUcVb6KJzL4dt7PFxChSjqztjDcP nqWRSPk8NqLMYSeDMr2tYWAa1BwQd+tlfZay8o5Jjdkg+5qLEuy9NF6VZbekYjgoZc6DCH 5Uh7i4/15PDex15um6MF8olPtHFP308zHtNomw3CyiMFU9sxbp2SoQM4knMqTw== 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=1788379028; 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=iEB2tAG5LqTAZk0Ej6dU76rHA+55uKBpnat4tGNib10=; b=IoW5RzIVJAd7SM8leVVCCRv8ObrD1nmy75puB2H49/d7TWhLUajyL1d8WqMyZRZ2az1gYP KRiDo7/CZPpW0KGvhma3e/duw2QuZYuQcyr27bB4uDJ/TL/VaR0RgpT7KBDsdBt8meMyjX CUb3vdxDFgpv596g9MF+miDxGuEyV/qFtymyauVWQPG+FmJSZNaBpniX+IP7/i0CCVlDwJ CqxDxtbY+k79KLS3+rh8NagtEnRUAUC8+zcBiWeDJFvGWqdscI20YEL/4QwK+zIAnD2I1L EnDdf4cjS+5Vv4svIcv+881qj69eUpfikiABgreW4DX0tpvmRyMHLyNK/z3y+g== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) by mxrelay.nyi.freebsd.org (Postfix) with ESMTP id 4hZtmN19Vkzxwn for ; Wed, 02 Sep 2026 19:57:08 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from git (uid 1279) (envelope-from git@FreeBSD.org) id 25511 by gitrepo.freebsd.org (DragonFly Mail Agent v0.13+ on gitrepo.freebsd.org); Wed, 02 Sep 2026 19:57:08 +0000 To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Kevin Bowling Subject: git: 9d59ca793f70 - main - iflib: Do not hold the ifnet lock across registration 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 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: kbowling X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9d59ca793f7097575351d6de2fd61431233b5ed9 Auto-Submitted: auto-generated Date: Wed, 02 Sep 2026 19:57:08 +0000 Message-Id: <6a987f94.25511.13b5031a@gitrepo.freebsd.org> The branch main has been updated by kbowling: URL: https://cgit.FreeBSD.org/src/commit/?id=9d59ca793f7097575351d6de2fd61431233b5ed9 commit 9d59ca793f7097575351d6de2fd61431233b5ed9 Author: Kevin Bowling AuthorDate: 2026-08-31 23:24:49 +0000 Commit: Kevin Bowling CommitDate: 2026-09-02 19:56:14 +0000 iflib: Do not hold the ifnet lock across registration iflib_device_register() acquired IFNET_WLOCK to preserve lock order when ether_ifattach() was called with the context lock held. The context lock is now released around ether_ifattach(), making registration-wide ifnet serialization unnecessary. Keeping IFNET_WLOCK across driver attachment also allows synchronous interface event handlers to recurse on it. The rtnetlink interface-group dump does so through if_foreach_group() while handling the interface attachment event. Remove the outer lock and the corresponding failure-path unlock and relock transitions. Continue to drop the context lock around ether_ifattach() and taskqueue drains, and preserve context-lock coverage for driver attach and detach. Validated under WITNESS on 82576 and I226 controllers. Multiple VF attach and detach cycles, netmap control operations, and every iflib registration failure injection point completed without lock or cleanup errors. PR: 298121 Reported by: glebius, netchild, Yuichiro NAITO Reviewed by: gallatin, glebius Fixes: e0e12405285b ("netmap: fix LOR in iflib_netmap_register") Fixes: 2f8f892ca344 ("rtnetlink: Add FreeBSD-specific IFLAF_GROUP support") Fixes: 90e7dbe5e2ca ("iflib: Add registration failure injection points") MFC after: 2 weeks Sponsored by: BBOX.io Differential Revision: https://reviews.freebsd.org/D59294 --- sys/net/iflib.c | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/sys/net/iflib.c b/sys/net/iflib.c index 34d53d648a7c..83a518462100 100644 --- a/sys/net/iflib.c +++ b/sys/net/iflib.c @@ -5311,7 +5311,6 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct #endif } iflib_reset_qvalues(ctx); - IFNET_WLOCK(); CTX_LOCK(ctx); IFLIB_REGISTER_FAIL_POINT(dev, register_before_attach_pre, err, fail_cleanup); @@ -5544,7 +5543,6 @@ iflib_device_register(device_t dev, void *sc, if_shared_ctx_t sctx, if_ctx_t *ct iflib_add_pfil(ctx); ctx->ifc_flags |= IFC_INIT_DONE; CTX_UNLOCK(ctx); - IFNET_WUNLOCK(); /* Create led(4) devices if the driver defined the method */ kobj_desc = &ifdi_led_func_desc; @@ -5559,9 +5557,8 @@ fail_detach: STATE_LOCK(ctx); ctx->ifc_flags |= IFC_IN_DETACH; STATE_UNLOCK(ctx); - /* Tasks may need either lock; ether_ifdetach() takes ifnet_detach_sx. */ + /* Tasks may need the context lock; ether_ifdetach() may sleep. */ CTX_UNLOCK(ctx); - IFNET_WUNLOCK(); taskqueue_drain_all(ctx->ifc_tq); #ifdef PCI_IOV /* @@ -5578,7 +5575,6 @@ fail_detach: } #endif ether_ifdetach(ctx->ifc_ifp); - IFNET_WLOCK(); CTX_LOCK(ctx); goto fail_cleanup_detaching; @@ -5599,14 +5595,12 @@ fail_cleanup_detaching: if (ctx->ifc_tq != NULL) { /* - * Drain without holding the ifnet or context locks so configuration - * tasks can run to completion. On fail_detach a second drain also - * catches tasks queued during the first drain. + * Drain without holding the context lock so configuration tasks can + * run to completion. On fail_detach a second drain also catches + * tasks queued during the first drain. */ CTX_UNLOCK(ctx); - IFNET_WUNLOCK(); taskqueue_drain_all(ctx->ifc_tq); - IFNET_WLOCK(); CTX_LOCK(ctx); } @@ -5619,18 +5613,12 @@ fail_cleanup_detaching: /* * A successful IFDI_ATTACH_PRE must be matched by IFDI_DETACH, even * when registration fails before queue allocation. Match - * iflib_device_deregister by detaching before taskqueue_free, and avoid - * holding IFNET_WLOCK across driver detach (LinuxKPI workqueue drain). + * iflib_device_deregister by detaching before taskqueue_free. */ if (attach_pre_succeeded) { - IFNET_WUNLOCK(); IFDI_DETACH(ctx); if (queues_allocated) IFDI_QUEUES_FREE(ctx); - /* Reacquire the global lock before the context lock. */ - CTX_UNLOCK(ctx); - IFNET_WLOCK(); - CTX_LOCK(ctx); } if (ctx->ifc_tq != NULL) { taskqueue_free(ctx->ifc_tq); @@ -5640,7 +5628,6 @@ fail_cleanup_detaching: iflib_free_intr_mem(ctx); CTX_UNLOCK(ctx); - IFNET_WUNLOCK(); iflib_deregister(ctx); device_set_softc(ctx->ifc_dev, NULL); if (ctx->ifc_flags & IFC_SC_ALLOCATED)