[mle] fix handling of MLE Orphan Announce messages (#7786)

MLE Orphan Announce messages include a timestamp value that has both
seconds and ticks set to zero, but authoritative bit set. However, the
default Active Timestamp value is all zeros. As a result, an MLE
Orphan Announce timestamp can appear to be greater than the default
Active Timestamp value and cause a device to detach.

This commit adds a special case to check for the Orphan Announce
timestamp.
This commit is contained in:
Jonathan Hui
2022-06-06 10:51:47 -07:00
committed by GitHub
parent 5daca7c684
commit 4384a3100b
2 changed files with 18 additions and 9 deletions
+9
View File
@@ -140,6 +140,15 @@ public:
*/
void AdvanceRandomTicks(void);
/**
* This method indicates whether the timestamp indicates an MLE Orphan Announce message.
*
* @retval TRUE The timestamp indicates an Orphan Announce message.
* @retval FALSE If the timestamp does not indicate an Orphan Announce message.
*
*/
bool IsOrphanTimestamp(void) const { return GetSeconds() == 0 && GetTicks() == 0 && GetAuthoritative(); }
/**
* This static method compares two timestamps.
*
+9 -9
View File
@@ -4113,7 +4113,15 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo)
localTimestamp = Get<MeshCoP::ActiveDatasetManager>().GetTimestamp();
if (MeshCoP::Timestamp::Compare(&timestamp, localTimestamp) > 0)
if (timestamp.IsOrphanTimestamp() || MeshCoP::Timestamp::Compare(&timestamp, localTimestamp) < 0)
{
SendAnnounce(channel);
#if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE
SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr());
#endif
}
else if (MeshCoP::Timestamp::Compare(&timestamp, localTimestamp) > 0)
{
// No action is required if device is detached, and current
// channel and pan-id match the values from the received MLE
@@ -4136,14 +4144,6 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo)
LogNote("Delay processing Announce - channel %d, panid 0x%02x", channel, panId);
}
else if (MeshCoP::Timestamp::Compare(&timestamp, localTimestamp) < 0)
{
SendAnnounce(channel);
#if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE
SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr());
#endif
}
else
{
// Timestamps are equal.