From 26550d53c6252114f825842a0324a8ab0637e193 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Wed, 22 May 2019 08:37:59 -0700 Subject: [PATCH] [mle] fix bug in MLE attach behavior (#3850) Bug was introdcued in 5a7faa5. A device performing MLE attach first sends an MLE Parent Request looking for routers. If no MLE Parent Response is received from a neighboring router where the link quality is 3 in both directions, the device shall send a second MLE Parent Request that includes both routers and REEDs. This commit adds the bi-directional link quality check to determine whether a second MLE Parent Request should be sent. --- src/core/thread/mle.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 12f64c89a..c791fa049 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -1627,6 +1627,15 @@ void Mle::HandleAttachTimer(void) if (mAttachState == kAttachStateParentRequestRouter || mAttachState == kAttachStateParentRequestReed || mAttachState == kAttachStateAnnounce) { + uint8_t linkQuality; + + linkQuality = mParentCandidate.GetLinkInfo().GetLinkQuality(); + + if (linkQuality > mParentCandidate.GetLinkQualityOut()) + { + linkQuality = mParentCandidate.GetLinkQualityOut(); + } + // If already attached, accept the parent candidate if // we are trying to attach to a better partition or if a // Parent Response was also received from the current parent @@ -1638,7 +1647,7 @@ void Mle::HandleAttachTimer(void) // the candidate and forward to REED stage to find a better // parent. - if ((mParentCandidate.GetLinkInfo().GetLinkQuality() == 3 || mAttachState != kAttachStateParentRequestRouter) && + if ((linkQuality == 3 || mAttachState != kAttachStateParentRequestRouter) && mParentCandidate.GetState() == Neighbor::kStateParentResponse && (mRole != OT_DEVICE_ROLE_CHILD || mReceivedResponseFromParent || mParentRequestMode == kAttachBetter) && SendChildIdRequest() == OT_ERROR_NONE)