aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Price <nprice@FreeBSD.org>2026-08-08 06:17:16 +0000
committerKevin Bowling <kbowling@FreeBSD.org>2026-08-14 22:08:36 +0000
commitba353c8950d575f9d15b82c92658e660935fba25 (patch)
treec1a8be6735503ac6ee947b4e26651174aee70337
parent90e7dbe5e2ca47baff4e4c6d9e892a0554eec4db (diff)
iflib: Drain configuration tasks before interface detach
iflib_device_deregister() sets IFC_IN_DETACH before removing the interface, but a task which already passed its detach check can still report a link change. This can re-arm if_linktask after ether_ifdetach() has drained it and leave work pending across queue teardown. Drain the entire private taskqueue before ether_ifdetach(). Drivers may register their own link-related configuration tasks there, so draining only the framework admin task leaves the same race for those drivers. MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D58452 Co-authored-by: Andrew Gallatin <gallatin@FreeBSD.org> Co-authored-by: Kevin Bowling <kbowling@FreeBSD.org>
-rw-r--r--sys/net/iflib.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 461ff0ba273e..cda60f174a31 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5658,6 +5658,13 @@ iflib_device_deregister(if_ctx_t ctx)
iflib_unregister_vlan_handlers(ctx);
iflib_netmap_detach(ifp);
+ /*
+ * A task that passed its IFC_IN_DETACH check before the flag was set
+ * can still report a link change. Drain every private task before
+ * ether_ifdetach() performs the final if_linktask drain. Drivers may
+ * register their own link-related tasks on this taskqueue.
+ */
+ taskqueue_drain_all(ctx->ifc_tq);
ether_ifdetach(ifp);
CTX_LOCK(ctx);