diff --git a/src/core/backbone_router/bbr_manager.cpp b/src/core/backbone_router/bbr_manager.cpp index 1771f90d2..66311fc79 100644 --- a/src/core/backbone_router/bbr_manager.cpp +++ b/src/core/backbone_router/bbr_manager.cpp @@ -686,7 +686,7 @@ void Manager::HandleDadBackboneAnswer(const Ip6::Address &aDua, const Ip6::Inter Ip6::Address dest; dest.SetToRoutingLocator(Get().GetMeshLocalPrefix(), ndProxy->GetRloc16()); - Get().SendAddressError(aDua, aMeshLocalIid, &dest); + Get().SendAddressError(aDua, aMeshLocalIid, dest); } ot::BackboneRouter::NdProxyTable::NotifyDadComplete(*ndProxy, duplicate); @@ -739,7 +739,7 @@ void Manager::HandleProactiveBackboneNotification(const Ip6::Address { // Duplicated address detected, send ADDR_ERR.ntf to ff03::2 in the Thread network BackboneRouter::NdProxyTable::Erase(*ndProxy); - Get().SendAddressError(aDua, aMeshLocalIid, nullptr); + Get().SendAddressError(aDua, aMeshLocalIid, Ip6::Address::GetRealmLocalAllRoutersMulticast()); } exit: diff --git a/src/core/thread/address_resolver.cpp b/src/core/thread/address_resolver.cpp index 47c7c7961..02daf0752 100644 --- a/src/core/thread/address_resolver.cpp +++ b/src/core/thread/address_resolver.cpp @@ -678,19 +678,20 @@ template <> void AddressResolver::HandleTmf(Coap::Msg &aMsg) entry = FindCacheEntry(target, list, prev); VerifyOrExit(entry != nullptr); - if (list == &mCachedList) + if ((list == &mCachedList) && entry->IsLastTransactionTimeValid()) { - if (entry->IsLastTransactionTimeValid()) + // Receiving multiple Address Notification for an EID from + // different mesh-local IIDs indicates address is in use + // by more than one device. Try to resolve the duplicate + // address by sending an Address Error message. + + if (entry->GetMeshLocalIid() != meshLocalIid) { - // Receiving multiple Address Notification for an EID from - // different mesh-local IIDs indicates address is in use - // by more than one device. Try to resolve the duplicate - // address by sending an Address Error message. - - VerifyOrExit(entry->GetMeshLocalIid() == meshLocalIid, SendAddressError(target, meshLocalIid, nullptr)); - - VerifyOrExit(lastTransactionTime < entry->GetLastTransactionTime()); + SendAddressError(target, meshLocalIid, Ip6::Address::GetRealmLocalAllRoutersMulticast()); + ExitNow(); } + + VerifyOrExit(lastTransactionTime < entry->GetLastTransactionTime()); } entry->SetRloc16(rloc16); @@ -717,7 +718,7 @@ exit: void AddressResolver::SendAddressError(const Ip6::Address &aTarget, const Ip6::InterfaceIdentifier &aMeshLocalIid, - const Ip6::Address *aDestination) + const Ip6::Address &aDestination) { Error error; Coap::Message *message; @@ -725,22 +726,13 @@ void AddressResolver::SendAddressError(const Ip6::Address &aTarget, VerifyOrExit((message = Get().NewMessage()) != nullptr, error = kErrorNoBufs); - SuccessOrExit(error = message->Init(aDestination == nullptr ? Coap::kTypeNonConfirmable : Coap::kTypeConfirmable, - Coap::kCodePost)); - SuccessOrExit(error = message->AppendUriPathOptions(PathForUri(kUriAddressError))); + SuccessOrExit(error = message->InitAsPost(aDestination, kUriAddressError)); SuccessOrExit(error = message->AppendPayloadMarker()); SuccessOrExit(error = Tlv::Append(*message, aTarget)); SuccessOrExit(error = Tlv::Append(*message, aMeshLocalIid)); - if (aDestination == nullptr) - { - messageInfo.SetSockAddrToRlocPeerAddrToRealmLocalAllRoutersMulticast(); - } - else - { - messageInfo.SetSockAddrToRlocPeerAddrTo(*aDestination); - } + messageInfo.SetSockAddrToRlocPeerAddrTo(aDestination); SuccessOrExit(error = Get().SendMessage(*message, messageInfo)); @@ -817,7 +809,7 @@ template <> void AddressResolver::HandleTmf(Coap::Msg &aMsg) { destination.SetToRoutingLocator(Get().GetMeshLocalPrefix(), child.GetRloc16()); - SendAddressError(target, meshLocalIid, &destination); + SendAddressError(target, meshLocalIid, destination); ExitNow(); } } diff --git a/src/core/thread/address_resolver.hpp b/src/core/thread/address_resolver.hpp index 8b77bab9d..76b85404a 100644 --- a/src/core/thread/address_resolver.hpp +++ b/src/core/thread/address_resolver.hpp @@ -228,7 +228,7 @@ public: */ void SendAddressError(const Ip6::Address &aTarget, const Ip6::InterfaceIdentifier &aMeshLocalIid, - const Ip6::Address *aDestination); + const Ip6::Address &aDestination); private: static constexpr uint16_t kCacheEntries = OPENTHREAD_CONFIG_TMF_ADDRESS_CACHE_ENTRIES;