Skip to content

Commit

Permalink
[mle] fix updating of mDataRequestState for Network Data (openthrea…
Browse files Browse the repository at this point in the history
…d#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.
  • Loading branch information
abtink authored Oct 16, 2024
1 parent 230c155 commit 31f92b6
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/core/thread/mle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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));

Expand Down Expand Up @@ -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;
}

Expand Down

0 comments on commit 31f92b6

Please sign in to comment.