+ ap->found++;
+ VERIFY(rt->rt_expire == 0 || rt->rt_rmx.rmx_expire != 0);
+ VERIFY(rt->rt_expire != 0 || rt->rt_rmx.rmx_expire == 0);
+ if (ap->draining || rt->rt_expire <= timenow ||
+ ((rt->rt_flags & RTF_DYNAMIC) && ip6_maxdynroutes >= 0 &&
+ in6dynroutes > ip6_maxdynroutes / 2)) {
+ if (rt->rt_refcnt > 0) {
+ panic("%s: route %p marked with RTPRF_OURS "
+ "with non-zero refcnt (%u)", __func__,
+ rt, rt->rt_refcnt);
+ /* NOTREACHED */
+ }
+
+ if (verbose) {
+ log(LOG_DEBUG, "%s: deleting route to "
+ "%s->%s->%s, flags=%b, draining=%d\n",
+ __func__, dbuf, gbuf, (rt->rt_ifp != NULL) ?
+ rt->rt_ifp->if_xname : "", rt->rt_flags,
+ RTF_BITS, ap->draining);
+ }
+ RT_ADDREF_LOCKED(rt); /* for us to free below */
+ /*
+ * Delete this route since we're done with it;
+ * the route may be freed afterwards, so we
+ * can no longer refer to 'rt' upon returning
+ * from rtrequest(). Safe to drop rt_lock and
+ * use rt_key, rt_gateway, since holding rnh_lock
+ * here prevents another thread from calling
+ * rt_setgate() on this route.
+ */
+ RT_UNLOCK(rt);
+ err = rtrequest_locked(RTM_DELETE, rt_key(rt),
+ rt->rt_gateway, rt_mask(rt), rt->rt_flags, NULL);
+ if (err != 0) {
+ RT_LOCK(rt);
+ if (!verbose)
+ rt_str(rt, dbuf, sizeof (dbuf),
+ gbuf, sizeof (gbuf));
+ log(LOG_ERR, "%s: error deleting route to "
+ "%s->%s->%s, flags=%b, err=%d\n", __func__,
+ dbuf, gbuf, (rt->rt_ifp != NULL) ?
+ rt->rt_ifp->if_xname : "", rt->rt_flags,
+ RTF_BITS, err);
+ RT_UNLOCK(rt);