git: 2cb4abfe7e6b - main - linux: Destroy the per-VNET unit allocator after the cloners

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

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

commit 2cb4abfe7e6b526897bbe602b121f07ed422ec08
Author:     R. Christian McDonald <rcm@FreeBSD.org>
AuthorDate: 2026-11-20 18:31:15 +0000
Commit:     R. Christian McDonald <rcm@FreeBSD.org>
CommitDate: 2026-11-20 18:32:11 +0000

    linux: Destroy the per-VNET unit allocator after the cloners
    
    linux_ifnet_vnet_uninit() deletes the unit number allocator that
    linux_ifnet_departure() frees into.  It ran at SI_SUB_INIT_IF,
    SI_ORDER_ANY, the same slot in which lagg, vlan, edsc and ng_eiface
    destroy the interfaces left in a dying vnet.  Destructors of equal order
    run in the reverse of the order their modules were loaded, so with
    linux_common loaded after if_lagg the allocator was gone by the time
    vnet_lagg_uninit() detached its interfaces, and removing a vnet jail that
    still held a lagg interface panicked in free_unr().
    
    Commit a23901a37be9 moved the destructor from SI_SUB_PROTO_IF to
    SI_SUB_INIT_IF for the cloners that tear down earlier, which left this
    tie.
    
    Run the destructor at SI_ORDER_FIRST, which is after every destructor of
    a later order in the same subsystem, whatever the load order.  Move the
    constructor with it.
    
    PR:                     300934
    Reported by:            siva
    Reviewed by:            markj, glebius
    Fixes:                  607f11055d2d ("linux: store Linux Ethernet...")
    Sponsored by:           Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D61781
---
 sys/compat/linux/linux_if.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/sys/compat/linux/linux_if.c b/sys/compat/linux/linux_if.c
index f386d55a9ae2..cc88f2c33605 100644
--- a/sys/compat/linux/linux_if.c
+++ b/sys/compat/linux/linux_if.c
@@ -113,9 +113,13 @@ linux_ifnet_vnet_init(void *arg __unused)
 		linux_ifnet_arrival(NULL, ifp);
 	NET_EPOCH_EXIT(et);
 }
-VNET_SYSINIT(linux_ifnet_vnet_init, SI_SUB_INIT_IF, SI_ORDER_ANY,
+VNET_SYSINIT(linux_ifnet_vnet_init, SI_SUB_INIT_IF, SI_ORDER_FIRST,
     linux_ifnet_vnet_init, NULL);
 
+/*
+ * Runs at SI_ORDER_FIRST, after the cloners that destroy their interfaces
+ * at SI_SUB_INIT_IF: linux_ifnet_departure() needs the allocator until then.
+ */
 static void
 linux_ifnet_vnet_uninit(void *arg __unused)
 {
@@ -129,7 +133,7 @@ linux_ifnet_vnet_uninit(void *arg __unused)
 	clear_unrhdr(V_linux_eth_unr);
 	delete_unrhdr(V_linux_eth_unr);
 }
-VNET_SYSUNINIT(linux_ifnet_vnet_uninit, SI_SUB_INIT_IF, SI_ORDER_ANY,
+VNET_SYSUNINIT(linux_ifnet_vnet_uninit, SI_SUB_INIT_IF, SI_ORDER_FIRST,
     linux_ifnet_vnet_uninit, NULL);
 
 /*