[mle] fix router id release issue introduced in #2217 (#2320)

This commit is contained in:
rongli
2017-11-06 08:56:19 -08:00
committed by Jonathan Hui
parent 04ed60be07
commit 203dd58998
+19 -9
View File
@@ -1928,6 +1928,7 @@ void MleRouter::HandleStateUpdateTimer(void)
{
otLogInfoMle(GetInstance(), "Router timeout expired");
RemoveNeighbor(router);
continue;
}
#else
@@ -1941,6 +1942,7 @@ void MleRouter::HandleStateUpdateTimer(void)
else if (age >= TimerMilli::SecToMsec(kMaxNeighborAge) + kMaxLinkRequestTimeout)
{
RemoveNeighbor(router);
continue;
}
#endif
@@ -1951,6 +1953,7 @@ void MleRouter::HandleStateUpdateTimer(void)
{
otLogInfoMle(GetInstance(), "Link Request timeout expired");
RemoveNeighbor(router);
continue;
}
}
@@ -4094,6 +4097,9 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe
// assign short address
SetRouterId(routerId);
// fill in its own extended address.
router->SetExtAddress(*GetNetif().GetMac().GetExtAddress());
SuccessOrExit(SetStateRouter(GetRloc16(mRouterId)));
router->SetCost(0);
@@ -4113,18 +4119,22 @@ void MleRouter::HandleAddressSolicitResponse(Coap::Header *aHeader, Message *aMe
}
}
// Keep route path to the Leader reported by the parent before it is updated.
if (mRouters[GetLeaderId()].GetCost() == 0)
{
mRouters[GetLeaderId()].SetCost(mParentLeaderCost);
}
mRouters[GetLeaderId()].SetNextHop(GetRouterId(mParent.GetRloc16()));
// Keep link to the parent in order to response to Parent Requests before new link is established.
// Keep link to the parent in order to respond to Parent Requests before new link is established.
mRouters[GetRouterId(mParent.GetRloc16())] = mParent;
mRouters[GetRouterId(mParent.GetRloc16())].SetAllocated(true);
// Only has direct link connection to its parent currently.
mRouters[GetRouterId(mParent.GetRloc16())].SetNextHop(kInvalidRouterId);
mRouters[GetRouterId(mParent.GetRloc16())].SetCost(0);
// Keep route path to the Leader reported by the parent before it is updated.
if (GetLeaderId() != GetRouterId(mParent.GetRloc16()))
{
mRouters[GetLeaderId()].SetCost(mParentLeaderCost);
mRouters[GetLeaderId()].SetAllocated(true);
mRouters[GetLeaderId()].SetNextHop(GetRouterId(mParent.GetRloc16()));
}
// send link request
SendLinkRequest(NULL);