[openwrt/openwrt] dnsmasq: generate the dns object name dynamically

LEDE Commits lede-commits at lists.infradead.org
Wed Nov 10 01:07:47 PST 2021


nbd pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/0b79e7c01e42898547eddefc9efc030f2e772b93

commit 0b79e7c01e42898547eddefc9efc030f2e772b93
Author: Felix Fietkau <nbd at nbd.name>
AuthorDate: Wed Nov 10 10:07:02 2021 +0100

    dnsmasq: generate the dns object name dynamically
    
    Fixes an issue with running multiple dnsmasq instances
    
    Signed-off-by: Felix Fietkau <nbd at nbd.name>
---
 .../services/dnsmasq/patches/200-ubus_dns.patch    | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

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)
  



More information about the lede-commits mailing list