Skip to content

Commit

Permalink
Fix discovery issues with minimal mDNS (#9102)
Browse files Browse the repository at this point in the history
- 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 happen when doing tests in quick succession
  because stale records accumulate in the SRP server.

fixes #9099
  • Loading branch information
mspang authored Aug 20, 2021
1 parent 84876c7 commit 3b145cb
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
10 changes: 2 additions & 8 deletions src/lib/mdns/Resolver_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 3b145cb

Please sign in to comment.