[border-router] more strict state check before evaluating routing policy (#6336)

This commit is contained in:
kangping
2021-03-23 12:44:28 -07:00
committed by GitHub
parent 1236839e3e
commit a04e164e7d
+6 -6
View File
@@ -313,7 +313,7 @@ void RoutingManager::HandleNotifierEvents(Events aEvents)
EvaluateState();
}
if (aEvents.Contains(kEventThreadNetdataChanged))
if (mIsRunning && aEvents.Contains(kEventThreadNetdataChanged))
{
StartRoutingPolicyEvaluationDelay();
}
@@ -576,12 +576,12 @@ exit:
// OMR prefix in the Thread network.
void RoutingManager::EvaluateRoutingPolicy(void)
{
OT_ASSERT(mIsRunning);
const Ip6::Prefix *newOnLinkPrefix = nullptr;
Ip6::Prefix newOmrPrefixes[kMaxOmrPrefixNum];
uint8_t newOmrPrefixNum = 0;
VerifyOrExit(mIsRunning);
otLogInfoBr("evaluating routing policy");
// 0. Evaluate on-link & OMR prefixes.
@@ -618,13 +618,12 @@ void RoutingManager::EvaluateRoutingPolicy(void)
static_assert(sizeof(mAdvertisedOmrPrefixes) == sizeof(newOmrPrefixes), "invalid new OMR prefix array size");
memcpy(mAdvertisedOmrPrefixes, newOmrPrefixes, sizeof(newOmrPrefixes[0]) * newOmrPrefixNum);
mAdvertisedOmrPrefixNum = newOmrPrefixNum;
exit:
return;
}
void RoutingManager::StartRoutingPolicyEvaluationDelay(void)
{
OT_ASSERT(mIsRunning);
uint32_t randomDelay;
static_assert(kMaxRoutingPolicyDelay > 0, "invalid maximum routing policy evaluation delay");
@@ -917,6 +916,7 @@ void RoutingManager::HandleRouterAdvertisement(const Ip6::Address &aSrcAddress,
const uint8_t * aBuffer,
uint16_t aBufferLength)
{
OT_ASSERT(mIsRunning);
OT_UNUSED_VARIABLE(aSrcAddress);
using RouterAdv::Option;