[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:
Abtin Keshavarzian
2024-02-01 19:04:54 -08:00
committed by GitHub
parent 686eb30e9a
commit 21cd366b50
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -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.