From 0b1e922a1d446e58daaafdbf4840ddfbfd80dd73 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Thu, 28 Jul 2022 10:27:57 -0400 Subject: [PATCH] [mle] send Link Request immediately if router id was previously allocated (#7947) After upgrading to a router, the device will wait until it receives a Route TLV from a neighboring node indicating that the new Router ID has been allocated. In normal cases, this is not an issue since the Leader will disseminate a new Router ID Sequence after allocating a new Router ID. However, in some scenarios, a device may request the same Router ID that was previously allocated and significantly delay establishing links with neighboring routers. With this commit, a device will immediately send a Link Request if the Router ID was previously allocated. --- src/core/thread/mle_router.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index d630347f9..aa7787784 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -3800,6 +3800,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message * aMessage, uint8_t routerId; Router * router; Router * leader; + bool isRouterIdAllocated; mAddressSolicitPending = false; @@ -3831,6 +3832,8 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message * aMessage, SuccessOrExit(Tlv::Find(*aMessage, rloc16)); routerId = RouterIdFromRloc16(rloc16); + isRouterIdAllocated = mRouterTable.IsAllocated(routerId); + SuccessOrExit(Tlv::FindTlv(*aMessage, routerMaskTlv)); VerifyOrExit(routerMaskTlv.IsValid()); @@ -3866,13 +3869,22 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Message * aMessage, leader->SetNextHop(RouterIdFromRloc16(mParent.GetRloc16())); } + if (isRouterIdAllocated) + { + // send Link Request immediately if Router ID was previously allocated + IgnoreError(SendLinkRequest(nullptr)); + } + else + { + // wait to send Link Request until new Router ID has been disseminated from the Leader + mLinkRequestDelay = kMulticastLinkRequestDelay; + } + for (Child &child : Get().Iterate(Child::kInStateChildIdRequest)) { IgnoreError(SendChildIdResponse(child)); } - mLinkRequestDelay = kMulticastLinkRequestDelay; - exit: // Send announce after received address solicit reply if needed InformPreviousChannel();