mirror of
https://github.com/espressif/openthread.git
synced 2026-07-30 07:37:46 +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:
@@ -38,6 +38,7 @@
|
||||
#include "border_router/routing_manager.hpp"
|
||||
#include "common/arg_macros.hpp"
|
||||
#include "common/array.hpp"
|
||||
#include "common/numeric_limits.hpp"
|
||||
#include "common/time.hpp"
|
||||
#include "instance/instance.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 kPreferredLifetime = 1800;
|
||||
static constexpr uint32_t kInfiniteLifetime = NumericLimits<uint32_t>::kMax;
|
||||
|
||||
static constexpr uint32_t kRioValidLifetime = 1800;
|
||||
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
|
||||
// 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.
|
||||
|
||||
Reference in New Issue
Block a user