X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/b7266188b87f3620ec3f9f717e57194a7dd989fe..060df5ea7c632b1ac8cc8aac1fb59758165c2084:/bsd/netinet6/nd6.c?ds=sidebyside diff --git a/bsd/netinet6/nd6.c b/bsd/netinet6/nd6.c index a7b5cb3a3..d71746042 100644 --- a/bsd/netinet6/nd6.c +++ b/bsd/netinet6/nd6.c @@ -550,12 +550,8 @@ skip1: return 0; } -/* - * ND6 timer routine to expire default route list and prefix list - */ void -nd6_timer( - __unused void *ignored_arg) +nd6_drain(__unused void *ignored_arg) { struct llinfo_nd6 *ln; struct nd_defrouter *dr; @@ -683,7 +679,8 @@ again: case ND6_LLINFO_REACHABLE: if (ln->ln_expire) { ln->ln_state = ND6_LLINFO_STALE; - ln->ln_expire = timenow.tv_sec + nd6_gctimer; + ln->ln_expire = rt_expiry(rt, timenow.tv_sec, + nd6_gctimer); } RT_UNLOCK(rt); break; @@ -721,7 +718,8 @@ again: goto again; } ln->ln_state = ND6_LLINFO_STALE; /* XXX */ - ln->ln_expire = timenow.tv_sec + nd6_gctimer; + ln->ln_expire = rt_expiry(rt, timenow.tv_sec, + nd6_gctimer); RT_UNLOCK(rt); break; @@ -899,6 +897,15 @@ again: pr = pr->ndpr_next; } lck_mtx_unlock(nd6_mutex); +} + +/* + * ND6 timer routine to expire default route list and prefix list + */ +void +nd6_timer(__unused void *ignored_arg) +{ + nd6_drain(NULL); timeout(nd6_timer, (caddr_t)0, nd6_prune * hz); } @@ -1186,10 +1193,11 @@ nd6_lookup( * use rt->rt_ifa->ifa_ifp, which would specify the REAL * interface. */ - if (((ifp && (ifp->if_type != IFT_PPP)) && ((ifp->if_eflags & IFEF_NOAUTOIPV6LL) == 0)) && - ((rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 || + if (ifp == NULL || (ifp->if_type == IFT_PPP) || + (ifp->if_eflags & IFEF_NOAUTOIPV6LL) || + (rt->rt_flags & RTF_GATEWAY) || (rt->rt_flags & RTF_LLINFO) == 0 || rt->rt_gateway->sa_family != AF_LINK || rt->rt_llinfo == NULL || - (ifp && rt->rt_ifa->ifa_ifp != ifp))) { + (ifp && rt->rt_ifa->ifa_ifp != ifp)) { RT_REMREF_LOCKED(rt); RT_UNLOCK(rt); if (create) { @@ -1436,8 +1444,8 @@ nd6_nud_hint( ln->ln_state = ND6_LLINFO_REACHABLE; if (ln->ln_expire) { lck_rw_lock_shared(nd_if_rwlock); - ln->ln_expire = timenow.tv_sec + - nd_ifinfo[rt->rt_ifp->if_index].reachable; + ln->ln_expire = rt_expiry(rt, timenow.tv_sec, + nd_ifinfo[rt->rt_ifp->if_index].reachable); lck_rw_done(nd_if_rwlock); } done: @@ -1680,6 +1688,14 @@ nd6_rtrequest( SDL(gate)->sdl_alen = ifp->if_addrlen; } if (nd6_useloopback) { +#if IFNET_ROUTE_REFCNT + /* Adjust route ref count for the interfaces */ + if (rt->rt_if_ref_fn != NULL && + rt->rt_ifp != lo_ifp) { + rt->rt_if_ref_fn(lo_ifp, 1); + rt->rt_if_ref_fn(rt->rt_ifp, -1); + } +#endif /* IFNET_ROUTE_REFCNT */ rt->rt_ifp = lo_ifp; /* XXX */ /* * Make sure rt_ifa be equal to the ifaddr @@ -2315,7 +2331,8 @@ fail: * we must set the timer now, although it is actually * meaningless. */ - ln->ln_expire = timenow.tv_sec + nd6_gctimer; + ln->ln_expire = rt_expiry(rt, timenow.tv_sec, + nd6_gctimer); ln->ln_hold = NULL; if (m != NULL) { @@ -2716,7 +2733,7 @@ lookup: if ((ifp->if_flags & IFF_POINTOPOINT) != 0 && ln->ln_state < ND6_LLINFO_REACHABLE) { ln->ln_state = ND6_LLINFO_STALE; - ln->ln_expire = timenow.tv_sec + nd6_gctimer; + ln->ln_expire = rt_expiry(rt, timenow.tv_sec, nd6_gctimer); } /* @@ -2729,7 +2746,7 @@ lookup: if (ln->ln_state == ND6_LLINFO_STALE) { ln->ln_asked = 0; ln->ln_state = ND6_LLINFO_DELAY; - ln->ln_expire = timenow.tv_sec + nd6_delay; + ln->ln_expire = rt_expiry(rt, timenow.tv_sec, nd6_delay); } /*