mirror of
https://github.com/espressif/openthread.git
synced 2026-10-07 08:17:40 +00:00
[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:
@@ -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())
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user