Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set the cache-flush bit for "unique" records in minimal mdns. #23933

Merged
merged 2 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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