diff options
| author | Felix Fietkau | 2025-02-10 20:25:54 +0000 |
|---|---|---|
| committer | Felix Fietkau | 2025-02-10 20:28:32 +0000 |
| commit | c5ca22a71b2ecb83a2a28b46391dac443be315c2 (patch) | |
| tree | b7e10bdcd0220e7f944d4b33b7b363906c0728da | |
| parent | c0a2aa12c3979d9352228adacd4e186b30326713 (diff) | |
| download | mdnsd-c5ca22a71b2ecb83a2a28b46391dac443be315c2.tar.gz | |
cache: improve service discovery reliability
Send queries for non-host PTR services out to all interfaces instead of
just the one that they were first discovered on.
When updating, go through all non-host service entries and send a query.
When host records expire while non-host service entries remain, queries
were not automatically re-sent, causing some services with lower TTL to
be missed.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
| -rw-r--r-- | cache.c | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -142,11 +142,16 @@ void cache_cleanup(struct interface *iface) void cache_update(void) { + struct cache_service *s; struct interface *iface; vlist_for_each_element(&interfaces, iface, node) { - dns_send_question(iface, NULL, C_DNS_SD, TYPE_ANY, 0); - dns_send_question(iface, NULL, C_DNS_SD, TYPE_PTR, 0); + dns_send_question(iface, NULL, C_DNS_SD, TYPE_ANY, interface_multicast(iface)); + dns_send_question(iface, NULL, C_DNS_SD, TYPE_PTR, interface_multicast(iface)); + avl_for_each_element(&services, s, avl) + if (!s->host) + dns_send_question(iface, NULL, s->entry, TYPE_PTR, + interface_multicast(iface)); } } @@ -186,7 +191,10 @@ cache_service(struct interface *iface, char *entry, int hlen, int ttl) s->avl.key = type; avl_insert(&services, &s->avl); - if (!hlen) + if (hlen) + return s; + + vlist_for_each_element(&interfaces, iface, node) dns_send_question(iface, NULL, entry, TYPE_PTR, interface_multicast(iface)); return s; |