Skip to content

Commit

Permalink
Set the cache-flush bit for "unique" records in minimal mdns.
Browse files Browse the repository at this point in the history
There should only be one entity around with a given Matter instance name or
Matter hostname, so all records which have those as the QName are part of the
unique set.

Fixes #23918
  • Loading branch information
bzbarsky-apple committed Dec 6, 2022
1 parent 14ab4a9 commit 9d604b0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,10 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const OperationalAdvertisingParameters &
return CHIP_ERROR_NO_MEMORY;
}

if (!operationalAllocator->AddResponder<SrvResponder>(SrvResourceRecord(instanceName, hostName, params.GetPort()))
// We are the sole owner of our instanceName, so records keyed on the
// instanceName should have the cache-flush bit set.
if (!operationalAllocator
->AddResponder<SrvResponder>(SrvResourceRecord(instanceName, hostName, params.GetPort()).SetCacheFlush(true))
.SetReportAdditional(hostName)
.IsValid())
{
Expand All @@ -497,7 +500,8 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const OperationalAdvertisingParameters &
}

if (!operationalAllocator
->AddResponder<TxtResponder>(TxtResourceRecord(instanceName, GetOperationalTxtEntries(operationalAllocator, params)))
->AddResponder<TxtResponder>(
TxtResourceRecord(instanceName, GetOperationalTxtEntries(operationalAllocator, params)).SetCacheFlush(true))
.SetReportAdditional(hostName)
.IsValid())
{
Expand Down
6 changes: 6 additions & 0 deletions src/lib/dnssd/minimal_mdns/responders/IP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void IPv4Responder::AddAllResponses(const chip::Inet::IPPacketInfo * source, Res
assert(addr.IsIPv4());

IPResourceRecord record(GetQName(), addr);
// We're the only thing around with our hostname, so we should set the
// cache-flush bit.
record.SetCacheFlush(true);
configuration.Adjust(record);
delegate->AddResponse(record);
}
Expand All @@ -59,6 +62,9 @@ void IPv6Responder::AddAllResponses(const chip::Inet::IPPacketInfo * source, Res
assert(addr.IsIPv6());

IPResourceRecord record(GetQName(), addr);
// We're the only thing around with our hostname, so we should set the
// cache-flush bit.
record.SetCacheFlush(true);
configuration.Adjust(record);
delegate->AddResponse(record);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class IPResponseAccumulator : public ResponderDelegate
{

NL_TEST_ASSERT(mSuite, (record.GetType() == QType::A) || (record.GetType() == QType::AAAA));
NL_TEST_ASSERT(mSuite, record.GetClass() == QClass::IN);
NL_TEST_ASSERT(mSuite, record.GetClass() == QClass::IN_FLUSH);
NL_TEST_ASSERT(mSuite, record.GetName() == kNames);
}

Expand Down

0 comments on commit 9d604b0

Please sign in to comment.