Do not prematurely detach when a router migrates to another partition. (#298)

Move processing the Route TLV from the new partition after successfully
completing the attach.
This commit is contained in:
Jonathan Hui
2016-07-28 14:49:36 -07:00
committed by GitHub
parent 143ea37a0a
commit 3cf6a79e1d
2 changed files with 18 additions and 18 deletions
+17 -17
View File
@@ -1727,21 +1727,6 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
(mDeviceMode & ModeTlv::kModeFullNetworkData) == 0,
networkData.GetNetworkData(), networkData.GetLength());
// Route
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == kThreadError_None) &&
(mDeviceMode & ModeTlv::kModeFFD))
{
SuccessOrExit(error = mMleRouter.ProcessRouteTlv(route));
for (int i = 0; i < kMaxRouterId; i++)
{
if (route.IsRouterIdSet(i))
{
numRouters++;
}
}
}
// Parent Attach Success
mParentRequestTimer.Stop();
@@ -1760,9 +1745,24 @@ ThreadError Mle::HandleChildIdResponse(const Message &aMessage, const Ip6::Messa
mParent.mValid.mRloc16 = sourceAddress.GetRloc16();
SuccessOrExit(error = SetStateChild(shortAddress.GetRloc16()));
if ((mDeviceMode & ModeTlv::kModeFFD) && (numRouters < mMleRouter.GetRouterUpgradeThreshold()))
// Route
if ((Tlv::GetTlv(aMessage, Tlv::kRoute, sizeof(route), route) == kThreadError_None) &&
(mDeviceMode & ModeTlv::kModeFFD))
{
mMleRouter.BecomeRouter();
SuccessOrExit(error = mMleRouter.ProcessRouteTlv(route));
for (int i = 0; i < kMaxRouterId; i++)
{
if (route.IsRouterIdSet(i))
{
numRouters++;
}
}
if ((mDeviceMode & ModeTlv::kModeFFD) && (numRouters < mMleRouter.GetRouterUpgradeThreshold()))
{
mMleRouter.BecomeRouter();
}
}
exit:
+1 -1
View File
@@ -1073,7 +1073,7 @@ ThreadError MleRouter::ProcessRouteTlv(const RouteTlv &aRoute)
bool old;
// check for newer route data
if (diff > 0 || mDeviceState == kDeviceStateDetached)
if (diff > 0 || mDeviceState == kDeviceStateDetached || mDeviceState == kDeviceStateChild)
{
mRouterIdSequence = aRoute.GetRouterIdSequence();
mRouterIdSequenceLastUpdated = Timer::GetNow();