From d94c4e00856097b31449211328afb2f13637bd87 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Mon, 11 Sep 2023 06:49:08 -0700 Subject: [PATCH] [mle] suppress Announce response to orphan child on same channel and PAN ID (#9388) This commit updates MLE to skip sending an Announce response when receiving an Announce message from a detached/orphan device and the included channel and PAN ID in the received Announce message are the same as the current network's channel and PAN ID. --- src/core/thread/mle.cpp | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 355f45c01..57fa4e79d 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -3712,6 +3712,9 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo) const MeshCoP::Timestamp *localTimestamp; uint8_t channel; uint16_t panId; + bool isFromOrphan; + bool channelAndPanIdMatch; + int timestampCompare; Log(kMessageReceive, kTypeAnnounce, aRxInfo.mMessageInfo.GetPeerAddr()); @@ -3727,22 +3730,33 @@ void Mle::HandleAnnounce(RxInfo &aRxInfo) localTimestamp = Get().GetTimestamp(); - if (timestamp.IsOrphanTimestamp() || MeshCoP::Timestamp::Compare(×tamp, localTimestamp) < 0) + isFromOrphan = timestamp.IsOrphanTimestamp(); + timestampCompare = MeshCoP::Timestamp::Compare(×tamp, localTimestamp); + channelAndPanIdMatch = (channel == Get().GetPanChannel()) && (panId == Get().GetPanId()); + + if (isFromOrphan || (timestampCompare < 0)) { + if (isFromOrphan) + { + VerifyOrExit(!channelAndPanIdMatch); + } + SendAnnounce(channel); #if OPENTHREAD_CONFIG_MLE_SEND_UNICAST_ANNOUNCE_RESPONSE SendAnnounce(channel, aRxInfo.mMessageInfo.GetPeerAddr()); #endif } - else if (MeshCoP::Timestamp::Compare(×tamp, localTimestamp) > 0) + else if (timestampCompare > 0) { // No action is required if device is detached, and current // channel and pan-id match the values from the received MLE // Announce message. - VerifyOrExit(!IsDetached() || (Get().GetPanChannel() != channel) || - (Get().GetPanId() != panId)); + if (IsDetached()) + { + VerifyOrExit(!channelAndPanIdMatch); + } if (mAttachState == kAttachStateProcessAnnounce) {