mirror of
https://github.com/espressif/openthread.git
synced 2026-06-06 05:24:51 +00:00
[mle] reuse challenge during child role restoration (#12065)
Ensure the same challenge is used for all "Child Update Request" messages sent to the parent while trying to restore the previous child role. The challenge is now generated once when the child role restoration process starts in `PrevRoleRestorer::Start`. This prevents a situation where a new challenge from a retry could invalidate a delayed but valid response from the parent that contained the previous challenge.
This commit is contained in:
committed by
GitHub
parent
9520760ff1
commit
76f905bfac
+11
-1
@@ -1194,8 +1194,17 @@ Error Mle::SendChildUpdateRequestToParent(ChildUpdateRequestMode aMode)
|
||||
case kAppendZeroTimeout:
|
||||
break;
|
||||
case kAppendChallengeTlv:
|
||||
case kToRestoreChildRole:
|
||||
mPrevRoleRestorer.GenerateRandomChallenge();
|
||||
OT_FALL_THROUGH;
|
||||
|
||||
case kToRestoreChildRole:
|
||||
// The challenge used for child role restoration is generated
|
||||
// only once, specifically when the `mPrevRoleRestorer` state
|
||||
// changes and the process starts. We reuse this single challenge
|
||||
// for all "Child Update Request" retries. This prevents a new
|
||||
// challenge from invalidating a potentially delayed, yet correct,
|
||||
// response from the parent.
|
||||
|
||||
SuccessOrExit(error = message->AppendChallengeTlv(mPrevRoleRestorer.GetChallenge()));
|
||||
break;
|
||||
}
|
||||
@@ -4284,6 +4293,7 @@ Error Mle::PrevRoleRestorer::Start(void)
|
||||
VerifyOrExit(Get<Mle>().mLastSavedRole == kRoleChild);
|
||||
VerifyOrExit(Get<Mle>().mParent.IsStateValidOrRestoring());
|
||||
SetState(kRestoringChildRole);
|
||||
GenerateRandomChallenge();
|
||||
mAttempts = kMaxChildUpdatesToRestoreRole;
|
||||
mTimer.Start(Get<Mle>().GenerateRandomDelay(kMaxStartDelay));
|
||||
error = kErrorNone;
|
||||
|
||||
Reference in New Issue
Block a user