From cde7fd02c7707953df3737c00bbf81512471ead9 Mon Sep 17 00:00:00 2001 From: Abtin Keshavarzian Date: Tue, 3 Jan 2023 17:07:08 -0800 Subject: [PATCH] [mle] use DUA address directly in `AppendAddressRegistrationTlv()` (#8608) This commit skips creating a local copy of DUA address and directly uses `Get().GetDomainUnicastAddress()` which will be fully inlined. --- src/core/thread/mle.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index b6a537843..33bd615e5 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -4586,9 +4586,6 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode uint8_t length = 0; uint8_t counter = 0; uint16_t startOffset = GetLength(); -#if OPENTHREAD_CONFIG_DUA_ENABLE - Ip6::Address domainUnicastAddress; -#endif tlv.SetType(Tlv::kAddressRegistration); SuccessOrExit(error = Append(tlv)); @@ -4604,21 +4601,18 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode counter++; #if OPENTHREAD_CONFIG_DUA_ENABLE - // Cache Domain Unicast Address. - domainUnicastAddress = Get().GetDomainUnicastAddress(); - - if (Get().HasUnicastAddress(domainUnicastAddress)) + if (Get().HasUnicastAddress(Get().GetDomainUnicastAddress())) { - SuccessOrAssert(Get().GetContext(domainUnicastAddress, context)); + SuccessOrAssert(Get().GetContext(Get().GetDomainUnicastAddress(), context)); // Prioritize DUA, compressed entry entry.SetContextId(context.mContextId); - entry.SetIid(domainUnicastAddress.GetIid()); + entry.SetIid(Get().GetDomainUnicastAddress().GetIid()); SuccessOrExit(error = AppendBytes(&entry, entry.GetLength())); length += entry.GetLength(); counter++; } -#endif // OPENTHREAD_CONFIG_DUA_ENABLE +#endif for (const Ip6::Netif::UnicastAddress &addr : Get().GetUnicastAddresses()) { @@ -4629,8 +4623,7 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode } #if OPENTHREAD_CONFIG_DUA_ENABLE - // Skip DUA that was already appended above. - if (addr.GetAddress() == domainUnicastAddress) + if (addr.GetAddress() == Get().GetDomainUnicastAddress()) { continue; }