mirror of
https://github.com/espressif/openthread.git
synced 2026-08-03 09:27:47 +00:00
[mle] fix unexpected data request (#4326)
This commit compares data version properly according to the device mode (whether or not requiring full network data), thus avoiding unexpected data request when receiving MLE advertisement.
This commit is contained in:
+18
-15
@@ -2877,8 +2877,7 @@ otError Mle::HandleAdvertisement(const Message &aMessage, const Ip6::MessageInfo
|
||||
break;
|
||||
}
|
||||
|
||||
if (mRetrieveNewNetworkData ||
|
||||
(static_cast<int8_t>(leaderData.GetDataVersion() - Get<NetworkData::Leader>().GetVersion()) > 0))
|
||||
if (mRetrieveNewNetworkData || IsNetworkDataNewer(leaderData))
|
||||
{
|
||||
delay = Random::NonCrypto::GetUint16InRange(0, kMleMaxResponseDelay);
|
||||
SendDataRequest(aMessageInfo.GetPeerAddr(), tlvs, sizeof(tlvs), delay);
|
||||
@@ -2919,6 +2918,22 @@ exit:
|
||||
return error;
|
||||
}
|
||||
|
||||
bool Mle::IsNetworkDataNewer(const LeaderDataTlv &aLeaderData)
|
||||
{
|
||||
int8_t diff;
|
||||
|
||||
if (IsFullNetworkData())
|
||||
{
|
||||
diff = static_cast<int8_t>(aLeaderData.GetDataVersion() - Get<NetworkData::Leader>().GetVersion());
|
||||
}
|
||||
else
|
||||
{
|
||||
diff = static_cast<int8_t>(aLeaderData.GetStableDataVersion() - Get<NetworkData::Leader>().GetStableVersion());
|
||||
}
|
||||
|
||||
return (diff > 0);
|
||||
}
|
||||
|
||||
otError Mle::HandleLeaderData(const Message &aMessage, const Ip6::MessageInfo &aMessageInfo)
|
||||
{
|
||||
otError error = OT_ERROR_NONE;
|
||||
@@ -2950,19 +2965,7 @@ otError Mle::HandleLeaderData(const Message &aMessage, const Ip6::MessageInfo &a
|
||||
}
|
||||
else if (!mRetrieveNewNetworkData)
|
||||
{
|
||||
int8_t diff;
|
||||
|
||||
if (IsFullNetworkData())
|
||||
{
|
||||
diff = static_cast<int8_t>(leaderData.GetDataVersion() - Get<NetworkData::Leader>().GetVersion());
|
||||
}
|
||||
else
|
||||
{
|
||||
diff =
|
||||
static_cast<int8_t>(leaderData.GetStableDataVersion() - Get<NetworkData::Leader>().GetStableVersion());
|
||||
}
|
||||
|
||||
VerifyOrExit(diff > 0);
|
||||
VerifyOrExit(IsNetworkDataNewer(leaderData));
|
||||
}
|
||||
|
||||
// Active Timestamp
|
||||
|
||||
@@ -1713,6 +1713,7 @@ private:
|
||||
uint32_t Reattach(void);
|
||||
|
||||
bool IsBetterParent(uint16_t aRloc16, uint8_t aLinkQuality, uint8_t aLinkMargin, ConnectivityTlv &aConnectivityTlv);
|
||||
bool IsNetworkDataNewer(const LeaderDataTlv &aLeaderData);
|
||||
void ResetParentCandidate(void);
|
||||
|
||||
otError GetAlocAddress(Ip6::Address &aAddress, uint16_t aAloc16) const;
|
||||
|
||||
Reference in New Issue
Block a user