From 15885dc2a20bf40f208ff7274cb47c41c2ead840 Mon Sep 17 00:00:00 2001 From: Jonathan Hui Date: Sun, 14 Jan 2018 18:46:34 +0000 Subject: [PATCH] [mle] do not clear router table state until role transitions to router (#2475) Prior to this commit, a REED attempting to become a router clears its routing table state when sending the Address Solicit message. This causes the REED to improperly think that it is a singleton when determining whether or not to merge with another partition. This commit only updates the routing table state when the REED actually transitions to becoming a router. --- src/core/thread/mle_router.cpp | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/core/thread/mle_router.cpp b/src/core/thread/mle_router.cpp index 504bb3810..bf04bb4d6 100644 --- a/src/core/thread/mle_router.cpp +++ b/src/core/thread/mle_router.cpp @@ -243,16 +243,7 @@ otError MleRouter::BecomeRouter(ThreadStatusTlv::Status aStatus) otLogInfoMle(GetInstance(), "Attempt to become router"); - for (int i = 0; i <= kMaxRouterId; i++) - { - mRouters[i].SetAllocated(false); - mRouters[i].SetReclaimDelay(false); - mRouters[i].SetState(Neighbor::kStateInvalid); - mRouters[i].SetNextHop(kInvalidRouterId); - } - mAdvertiseTimer.Stop(); - netif.GetAddressResolver().Clear(); netif.GetMeshForwarder().SetRxOnWhenIdle(true); mRouterSelectionJitterTimeout = 0; @@ -303,7 +294,6 @@ otError MleRouter::BecomeLeader(void) router->SetExtAddress(netif.GetMac().GetExtAddress()); mAdvertiseTimer.Stop(); - netif.GetAddressResolver().Clear(); if (mFixedLeaderPartitionId != 0) { @@ -445,6 +435,16 @@ otError MleRouter::SetStateRouter(uint16_t aRloc16) netif.GetIp6().SetForwardingEnabled(true); netif.GetIp6().GetMpl().SetTimerExpirations(kMplRouterDataMessageTimerExpirations); netif.GetMac().SetBeaconEnabled(true); + netif.GetAddressResolver().Clear(); + + // clear router table + for (int i = 0; i <= kMaxRouterId; i++) + { + mRouters[i].SetAllocated(false); + mRouters[i].SetReclaimDelay(false); + mRouters[i].SetState(Neighbor::kStateInvalid); + mRouters[i].SetNextHop(kInvalidRouterId); + } // remove children that do not have matching RLOC16 for (int i = 0; i < mMaxChildrenAllowed; i++) @@ -491,6 +491,7 @@ otError MleRouter::SetStateLeader(uint16_t aRloc16) netif.GetIp6().SetForwardingEnabled(true); netif.GetIp6().GetMpl().SetTimerExpirations(kMplRouterDataMessageTimerExpirations); netif.GetMac().SetBeaconEnabled(true); + netif.GetAddressResolver().Clear(); // remove children that do not have matching RLOC16 for (int i = 0; i < mMaxChildrenAllowed; i++) @@ -4150,7 +4151,6 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe ThreadRouterMaskTlv routerMaskTlv; uint8_t routerId; Router *router; - bool old; mAddressSolicitPending = false; @@ -4213,13 +4213,7 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe for (uint8_t i = 0; i <= kMaxRouterId; i++) { - old = mRouters[i].IsAllocated(); mRouters[i].SetAllocated(routerMaskTlv.IsAssignedRouterIdSet(i)); - - if (old && !mRouters[i].IsAllocated()) - { - GetNetif().GetAddressResolver().Remove(i); - } } // Keep link to the parent in order to respond to Parent Requests before new link is established.