From: Felix Fietkau Date: Wed, 10 Nov 2021 09:07:02 +0000 (+0100) Subject: dnsmasq: generate the dns object name dynamically X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=0b79e7c01e42898547eddefc9efc030f2e772b93;p=openwrt%2Fstaging%2Fjow.git dnsmasq: generate the dns object name dynamically Fixes an issue with running multiple dnsmasq instances Signed-off-by: Felix Fietkau --- diff --git a/package/network/services/dnsmasq/patches/200-ubus_dns.patch b/package/network/services/dnsmasq/patches/200-ubus_dns.patch index 506a413ae2..03fc5b50b3 100644 --- a/package/network/services/dnsmasq/patches/200-ubus_dns.patch +++ b/package/network/services/dnsmasq/patches/200-ubus_dns.patch @@ -162,7 +162,7 @@ ttl = find_soa(header, qlen, doctored); --- a/src/ubus.c +++ b/src/ubus.c -@@ -72,6 +72,14 @@ static struct ubus_object ubus_object = +@@ -72,6 +72,13 @@ static struct ubus_object ubus_object = .subscribe_cb = ubus_subscribe_cb, }; @@ -170,23 +170,35 @@ + { .name = "dnsmasq.dns" }; + +static struct ubus_object ubus_dns_object = { -+ .name = "dnsmasq.dns", + .type = &ubus_dns_object_type, +}; + static void ubus_subscribe_cb(struct ubus_context *ctx, struct ubus_object *obj) { (void)ctx; -@@ -112,6 +120,8 @@ char *ubus_init() +@@ -105,13 +112,21 @@ static void ubus_disconnect_cb(struct ub + char *ubus_init() + { + struct ubus_context *ubus = NULL; ++ char *dns_name; + int ret = 0; + + if (!(ubus = ubus_connect(NULL))) + return NULL; ++ dns_name = whine_malloc(strlen(daemon->ubus_name) + 5); ++ sprintf(dns_name, "%s.dns", daemon->ubus_name); ++ ubus_object.name = daemon->ubus_name; ++ ubus_dns_object.name = dns_name; ++ ret = ubus_add_object(ubus, &ubus_object); + if (!ret) + ret = ubus_add_object(ubus, &ubus_dns_object); if (ret) { ubus_destroy(ubus); -@@ -181,6 +191,17 @@ void check_ubus_listeners() +@@ -181,6 +196,17 @@ void check_ubus_listeners() } \ } while (0) @@ -204,7 +216,7 @@ static int ubus_handle_metrics(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg) -@@ -328,6 +349,50 @@ fail: +@@ -328,6 +354,50 @@ fail: } \ } while (0)