[mle] fix comparing PAN ID to skip logging (#7390)

This commit adds a flag in Thread link info to indicate whether
destination PAN ID is broadcast.

Verified by running two simulation nodes (modified announce sender
interval) of different Thread networks and make sure there are no
logs of `[WARN]-MLE-----: Failed to process UDP: Security` when
receiving MLE Announce messages.
This commit is contained in:
Yakun Xu
2022-02-07 21:41:15 -08:00
committed by GitHub
parent bef3f6e024
commit ad2bc74c12
5 changed files with 29 additions and 8 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ extern "C" {
* @note This number versions both OpenThread platform and user APIs.
*
*/
#define OPENTHREAD_API_VERSION (190)
#define OPENTHREAD_API_VERSION (191)
/**
* @addtogroup api-instance
+6 -5
View File
@@ -60,11 +60,12 @@ extern "C" {
*/
typedef struct otThreadLinkInfo
{
uint16_t mPanId; ///< Source PAN ID
uint8_t mChannel; ///< 802.15.4 Channel
int8_t mRss; ///< Received Signal Strength in dBm.
uint8_t mLqi; ///< Link Quality Indicator for a received message.
bool mLinkSecurity; ///< Indicates whether or not link security is enabled.
uint16_t mPanId; ///< Source PAN ID
uint8_t mChannel; ///< 802.15.4 Channel
int8_t mRss; ///< Received Signal Strength in dBm.
uint8_t mLqi; ///< Link Quality Indicator for a received message.
bool mLinkSecurity : 1; ///< Indicates whether or not link security is enabled.
bool mIsDstPanIdBroadcast : 1; ///< Indicates whether or not destination PAN ID is broadcast.
// Applicable/Required only when time sync feature (`OPENTHREAD_CONFIG_TIME_SYNC_ENABLE`) is enabled.
uint8_t mTimeSyncSeq; ///< The time sync sequence.
+11
View File
@@ -63,6 +63,17 @@ void ThreadLinkInfo::SetFrom(const Mac::RxFrame &aFrame)
IgnoreError(aFrame.GetDstPanId(mPanId));
}
{
Mac::PanId dstPanId;
if (kErrorNone != aFrame.GetDstPanId(dstPanId))
{
dstPanId = mPanId;
}
mIsDstPanIdBroadcast = (dstPanId == Mac::kPanIdBroadcast);
}
mChannel = aFrame.GetChannel();
mRss = aFrame.GetRssi();
mLqi = aFrame.GetLqi();
+9
View File
@@ -95,6 +95,15 @@ public:
*/
uint8_t GetChannel(void) const { return mChannel; }
/**
* This method returns whether the Destination PAN ID is broadcast.
*
* @retval TRUE If Destination PAN ID is broadcast.
* @retval FALSE If Destination PAN ID is not broadcast.
*
*/
bool IsDstPanIdBroadcast(void) const { return mIsDstPanIdBroadcast; }
/**
* This method indicates whether or not link security is enabled.
*
+2 -2
View File
@@ -2834,8 +2834,8 @@ void Mle::HandleUdpReceive(Message &aMessage, const Ip6::MessageInfo &aMessageIn
// 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);
skipLoggingError =
(aMessageInfo.GetSockAddr().IsMulticast() && aMessageInfo.GetThreadLinkInfo()->IsDstPanIdBroadcast());
ExitNow(error = kErrorSecurity);
}
#endif