In this point the interface is already removed from the list of all interfaces and from the interface index map and all possible concurrent ioctl() threads finished. Remove this dead code.
Index: sys/net/if.c =================================================================== RCS file: /cvs/src/sys/net/if.c,v retrieving revision 1.699 diff -u -p -r1.699 if.c --- sys/net/if.c 5 Jun 2023 11:35:46 -0000 1.699 +++ sys/net/if.c 7 Jun 2023 10:22:36 -0000 @@ -145,7 +145,6 @@ int if_setrdomain(struct ifnet *, int); void if_slowtimo(void *); void if_detached_qstart(struct ifqueue *); -int if_detached_ioctl(struct ifnet *, u_long, caddr_t); int ifioctl_get(u_long, caddr_t); int ifconf(caddr_t); @@ -1128,7 +1127,6 @@ if_detach(struct ifnet *ifp) NET_LOCK(); s = splnet(); - ifp->if_ioctl = if_detached_ioctl; ifp->if_watchdog = NULL; /* Remove the watchdog timeout & task */ @@ -2761,19 +2759,13 @@ if_getdata(struct ifnet *ifp, struct if_ } /* - * Dummy functions replaced in ifnet during detach (if protocols decide to + * Dummy function replaced in ifnet during detach (if protocols decide to * fiddle with the if during detach. */ void if_detached_qstart(struct ifqueue *ifq) { ifq_purge(ifq); -} - -int -if_detached_ioctl(struct ifnet *ifp, u_long a, caddr_t b) -{ - return ENODEV; } /*