mirror of
https://github.com/espressif/openthread.git
synced 2026-09-03 15:50:06 +00:00
[routing-manager] fix IsDeprecated() to handle large preferred lifetime (#9822)
This commit fixes `DiscoveredPrefixTable::Entry::IsDeprecated()` to properly handle larger preferred lifetime values. It uses the method `CalculateExpireDelay()` to handle time delay calculation, avoiding overflow. The `test_routing_manager` test has also been updated to check for larger preferred/valid lifetime values.
This commit is contained in:
@@ -1838,7 +1838,7 @@ bool RoutingManager::DiscoveredPrefixTable::Entry::IsDeprecated(void) const
|
|||||||
{
|
{
|
||||||
OT_ASSERT(IsOnLinkPrefix());
|
OT_ASSERT(IsOnLinkPrefix());
|
||||||
|
|
||||||
return mLastUpdateTime + TimeMilli::SecToMsec(GetPreferredLifetime()) <= TimerMilli::GetNow();
|
return mLastUpdateTime + CalculateExpireDelay(GetPreferredLifetime()) <= TimerMilli::GetNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
RoutingManager::RoutePreference RoutingManager::DiscoveredPrefixTable::Entry::GetPreference(void) const
|
RoutingManager::RoutePreference RoutingManager::DiscoveredPrefixTable::Entry::GetPreference(void) const
|
||||||
|
|||||||
@@ -38,6 +38,7 @@
|
|||||||
#include "border_router/routing_manager.hpp"
|
#include "border_router/routing_manager.hpp"
|
||||||
#include "common/arg_macros.hpp"
|
#include "common/arg_macros.hpp"
|
||||||
#include "common/array.hpp"
|
#include "common/array.hpp"
|
||||||
|
#include "common/numeric_limits.hpp"
|
||||||
#include "common/time.hpp"
|
#include "common/time.hpp"
|
||||||
#include "instance/instance.hpp"
|
#include "instance/instance.hpp"
|
||||||
#include "net/icmp6.hpp"
|
#include "net/icmp6.hpp"
|
||||||
@@ -57,6 +58,7 @@ static const char kInfraIfAddress[] = "fe80::1";
|
|||||||
|
|
||||||
static constexpr uint32_t kValidLitime = 2000;
|
static constexpr uint32_t kValidLitime = 2000;
|
||||||
static constexpr uint32_t kPreferredLifetime = 1800;
|
static constexpr uint32_t kPreferredLifetime = 1800;
|
||||||
|
static constexpr uint32_t kInfiniteLifetime = NumericLimits<uint32_t>::kMax;
|
||||||
|
|
||||||
static constexpr uint32_t kRioValidLifetime = 1800;
|
static constexpr uint32_t kRioValidLifetime = 1800;
|
||||||
static constexpr uint32_t kRioDeprecatingLifetime = 300;
|
static constexpr uint32_t kRioDeprecatingLifetime = 300;
|
||||||
@@ -1876,7 +1878,7 @@ void TestLocalOnLinkPrefixDeprecation(void)
|
|||||||
// Send an RA from router A with a new on-link (PIO) which is preferred over
|
// Send an RA from router A with a new on-link (PIO) which is preferred over
|
||||||
// the local on-link prefix.
|
// the local on-link prefix.
|
||||||
|
|
||||||
SendRouterAdvert(routerAddressA, {Pio(onLinkPrefix, kValidLitime, kPreferredLifetime)});
|
SendRouterAdvert(routerAddressA, {Pio(onLinkPrefix, kInfiniteLifetime, kInfiniteLifetime)});
|
||||||
|
|
||||||
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
//- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// Check that the local on-link prefix is now deprecating in the new RA.
|
// Check that the local on-link prefix is now deprecating in the new RA.
|
||||||
|
|||||||
Reference in New Issue
Block a user