From 5cd4392b6be88394ff6c13c8c64cfb043fd6761d Mon Sep 17 00:00:00 2001 From: Yakun Xu Date: Fri, 28 Jan 2022 05:15:16 +0800 Subject: [PATCH] [mle] no failing logs for broadcast security check (#7362) This commit eliminates logging of broadcast security check failures because it can be common to receive such messages from ajacent Thread networks. --- src/core/thread/mle.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 421e2966d..89a662fb3 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -2748,6 +2748,7 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn uint8_t tag[kMleSecurityTagSize]; uint8_t command; Neighbor * neighbor; + bool skipLoggingError = false; otLogDebgMle("Receive UDP message"); @@ -2828,7 +2829,15 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn aesCcm.Finalize(tag); #ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION - VerifyOrExit(memcmp(messageTag, tag, sizeof(tag)) == 0, error = kErrorSecurity); + if (memcmp(messageTag, tag, sizeof(tag)) != 0) + { + // We skip logging security check failures for broadcast MLE + // messages since it can be common to receive such messages + // from adjacent Thread networks. + skipLoggingError = (aMessageInfo.GetSockAddr().IsMulticast() && + aMessageInfo.GetThreadLinkInfo()->GetPanId() == Mac::kPanIdBroadcast); + ExitNow(error = kErrorSecurity); + } #endif if (keySequence > Get().GetCurrentKeySequence()) @@ -3017,7 +3026,10 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn #endif exit: - LogProcessError(kTypeGenericUdp, error); + if (!skipLoggingError) + { + LogProcessError(kTypeGenericUdp, error); + } } void Mle::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo, Neighbor *aNeighbor)