ot-br-posix: [dns][srp] Service deleted in SRP Registrar is not deleted in Discovery-Proxy
Describe the bug A clear and concise description of what the bug is.
In cert test 2.8 Removing Some Published Services, the OTBR consistently fails step 19 which checks that a removed service (in SRP Registrar) does not show up anymore in a unicast DNS query sent to the Thread BR.
After a single service is successfully removed, the PTR record gets advertised with mDNS on the AIL with TTL=0 as expected.
But when after this a unicast query is made for the SRV record of the service, it does still show up in the DNS answer with a fixed TTL value of 10. (While it should not be present, being an expired/deleted record.)
The log file from the OTBR shows that the answer is retrieved from the Discovery Proxy (log line DPROXY) and from there gets fed back to the unicast DNS answer.
To Reproduce Information to reproduce the behavior, including:
- Git commit id: ed7db65f2 (OTBR reference build)
- IEEE 802.15.4 hardware platform: OTS14_BR AutoDUT
- Build steps
- Network topology: one End Device (ED_1) linked to one Thread BR DUT (BR_1)
Expected behavior A clear and concise description of what you expected to happen.
DNS unicast query for SRV record of the service should return success and 0 answers. (DProxy should not cache the deleted service records)
Console/log output If applicable, add console/log output to help explain your problem.
BR log output snippets:
- Service deletion
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.092 [I] SrpServer-----: Received DNS update from fd00:db9:0:0:6f2e:a049:87ef:d3bc
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.144 [I] SrpServer-----: Processed SRP update info
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.144 [I] SrpServer-----: Host:host-test-1.default.service.arpa.
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.144 [I] SrpServer-----: Lease:600, key-lease:600, ttl:600
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: 1 host address(es):
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: fd12:7b72:49cd:1:3309:1fba:dffa:e645
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: Deleting service 'service-test-1._thread-test._udp.default.service.arpa.'
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: SRP update handler is notified (updatedId = 2041355067)
May 8 00:10:51 raspberrypi otbr-agent[4148]: [INFO]-ADPROXY-: Advertise SRP service updates: host=host-test-1.default.service.arpa.
May 8 00:10:51 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: Removing service service-test-1._thread-test._udp
May 8 00:10:51 raspberrypi otbr-agent[4148]: [INFO]-ADPROXY-: Handle unpublish SRP service 'service-test-1._thread-test._udp.default.service.arpa.': OK
May 8 00:10:51 raspberrypi otbr-agent[4148]: [INFO]-ADPROXY-: Waiting for more publishing callbacks 1
May 8 00:10:51 raspberrypi otbr-agent[4148]: [INFO]-ADPROXY-: Handle publish SRP host 'host-test-1.default.service.arpa.': OK
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: Handler result of SRP update (id = 2041355067) is received: OK
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: Committing update for existing host host-test-1.default.service.arpa.
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: Granted lease:600, key-lease:600, ttl:600
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.145 [I] SrpServer-----: Remove but retain name of service 'service-test-1._thread-test._udp.default.service.arpa.'
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.146 [I] SrpServer-----: Keep unchanged service 'service-test-2._thread-test._udp.default.service.arpa.'
May 8 00:10:51 raspberrypi otbr-agent[4148]: 00:01:30.146 [I] SrpServer-----: Send success response
- When DNS unicast query for service comes in, 1 answer is given:
May 8 00:11:12 raspberrypi otbr-agent[4148]: 00:01:50.622 [I] DnssdServer---: Received query from fd00:db9:0:0:6f2e:a049:87ef:d3bc
May 8 00:11:12 raspberrypi otbr-agent[4148]: 00:01:50.623 [I] DnssdServer---: SRV query for 'service-test-1._thread-test._udp.default.service.arpa.'
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-DPROXY--: Subscribe: service-test-1._thread-test._udp.default.service.arpa.
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: Subscribe service service-test-1._thread-test._udp (total 1)
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: DNSServiceResolve service-test-1 _thread-test._udp inf 0
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: DNSServiceResolve reply: service-test-1._thread-test._udp.local. host host-test-1.local.:985, TXT=1B inf 2, flags=0
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: DNSServiceGetAddrInfo host-test-1.local. inf 2
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: DNSServiceGetAddrInfo reply: flags=1073741826, host=host-test-1.local., sa_family=10, error=0
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: DNSServiceGetAddrInfo reply: add address=fd12:7b72:49cd:1:3309:1fba:dffa:e645, ttl=120
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: Service _thread-test._udp is resolved successfully: add service-test-1 host host-test-1.local. addresses 1
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-MDNS----: addresses: [ fd12:7b72:49cd:1:3309:1fba:dffa:e645 ]
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-DPROXY--: Service discovered: _thread-test._udp, instance service-test-1 hostname host-test-1.local. addresses 1 port 55555 priority 0 weight 0
May 8 00:11:12 raspberrypi otbr-agent[4148]: [INFO]-DPROXY--: Unsubscribe: service-test-1._thread-test._udp.default.service.arpa.
May 8 00:11:12 raspberrypi otbr-agent[4148]: 00:01:50.626 [I] DnssdServer---: Send response, rcode:0
Additional context Add any other context about the problem here. log/PCAP available if needed. Possibly this issue should go into the “ot-br-posix” project but I wasn’t sure.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (11 by maintainers)
@librasungirl After testing, it looks like the new mDNSResponder version does indeed fix the issue. We could close this issue?
@librasungirl It’s good news that Apple released such a recent mDNSResponder! In any case, it will likely still have the issue. This could be patched, using the existing framework for applying patches to the source that is already in place in ot-br-posix for mDNSResponder. I could take a look into the code on service deletion. If you already have an idea where I should look also let me know.
I did investigate the platform
ot-br-posixAdv Proxy code, and everything seems fine to me. To be frank, it’s not the easiest code to read through.I’ll add my findings to help others investigate this further.
First, the overall code architecture:
otbr::Mdns::Publisherclass, which defines the mDNS-related API used by the Adv Proxy and Discovery Proxy platform implementation.virtualinterface methods that are expected to be defined by its sub-classes.otbritself, one hooking it tomDNSResponder, and another toAvahi.Here is the call flow for the removal of a service:
PublisherMDnsSd::UnpublishService()is called to remove the service.RemoveServiceRegistration()on the base class.otbrLogInfo("Removing service %s.%s", aName.c_str(), aType.c_str());log line, which we do indeed see in the logs.ServiceRegistrationPtr(which is anstd::unique_ptr) from the list of services.ServiceRegistrationobject itself is then destroyed.ServiceRegistrationobjects are defined by the base classPublisher, but then sub-classes ofPublishercan define their own sub-classes of this type to add additional fields and functionality.Publisherdefinesclass DnssdServiceRegistration : public ServiceRegistrationand tracksDNSServiceRef mServiceRefas a member variable.~DnssdServiceRegistration(), callsDnssdServiceRegistration::Unregister().Unregister()method de-allocates the service refDNSServiceRefDeallocate(mServiceRef).DNSServiceRegister()(the mDNSResponder API), which mentionsDNSServiceRefDeallocate()to remove a service:Based on the above analysis, everything in the
ot-br-posixcode appears to be correct, so this may be an issue with the underlying mDNSResponder library being used?I will assign this to Rongli to see if someone from her team can investigate this further.