From ce1b8e67622483b3c4941ed3fdbc4b2013255238 Mon Sep 17 00:00:00 2001 From: Rongli Sun Date: Mon, 29 Jun 2020 23:57:01 +0800 Subject: [PATCH] [mle] suppress parent response when >= 32 active routers (#5156) This commit introduces one extra parent response rule: REED doesn't respond parent request if there are already `kMaxRouters` active routers in the Thread network as it's for sure that Leader will reject its address solicit. --- src/core/thread/mle_router.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index ff1ddef44..4c2e96a54 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -1612,7 +1612,7 @@ void MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::MessageI VerifyOrExit(IsRouterEligible(), error = OT_ERROR_INVALID_STATE); - // A Router MUST NOT send an MLE Parent Response if: + // A Router/REED MUST NOT send an MLE Parent Response if: // 0. It is detached or attempting to another partition VerifyOrExit(!IsDetached() && !IsAttaching(), error = OT_ERROR_DROP); @@ -1635,6 +1635,10 @@ void MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::MessageI (leader->GetCost() + GetLinkCost(leader->GetNextHop()) < kMaxRouteCost), error = OT_ERROR_DROP); + // 4. It is a REED and there are already `kMaxRouters` active routers in + // the network (because Leader would reject any further address solicit). + // ==> Verified below when checking the scan mask. + aMessageInfo.GetPeerAddr().ToExtAddress(macAddr); // Version @@ -1652,6 +1656,7 @@ void MleRouter::HandleParentRequest(const Message &aMessage, const Ip6::MessageI case kRoleChild: VerifyOrExit(ScanMaskTlv::IsEndDeviceFlagSet(scanMask), OT_NOOP); + VerifyOrExit(mRouterTable.GetActiveRouterCount() < kMaxRouters, error = OT_ERROR_DROP); break; case kRoleRouter: