mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 08:07:47 +00:00
[dataset] fix issue in applying pending dataset when delaytimer expires (#2988)
This commit is contained in:
@@ -518,7 +518,7 @@ void Dataset::Remove(uint8_t *aStart, uint8_t aLength)
|
||||
mLength -= aLength;
|
||||
}
|
||||
|
||||
otError Dataset::ApplyConfiguration(Instance &aInstance) const
|
||||
otError Dataset::ApplyConfiguration(Instance &aInstance, bool *aIsMasterKeyUpdated) const
|
||||
{
|
||||
ThreadNetif &netif = aInstance.GetThreadNetif();
|
||||
Mac::Mac & mac = netif.GetMac();
|
||||
@@ -528,6 +528,11 @@ otError Dataset::ApplyConfiguration(Instance &aInstance) const
|
||||
|
||||
VerifyOrExit(IsValid(), error = OT_ERROR_PARSE);
|
||||
|
||||
if (aIsMasterKeyUpdated)
|
||||
{
|
||||
*aIsMasterKeyUpdated = false;
|
||||
}
|
||||
|
||||
while (cur < end)
|
||||
{
|
||||
switch (cur->GetType())
|
||||
@@ -578,6 +583,13 @@ otError Dataset::ApplyConfiguration(Instance &aInstance) const
|
||||
case Tlv::kNetworkMasterKey:
|
||||
{
|
||||
const NetworkMasterKeyTlv *key = static_cast<const NetworkMasterKeyTlv *>(cur);
|
||||
|
||||
if (aIsMasterKeyUpdated &&
|
||||
memcmp(&key->GetNetworkMasterKey(), &netif.GetKeyManager().GetMasterKey(), OT_MASTER_KEY_SIZE))
|
||||
{
|
||||
*aIsMasterKeyUpdated = true;
|
||||
}
|
||||
|
||||
netif.GetKeyManager().SetMasterKey(key->GetNetworkMasterKey());
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -224,13 +224,14 @@ public:
|
||||
/**
|
||||
* This method applies the Active or Pending Dataset to the Thread interface.
|
||||
*
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[in] aInstance A reference to the OpenThread instance.
|
||||
* @param[out] aIsMasterKeyUpdated A pointer to where to place whether master key was updated.
|
||||
*
|
||||
* @retval OT_ERROR_NONE Successfully applied configuration.
|
||||
* @retval OT_ERROR_PARSE The dataset has at least one TLV with invalid format.
|
||||
*
|
||||
*/
|
||||
otError ApplyConfiguration(Instance &aInstance) const;
|
||||
otError ApplyConfiguration(Instance &aInstance, bool *aIsMasterKeyUpdated = NULL) const;
|
||||
|
||||
/**
|
||||
* This method converts a Pending Dataset to an Active Dataset.
|
||||
|
||||
@@ -149,6 +149,7 @@ otError DatasetManager::Set(const Dataset &aDataset)
|
||||
otError error = OT_ERROR_NONE;
|
||||
const Timestamp *timestamp;
|
||||
int compare;
|
||||
bool isMasterkeyUpdated = false;
|
||||
|
||||
timestamp = aDataset.GetTimestamp();
|
||||
|
||||
@@ -159,13 +160,13 @@ otError DatasetManager::Set(const Dataset &aDataset)
|
||||
|
||||
if (mLocal.GetType() == Tlv::kActiveTimestamp)
|
||||
{
|
||||
SuccessOrExit(error = aDataset.ApplyConfiguration(GetInstance()));
|
||||
SuccessOrExit(error = aDataset.ApplyConfiguration(GetInstance(), &isMasterkeyUpdated));
|
||||
}
|
||||
}
|
||||
|
||||
compare = mLocal.Compare(timestamp);
|
||||
|
||||
if (compare > 0)
|
||||
if (isMasterkeyUpdated || compare > 0)
|
||||
{
|
||||
ThreadNetif &netif = GetNetif();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user