[mle] invalidate parent if not child (#4572)

Current Thread certification needs Parent information even after the
node already become a router or leader. This commit sets parent state
to invalid to indicate information in mParent should not be used in
normal cases.
This commit is contained in:
Yakun Xu
2020-02-19 02:04:07 +08:00
committed by GitHub
parent 9de99a8efa
commit a8638d7ff8
+6
View File
@@ -339,6 +339,12 @@ void Mle::SetRole(otDeviceRole aRole)
break;
}
// If the previous state is disabled, the parent can be in kStateRestored.
if (mRole != OT_DEVICE_ROLE_CHILD && oldRole != OT_DEVICE_ROLE_DISABLED)
{
mParent.SetState(Neighbor::kStateInvalid);
}
#if OPENTHREAD_CONFIG_BORDER_AGENT_ENABLE
if (IsAttached())
{