summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorGleb Smirnoff <glebius@FreeBSD.org>2026-01-16 16:38:02 -0800
committerGleb Smirnoff <glebius@FreeBSD.org>2026-01-16 16:38:02 -0800
commitf102a18349335bfda1eb373a64eb1ba7462cd6bb (patch)
tree7286385dd6e4a7ef4fc3f6ed8f59b75ed36d192d /sys
parent74cac745fe302b26ad22114f60735c8b73e90571 (diff)
net: on interface detach purge all its routes before detaching protocols
Otherwise, a forwarding thread may use the interface being detached. This is a regression from 0d469d23715d, which manifests itself as a reliably reproducible panic in in6_selecthlim(). Note that there are old bug reports about such a panic, and I believe this change will not fix them, as their nature is not due to a screwed up detach sequence, but due to lack of proper epoch(9) based synchronization between the detach and forwarding. Reviewed by: pouria Reported & tested by: jhibbits PR: 292162 Fixes: 0d469d23715d690b863787ebfa51529e1f6a9092 Differential Revision: https://reviews.freebsd.org/D54721
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 4ddf8a69b3f0..047ccd2ecda7 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -1115,6 +1115,8 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
altq_detach(&ifp->if_snd);
#endif
+ rt_flushifroutes(ifp);
+
if_purgeaddrs(ifp);
EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
if_purgemaddrs(ifp);
@@ -1139,8 +1141,6 @@ if_detach_internal(struct ifnet *ifp, bool vmove)
} else
IF_ADDR_WUNLOCK(ifp);
}
-
- rt_flushifroutes(ifp);
}
#ifdef VIMAGE