diff --git a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp index 52a8be78bc6ffa..6153ee8245f37a 100644 --- a/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Advertiser_ImplMinimalMdns.cpp @@ -488,18 +488,19 @@ CHIP_ERROR AdvertiserMinMdns::Advertise(const OperationalAdvertisingParameters & return CHIP_ERROR_NO_MEMORY; } - if (!operationalAllocator->AddResponder(SrvResourceRecord(instanceName, hostName, params.GetPort())) - .SetReportAdditional(hostName) - .IsValid()) + // We are the sole owner of our instanceName, so records keyed on the + // instanceName should have the cache-flush bit set. + SrvResourceRecord srvRecord(instanceName, hostName, params.GetPort()); + srvRecord.SetCacheFlush(true); + if (!operationalAllocator->AddResponder(srvRecord).SetReportAdditional(hostName).IsValid()) { ChipLogError(Discovery, "Failed to add SRV record mDNS responder"); return CHIP_ERROR_NO_MEMORY; } - if (!operationalAllocator - ->AddResponder(TxtResourceRecord(instanceName, GetOperationalTxtEntries(operationalAllocator, params))) - .SetReportAdditional(hostName) - .IsValid()) + TxtResourceRecord txtRecord(instanceName, GetOperationalTxtEntries(operationalAllocator, params)); + txtRecord.SetCacheFlush(true); + if (!operationalAllocator->AddResponder(txtRecord).SetReportAdditional(hostName).IsValid()) { ChipLogError(Discovery, "Failed to add TXT record mDNS responder"); return CHIP_ERROR_NO_MEMORY; diff --git a/src/lib/dnssd/minimal_mdns/responders/IP.cpp b/src/lib/dnssd/minimal_mdns/responders/IP.cpp index c509d818adf573..8290db94e0aa40 100644 --- a/src/lib/dnssd/minimal_mdns/responders/IP.cpp +++ b/src/lib/dnssd/minimal_mdns/responders/IP.cpp @@ -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); } @@ -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); } diff --git a/src/lib/dnssd/minimal_mdns/responders/tests/TestIPResponder.cpp b/src/lib/dnssd/minimal_mdns/responders/tests/TestIPResponder.cpp index 6a148cf6628385..ca66dd184cc9e6 100644 --- a/src/lib/dnssd/minimal_mdns/responders/tests/TestIPResponder.cpp +++ b/src/lib/dnssd/minimal_mdns/responders/tests/TestIPResponder.cpp @@ -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); }