[border-routing] decide Router Solicitation state with IsRouterSolicitationInProgress (#7242)

This commit is contained in:
Simon Lin
2021-12-23 12:19:26 -08:00
committed by GitHub
parent 7e2b694c1d
commit 2e8703dfa5
2 changed files with 13 additions and 4 deletions
+12 -4
View File
@@ -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);
@@ -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);