From nobody Wed Sep 02 19:57:08 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 4hZtmT6vzbz6qbbp for ; Wed, 02 Sep 2026 19:57:13 +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 4hZtmT4YfQz3Vst for ; Wed, 02 Sep 2026 19:57:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1788379033; 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=lud1MeaMHWKzbOWx1pLHI19c1xG2lhGW4LKhwsY7xs9REpy2pwQpwEegiGpvYGmwqq8i0X EKDEYsZ05NDifam/O0j4JuLCQ+LNZbmY5bdL//yHx5vzjuHrMa4BGjV0vNeodyHi3+uPJr pthwD7aFwfbIckMvyOTxCjyo6XwGcCmeZZGIC4pK0uts6fqufMDWgNK5O8QcwsII6D8d+G yXIpvPw87Inb4oniAZXD5tDdDELGgq/comT9BbPuQ3XcBDLen650qCbgCD4DdksLQ2fVXl H2mvEYUBoqB/mqjESYhCAk5oi65ovM6C/ypb58j6/4l7RPuw6cWjcgQetVZxmA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1788379033; a=rsa-sha256; cv=none; b=ADEFHD3js0P52HIDtgKWT/szUs9ITa3ZNFJnNOG4GGwL/KEemrjSxMr92E3J3F5zgS7Eb6 OixkPZmDLl3XxvT1OwkUL1OkUHOqDqBQIlgux3+w1V2JZOg2harKnXfkyo+haejnFFKSvY 4Zxpfb6Jg3MC//FlOGTVas3vuCs8209pKfMDoVIv+Rp1OPjlIN62oWoJo1hoJ7P/qgGv69 gOAmnSWd52PLY2p48ztnASz5DsBwZuALfmo5561rM84vSTPQvrPw/bb3fgdfAV/FiMEIi1 xwlcmYxXJYMZ/3hoL0gMdp81F++ZS4BvT1oy76fmtx0HHMIA95RbqQltyliEjQ== 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=1788379033; 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=t0gLaFLnxktBGIrAidwUj5ZYy3rAjWZAW/sORyAt7XmGAupG39JgEl0yeOx8tSULGAJnmd dJtY3qQxIJ5EQu4zbNWMhT9aupMnemlD6emeYXor1Ki9OTEtDK3r9b62a+q20wpM/q8uPs avtrq2jyJosAxPYGicddP6OB/IBMNZtKAA3VW9byCW17Oob7UPsgV6BgFLdbcIQ8OItZzL UhMAqHAye5c15wS6I5kgBcAVhI+pbdQgI+j1DUrgNX/efS5a7jNR0oY2t7Yj2/R0ZJyoCY NS9or2kh+cwOWxmSQVi+673qeOGdhc27OO0gEcuFjfSYXabjlOFqTNepRpgI+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 4hZtmT3LBgzxrS for ; Wed, 02 Sep 2026 19:57:13 +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 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: 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)