[routing-manager] fix calculation if an entry's stale time is in past (#7818)

This commit updates the calculation of the next stale time in
`ResetDiscoveredPrefixStaleTimer()` in (unlikely) cases where the
stale time of a discovered prefix or RA header happens to be in past
(compared to `GetNow()`). In such a case, we use `now` as the stale
time of the entry. This then ensures that the we can correctly
compare the stale time with `now.GetDistantFuture()`.
This commit is contained in:
Abtin Keshavarzian
2022-06-16 21:22:02 -07:00
committed by GitHub
parent c055c10a9a
commit a5d39c3ec3
+3 -2
View File
@@ -1371,14 +1371,15 @@ void RoutingManager::ResetDiscoveredPrefixStaleTimer(void)
// Check for stale Router Advertisement Message if learnt from Host.
if (mLearntRouterAdvMessageFromHost)
{
TimeMilli routerAdvMessageStaleTime = mTimeRouterAdvMessageLastUpdate + Time::SecToMsec(kRtrAdvStaleTime);
TimeMilli routerAdvMessageStaleTime =
OT_MAX(mTimeRouterAdvMessageLastUpdate + Time::SecToMsec(kRtrAdvStaleTime), now);
nextStaleTime = OT_MIN(nextStaleTime, routerAdvMessageStaleTime);
}
for (ExternalPrefix &externalPrefix : mDiscoveredPrefixes)
{
TimeMilli prefixStaleTime = externalPrefix.GetStaleTime();
TimeMilli prefixStaleTime = OT_MAX(externalPrefix.GetStaleTime(), now);
if (externalPrefix.IsOnLinkPrefix())
{