[mle] fix updating of mDataRequestState for Network Data (#10841)

This commit updates and fixes how the `mDataRequestState` variable,
which controls retransmissions of MLE Data Request messages, is
updated.

An MLE Data Request message can be sent for different purposes: either
to request updated Network Data or to retrieve a Link Metrics Report
from a neighbor/parent. The `mDataRequestState` retransmission
mechanism is used to handle retx of Data Requests for retrieving
Network Data. This commit ensures that the code that updates these
variables is moved to `SendDataRequestAfterDelay()` and
not in the common version, which can be used for both Network Data
and Link Metric Reports. This ensures these states are not
incorrectly updated when a Link Metrics Report is retrieved.
This commit is contained in:
Abtin Keshavarzian
2024-10-16 11:29:42 -07:00
committed by GitHub
parent 230c155652
commit 31f92b6a2e
+17 -14
View File
@@ -1730,10 +1730,26 @@ Error Mle::SendDataRequestAfterDelay(const Ip6::Address &aDestination, uint16_t
{
static const uint8_t kTlvs[] = {Tlv::kNetworkData, Tlv::kRoute};
Error error;
mDelayedSender.RemoveDataRequestMessage(aDestination);
// Based on `mRequestRouteTlv` include both Network Data and Route
// TLVs or only Network Data TLV.
return SendDataRequest(aDestination, kTlvs, mRequestRouteTlv ? 2 : 1, aDelay);
error = SendDataRequest(aDestination, kTlvs, mRequestRouteTlv ? 2 : 1, aDelay);
if (IsChild() && !IsRxOnWhenIdle())
{
mDataRequestState = kDataRequestActive;
if (mChildUpdateRequestState == kChildUpdateRequestNone)
{
ScheduleMessageTransmissionTimer();
}
}
return error;
}
#if OPENTHREAD_CONFIG_MLE_LINK_METRICS_INITIATOR_ENABLE
@@ -1757,8 +1773,6 @@ Error Mle::SendDataRequest(const Ip6::Address &aDestination, const uint8_t *aTlv
Error error = kErrorNone;
TxMessage *message;
mDelayedSender.RemoveDataRequestMessage(aDestination);
VerifyOrExit((message = NewMleMessage(kCommandDataRequest)) != nullptr, error = kErrorNoBufs);
SuccessOrExit(error = message->AppendTlvRequestTlv(aTlvs, aTlvsLength));
@@ -1789,17 +1803,6 @@ Error Mle::SendDataRequest(const Ip6::Address &aDestination, const uint8_t *aTlv
exit:
FreeMessageOnError(message, error);
if (IsChild() && !IsRxOnWhenIdle())
{
mDataRequestState = kDataRequestActive;
if (mChildUpdateRequestState == kChildUpdateRequestNone)
{
ScheduleMessageTransmissionTimer();
}
}
return error;
}