diff --git a/src/core/border_router/routing_manager.cpp b/src/core/border_router/routing_manager.cpp index 693832a97..1a7d2e8f2 100644 --- a/src/core/border_router/routing_manager.cpp +++ b/src/core/border_router/routing_manager.cpp @@ -499,7 +499,7 @@ const Ip6::Prefix *RoutingManager::EvaluateOnLinkPrefix(void) const Ip6::Prefix *smallestOnLinkPrefix = nullptr; // We don't evaluate on-link prefix if we are doing Router Solicitation. - VerifyOrExit(!mRouterSolicitTimer.IsRunning(), + VerifyOrExit(!IsRouterSolicitationInProgress(), newOnLinkPrefix = (mIsAdvertisingLocalOnLinkPrefix ? &mLocalOnLinkPrefix : nullptr)); for (const ExternalPrefix &prefix : mDiscoveredPrefixes) @@ -636,7 +636,9 @@ void RoutingManager::StartRouterSolicitationDelay(void) { uint32_t randomDelay; - VerifyOrExit(!mRouterSolicitTimer.IsRunning() && mRouterSolicitCount == 0); + VerifyOrExit(!IsRouterSolicitationInProgress()); + + OT_ASSERT(mRouterSolicitCount == 0); mVicariousRouterSolicitTimer.Stop(); @@ -651,6 +653,11 @@ exit: return; } +bool RoutingManager::IsRouterSolicitationInProgress(void) const +{ + return mRouterSolicitTimer.IsRunning() || mRouterSolicitCount > 0; +} + Error RoutingManager::SendRouterSolicitation(void) { Ip6::Address destAddress; @@ -898,9 +905,10 @@ void RoutingManager::HandleRouterSolicitTimer(void) UpdateRouterAdvMessage(/* aRouterAdvMessage */ nullptr); } + mRouterSolicitCount = 0; + // Re-evaluate our routing policy and send Router Advertisement if necessary. EvaluateRoutingPolicy(); - mRouterSolicitCount = 0; } } @@ -940,7 +948,7 @@ void RoutingManager::HandleRouterSolicit(const Ip6::Address &aSrcAddress, OT_UNUSED_VARIABLE(aBuffer); OT_UNUSED_VARIABLE(aBufferLength); - VerifyOrExit(!mRouterSolicitTimer.IsRunning()); + VerifyOrExit(!IsRouterSolicitationInProgress()); otLogInfoBr("Received Router Solicitation from %s on interface %u", aSrcAddress.ToString().AsCString(), mInfraIfIndex); diff --git a/src/core/border_router/routing_manager.hpp b/src/core/border_router/routing_manager.hpp index bdf86c2b2..ec60fdd6b 100644 --- a/src/core/border_router/routing_manager.hpp +++ b/src/core/border_router/routing_manager.hpp @@ -288,6 +288,7 @@ private: void StartRouterSolicitationDelay(void); Error SendRouterSolicitation(void); void SendRouterAdvertisement(const OmrPrefixArray &aNewOmrPrefixes, const Ip6::Prefix *aNewOnLinkPrefix); + bool IsRouterSolicitationInProgress(void) const; static void HandleRouterAdvertisementTimer(Timer &aTimer); void HandleRouterAdvertisementTimer(void);