mirror of
https://github.com/espressif/openthread.git
synced 2026-09-04 16:20:05 +00:00
[mle] use compact Route TLV in Link Accept to child neighbors (#13012)
This commit enhances MLE where a full Route TLV could be appended to a Link Accept message sent to a child neighbor, potentially leading to a message requiring lowpan fragmentation. Previously, `Mle::SendLinkAccept()` relied on a `Router` pointer to determine whether to use a full or compact Route TLV. When the Link Request originated from a child, this pointer was null, causing a full Route TLV to be used. The changes in this commit include: - Updating the `LinkAcceptInfo` struct to track the RLOC16 of the Link Request sender. - Updating `Mle::TxMessage::AppendRouteTlv()` and adding `AppendCompactRouteTlv()` to replace the previous single method that took a `Neighbor` pointer. This makes the intent clearer and supports both router and child neighbors. - Updating `RouterTable::FillRouteTlv()` to take an RLOC16 instead of a `Neighbor` pointer. It uses `Mle::RouterIdFromRloc16()` to ensure that if the destination is a child, its parent's Router ID is included in the compact Route TLV. - Includes new Nexus test `test_compact_route_tlv` to validate the use of compact Route TLV in Link Accept.
This commit is contained in:
@@ -689,7 +689,6 @@ void Mle::HandleLinkRequest(RxInfo &aRxInfo)
|
||||
Neighbor *neighbor = nullptr;
|
||||
uint16_t version;
|
||||
LeaderData leaderData;
|
||||
uint16_t sourceAddress;
|
||||
LinkAcceptInfo info;
|
||||
|
||||
Log(kMessageReceive, kTypeLinkRequest, aRxInfo.mMessageInfo.GetPeerAddr());
|
||||
@@ -717,12 +716,12 @@ void Mle::HandleLinkRequest(RxInfo &aRxInfo)
|
||||
|
||||
info.mLinkMargin = Get<Mac::Mac>().ComputeLinkMargin(aRxInfo.mMessage.GetAverageRss());
|
||||
|
||||
switch (Tlv::Find<SourceAddressTlv>(aRxInfo.mMessage, sourceAddress))
|
||||
switch (Tlv::Find<SourceAddressTlv>(aRxInfo.mMessage, info.mRloc16))
|
||||
{
|
||||
case kErrorNone:
|
||||
if (IsRouterRloc16(sourceAddress))
|
||||
if (IsRouterRloc16(info.mRloc16))
|
||||
{
|
||||
Router *router = mRouterTable.FindRouterByRloc16(sourceAddress);
|
||||
Router *router = mRouterTable.FindRouterByRloc16(info.mRloc16);
|
||||
|
||||
VerifyOrExit(router != nullptr, error = kErrorParse);
|
||||
|
||||
@@ -745,8 +744,9 @@ void Mle::HandleLinkRequest(RxInfo &aRxInfo)
|
||||
case kErrorNotFound:
|
||||
// A missing source address indicates that the router was
|
||||
// recently reset.
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid() && IsRouterRloc16(aRxInfo.mNeighbor->GetRloc16()),
|
||||
error = kErrorDrop);
|
||||
VerifyOrExit(aRxInfo.IsNeighborStateValid(), error = kErrorDrop);
|
||||
info.mRloc16 = aRxInfo.mNeighbor->GetRloc16();
|
||||
VerifyOrExit(IsRouterRloc16(info.mRloc16), error = kErrorDrop);
|
||||
neighbor = aRxInfo.mNeighbor;
|
||||
break;
|
||||
|
||||
@@ -839,7 +839,7 @@ Error Mle::SendLinkAccept(const LinkAcceptInfo &aInfo)
|
||||
switch (tlvType)
|
||||
{
|
||||
case Tlv::kRoute:
|
||||
SuccessOrExit(error = message->AppendRouteTlv(router));
|
||||
SuccessOrExit(error = message->AppendCompactRouteTlv(aInfo.mRloc16));
|
||||
break;
|
||||
|
||||
case Tlv::kAddress16:
|
||||
@@ -1083,6 +1083,7 @@ void Mle::HandleLinkAcceptVariant(RxInfo &aRxInfo, MessageType aMessageType)
|
||||
}
|
||||
|
||||
info.mExtAddress = router->GetExtAddress();
|
||||
info.mRloc16 = router->GetRloc16();
|
||||
info.mLinkMargin = Get<Mac::Mac>().ComputeLinkMargin(aRxInfo.mMessage.GetAverageRss());
|
||||
|
||||
SuccessOrExit(error = SendLinkAccept(info));
|
||||
|
||||
Reference in New Issue
Block a user