git: dd6004c57540 - main - iflib: Drain the receive watchdog callout on detach

From: R. Christian McDonald <rcm_at_FreeBSD.org>
Date: Fri, 27 Nov 2026 14:40:32 UTC
The branch main has been updated by rcm:

URL: https://cgit.FreeBSD.org/src/commit/?id=dd6004c57540842ba9a5cc4eacb7390427ec0e0b

commit dd6004c57540842ba9a5cc4eacb7390427ec0e0b
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-11-27 14:21:07 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-11-27 14:21:07 +0000

    iflib: Drain the receive watchdog callout on detach
    
    Nothing stops ifr_watchdog when an interface goes away.  If it is armed
    when the interface detaches, the callout stays on the callout wheel
    after iflib_rx_structures_free() has freed the queue containing it,
    corrupting the wheel, or fires and enqueues a task that has already been
    detached.
    
    The window is small: the callout is armed for one tick, only when a
    receive buffer refill fails, and the detach has to follow right after.
    
    The former iflib_pseudo_deregister() drained the callout until
    102540192c71 moved its teardown into iflib_tqg_detach() without the
    drain, and iflib_device_deregister() never did.  Drain it in
    iflib_tqg_detach().  The callout cannot be rearmed by then:
    _task_fn_rx() only arms it while the interface is running, and
    iflib_device_deregister() has already called iflib_stop(), which clears
    the running state and then drains the receive tasks.
    
    Reviewed by:    kbowling
    Fixes:          fb1a29b45e8b ("Make sure the so-called end of receive...")
    MFC after:      2 weeks
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Pull Request:   https://ron-dev.freebsd.org/FreeBSD/src/pulls/90
---
 sys/net/iflib.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sys/net/iflib.c b/sys/net/iflib.c
index 205d2ff0d63f..aef6011aaaea 100644
--- a/sys/net/iflib.c
+++ b/sys/net/iflib.c
@@ -5996,6 +5996,7 @@ iflib_tqg_detach(if_ctx_t ctx)
 			taskqgroup_detach(tqg, &txq->ift_task);
 	}
 	for (i = 0, rxq = ctx->ifc_rxqs; i < NRXQSETS(ctx); i++, rxq++) {
+		callout_drain(&rxq->ifr_watchdog);
 		if (rxq->ifr_task.gt_uniq != NULL)
 			taskqgroup_detach(tqg, &rxq->ifr_task);
 	}