diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index f4c9d9678..11c4a8692 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -1459,15 +1459,15 @@ void RoutingManager::RxRaTracker::RemoveOrDeprecateOldEntries(TimeMilli aTimeThr RemoveExpiredEntries(); } -void RoutingManager::RxRaTracker::RemoveOrDeprecateEntriesFromInactiveRouters(void) +void RoutingManager::RxRaTracker::RemoveOrDeprecateEntriesFromUnreachableRouters(void) { // Remove route prefix entries and deprecate on-link prefix entries // in the table for routers that have reached the max NS probe - // attempts and considered as inactive. + // attempts and considered unreachable. for (Router &router : mRouters) { - if (router.mNsProbeCount <= Router::kMaxNsProbes) + if (router.IsReachable()) { continue; } @@ -1522,7 +1522,7 @@ void RoutingManager::RxRaTracker::ScheduleAllTimers(void) for (const Router &router : mRouters) { - if ((router.mNsProbeCount <= Router::kMaxNsProbes) && !router.mIsLocalDevice) + if (router.IsReachable() && !router.mIsLocalDevice) { // Skip if router is this device or has failed all // earlier NS probes. @@ -1697,7 +1697,8 @@ void RoutingManager::RxRaTracker::UpdateRouterOnRx(Router &aRouter) aRouter.mNsProbeCount = 0; aRouter.mLastUpdateTime = TimerMilli::GetNow(); - aRouter.mTimeout = aRouter.mLastUpdateTime + Random::NonCrypto::AddJitter(Router::kActiveTimeout, Router::kJitter); + aRouter.mTimeout = + aRouter.mLastUpdateTime + Random::NonCrypto::AddJitter(Router::kReachableTimeout, Router::kJitter); mRouterTimer.FireAtIfEarlier(aRouter.mTimeout); } @@ -1707,7 +1708,7 @@ void RoutingManager::RxRaTracker::HandleRouterTimer(void) for (Router &router : mRouters) { - if (router.mNsProbeCount > Router::kMaxNsProbes) + if (!router.IsReachable()) { continue; } @@ -1725,7 +1726,7 @@ void RoutingManager::RxRaTracker::HandleRouterTimer(void) { router.mNsProbeCount++; - if (router.mNsProbeCount > Router::kMaxNsProbes) + if (!router.IsReachable()) { LogInfo("No response to all Neighbor Solicitations attempts from router %s", router.mAddress.ToString().AsCString()); @@ -1739,7 +1740,7 @@ void RoutingManager::RxRaTracker::HandleRouterTimer(void) } } - RemoveOrDeprecateEntriesFromInactiveRouters(); + RemoveOrDeprecateEntriesFromUnreachableRouters(); ScheduleAllTimers(); } @@ -1782,7 +1783,7 @@ void RoutingManager::RxRaTracker::DetermineAndSetFlags(RouterAdvert::Header &aHe continue; } - if (router.mNsProbeCount > Router::kMaxNsProbes) + if (!router.IsReachable()) { continue; } @@ -1952,7 +1953,7 @@ bool RoutingManager::RxRaTracker::Router::Matches(EmptyChecker aChecker) const bool hasFlags = false; - if (mNsProbeCount <= kMaxNsProbes) + if (IsReachable()) { hasFlags = (mManagedAddressConfigFlag || mOtherConfigFlag); } diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index 1c5be7928..41160638f 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -811,9 +811,9 @@ private: struct Router : public Clearable { - // The timeout (in msec) for router staying in active state + // The timeout (in msec) for router to be considered reachable // before starting the Neighbor Solicitation (NS) probes. - static constexpr uint32_t kActiveTimeout = OPENTHREAD_CONFIG_BORDER_ROUTING_ROUTER_ACTIVE_CHECK_TIMEOUT; + static constexpr uint32_t kReachableTimeout = OPENTHREAD_CONFIG_BORDER_ROUTING_ROUTER_ACTIVE_CHECK_TIMEOUT; static constexpr uint8_t kMaxNsProbes = 5; // Max number of NS probe attempts. static constexpr uint32_t kNsProbeRetryInterval = 1000; // In msec. Time between NS probe attempts. @@ -827,6 +827,7 @@ private: kContainsNoEntriesOrFlags }; + bool IsReachable(void) const { return mNsProbeCount <= kMaxNsProbes; } bool Matches(const Ip6::Address &aAddress) const { return aAddress == mAddress; } bool Matches(EmptyChecker aChecker) const; void CopyInfoTo(RouterEntry &aEntry, TimeMilli aNow) const; @@ -914,7 +915,7 @@ private: void ProcessRouteInfoOption(const RouteInfoOption &aRio, Router &aRouter); void ProcessRaFlagsExtOption(const RaFlagsExtOption &aFlagsOption, Router &aRouter); bool ContainsOnLinkPrefix(OnLinkPrefix::UlaChecker aUlaChecker) const; - void RemoveOrDeprecateEntriesFromInactiveRouters(void); + void RemoveOrDeprecateEntriesFromUnreachableRouters(void); void RemoveRoutersWithNoEntriesOrFlags(void); void RemoveExpiredEntries(void); void SignalTableChanged(void);