From 07d69f30ce813dad859f38bdb29f7bd9a57cab74 Mon Sep 17 00:00:00 2001 From: Suvesh Pratapa <66088488+suveshpratapa@users.noreply.github.com> Date: Wed, 22 Mar 2023 01:14:31 -0400 Subject: [PATCH] [dua] remove DUA address if network data no longer contains DUA prefix (#8874) Fix for the following bug: Leader/Parent (OTBR) is reset (taken off the network), leading to its MTD child being detached. When the parent is brought back on the network without configuring the previous DUA prefix, the MTD asserts complaining that its DUA prefix is not valid anymore. 1. We don't assert anymore in this situation, rather the MTD just won't include the DUA address in its address registration TLV. 2. More importantly, we remove a "cached" DUA address if we find that the network leader is no longer configured with a DUA prefix. --- src/core/thread/dua_manager.cpp | 13 +++++++++++++ src/core/thread/mle.cpp | 5 ++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/core/thread/dua_manager.cpp b/src/core/thread/dua_manager.cpp index f0e09e426..d8866663f 100644 --- a/src/core/thread/dua_manager.cpp +++ b/src/core/thread/dua_manager.cpp @@ -305,6 +305,19 @@ void DuaManager::HandleNotifierEvents(Events aEvents) { Mle::MleRouter &mle = Get(); +#if OPENTHREAD_CONFIG_DUA_ENABLE + if (aEvents.Contains(kEventThreadNetdataChanged)) + { + Lowpan::Context context; + // Remove a stale DUA address if any. + if (Get().HasUnicastAddress(Get().GetDomainUnicastAddress()) && + (Get().GetContext(Get().GetDomainUnicastAddress(), context) != kErrorNone)) + { + RemoveDomainUnicastAddress(); + } + } +#endif + VerifyOrExit(mle.IsAttached(), mDelay.mValue = 0); if (aEvents.Contains(kEventThreadRoleChanged)) diff --git a/src/core/thread/mle.cpp b/src/core/thread/mle.cpp index 69c898124..5354c6cda 100644 --- a/src/core/thread/mle.cpp +++ b/src/core/thread/mle.cpp @@ -4599,10 +4599,9 @@ Error Mle::TxMessage::AppendAddressRegistrationTlv(AddressRegistrationMode aMode counter++; #if OPENTHREAD_CONFIG_DUA_ENABLE - if (Get().HasUnicastAddress(Get().GetDomainUnicastAddress())) + if (Get().HasUnicastAddress(Get().GetDomainUnicastAddress()) && + (Get().GetContext(Get().GetDomainUnicastAddress(), context) == kErrorNone)) { - SuccessOrAssert(Get().GetContext(Get().GetDomainUnicastAddress(), context)); - // Prioritize DUA, compressed entry entry.SetContextId(context.mContextId); entry.SetIid(Get().GetDomainUnicastAddress().GetIid());