From 590b5d614fac18c1d72d04941d6354e9390b0543 Mon Sep 17 00:00:00 2001 From: Michael Spang Date: Wed, 18 Aug 2021 01:49:37 +0000 Subject: [PATCH] Fix discovery issues with minimal mDNS - Don't skip the rest of the packet if it contains an irrelevant resource record. DNS packets can contain records other than those directly requested. - Don't terminate chip-tool commissioning if a device other than the commissionee is discovered. There is nothing preventing receiving OnAddressUpdateComplete for stale records and this will generally happening when doing tests in quick succession because stale records accumulate in the SRP server. fixes #9099 --- examples/chip-tool/commands/pairing/PairingCommand.cpp | 4 ++-- src/lib/mdns/Resolver_ImplMinimalMdns.cpp | 10 ++-------- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 949c5694ff897d..473b0a5e1e7c1b 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -397,8 +397,8 @@ CHIP_ERROR PairingCommand::UpdateNetworkAddress() void PairingCommand::OnAddressUpdateComplete(NodeId nodeId, CHIP_ERROR err) { - ChipLogProgress(chipTool, "OnAddressUpdateComplete: %s", ErrorStr(err)); - if (err != CHIP_NO_ERROR) + ChipLogProgress(chipTool, "OnAddressUpdateComplete: %" PRIx64 ": %s", nodeId, ErrorStr(err)); + if (err != CHIP_NO_ERROR && nodeId == mRemoteId) { // Set exit status only if the address update failed. // Otherwise wait for OnCommissioningComplete() callback. diff --git a/src/lib/mdns/Resolver_ImplMinimalMdns.cpp b/src/lib/mdns/Resolver_ImplMinimalMdns.cpp index b2b291457f5fe2..d2dd1d6d4e629d 100644 --- a/src/lib/mdns/Resolver_ImplMinimalMdns.cpp +++ b/src/lib/mdns/Resolver_ImplMinimalMdns.cpp @@ -219,25 +219,19 @@ void PacketDataReporter::OnResource(ResourceType type, const ResourceData & data else if (mDiscoveryType == DiscoveryType::kOperational) { // Ensure this is our record. + // TODO: Fix this comparison which is too loose. if (HasQNamePart(data.GetName(), kOperationalServiceName)) { OnOperationalSrvRecord(data.GetName(), srv); } - else - { - mValid = false; - } } else if (mDiscoveryType == DiscoveryType::kCommissionableNode || mDiscoveryType == DiscoveryType::kCommissionerNode) { + // TODO: Fix this comparison which is too loose. if (HasQNamePart(data.GetName(), kCommissionableServiceName) || HasQNamePart(data.GetName(), kCommissionerServiceName)) { OnCommissionableNodeSrvRecord(data.GetName(), srv); } - else - { - mValid = false; - } } break; }