From e91ed406ecebb4bc08c346929e25f1b819c19edd Mon Sep 17 00:00:00 2001 From: Felix Fietkau Date: Mon, 8 Jan 2024 10:21:48 +0100 Subject: [PATCH 1/3] ubus: assume that the service iface can be NULL Fix crash on dump Signed-off-by: Felix Fietkau --- ubus.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ubus.c b/ubus.c index 30e6121..6991278 100644 --- a/ubus.c +++ b/ubus.c @@ -104,7 +104,8 @@ umdns_browse(struct ubus_context *ctx, struct ubus_object *obj, *local = '\0'; c2 = blobmsg_open_table(&b, buffer); strncat(buffer, ".local", MAX_NAME_LEN); - blobmsg_add_string(&b, "iface", s->iface->name); + if (s->iface) + blobmsg_add_string(&b, "iface", s->iface->name); cache_dump_records(&b, s->entry, array, &hostname); if (address) cache_dump_records(&b, hostname, array, NULL); -- 2.30.2 From 93c9036d4e293b2c94a04a6a51bb0cc778e0b373 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Sun, 21 Apr 2024 19:44:07 +0200 Subject: [PATCH 2/3] dns: reply to A/AAAA questions for additional hostnames Signed-off-by: John Crispin --- dns.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/dns.c b/dns.c index 2b5a390..f6f0be5 100644 --- a/dns.c +++ b/dns.c @@ -358,6 +358,7 @@ static void parse_question(struct interface *iface, struct sockaddr *from, char *name, struct dns_question *q) { struct sockaddr *to = NULL; + struct hostname *h; char *host; /* TODO: Multicast if more than one quarter of TTL has passed */ @@ -404,8 +405,15 @@ parse_question(struct interface *iface, struct sockaddr *from, char *name, struc host = strstr(name, ".local"); if (host) *host = '\0'; - if (!strcmp(umdns_host_label, name)) + if (!strcmp(umdns_host_label, name)) { dns_reply_a(iface, to, announce_ttl, NULL); + } else { + if (host) + *host = '.'; + vlist_for_each_element(&hostnames, h, node) + if (!strcmp(h->hostname, name)) + dns_reply_a(iface, to, announce_ttl, h->hostname); + } break; }; } -- 2.30.2 From fbaca4b6f530d4b2f361ee15c266aa19a708242b Mon Sep 17 00:00:00 2001 From: John Crispin Date: Tue, 17 Sep 2024 18:00:37 +0200 Subject: [PATCH 3/3] cache: improve update call by doing a full refresh probe Signed-off-by: John Crispin --- cache.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cache.c b/cache.c index 8324993..384487a 100644 --- a/cache.c +++ b/cache.c @@ -143,11 +143,11 @@ void cache_update(void) { struct interface *iface; - struct cache_service *s; - vlist_for_each_element(&interfaces, iface, node) - avl_for_each_element(&services, s, avl) - dns_send_question(iface, NULL, s->entry, TYPE_PTR, 0); + 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); + } } static struct cache_service* -- 2.30.2