Skip to content

Commit

Permalink
[mle] do not clear router table state until role transitions to router (
Browse files Browse the repository at this point in the history
openthread#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.
  • Loading branch information
jwhui authored Jan 14, 2018
1 parent 5df7c83 commit 15885dc
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions src/core/thread/mle_router.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -303,7 +294,6 @@ otError MleRouter::BecomeLeader(void)

router->SetExtAddress(netif.GetMac().GetExtAddress());
mAdvertiseTimer.Stop();
netif.GetAddressResolver().Clear();

if (mFixedLeaderPartitionId != 0)
{
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -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++)
Expand Down Expand Up @@ -4150,7 +4151,6 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe
ThreadRouterMaskTlv routerMaskTlv;
uint8_t routerId;
Router *router;
bool old;

mAddressSolicitPending = false;

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 15885dc

Please sign in to comment.