Currently, when using multiple dnsmasq instances they are all assigned
to the same Ubus instance name. This does not work, as only a single
instance can register with Ubus at a time. In the log, this leads to
`Cannot add object to UBus: Invalid argument` error messages.
Furthermore, upstream 3c93e8eb41952a9c91699386132d6fe83050e9be changes
behaviour so that instead of the log, dnsmasq crashes instead.
This means that dnsmasq versions v2.86test2 and newer no longer apply.

When /etc/config/dhcp defines multiple named dnsmasq instances, this
patch now assigns unique names to each of them. This lets all instances
register with Ubus concurrently under their own names. To avoid breaking
backwards compatibility with packages relying on the old default name,
unnamed dnsmasq instances retain previous behaviour. This works well in
the common scenario of a single dnsmasq instance. With multiple unnamed
instances present, the config should be updated accordingly and Ubus
either disabled on all but one of them, or them being named accordingly.

Signed-off-by: Etan Kissling <etan.kissl...@gmail.com>
---
v5: Introduce this patch so that dnsmasq can be updated.

 package/network/services/dnsmasq/files/dnsmasq.init | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init 
b/package/network/services/dnsmasq/files/dnsmasq.init
index 44e7d2d4f9..0a200861a1 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -801,6 +801,12 @@ dnsmasq_start()
        config_get_bool disabled "$cfg" disabled 0
        [ "$disabled" -gt 0 ] && return 0
 
+       # assign instance name
+       local instancename="dnsmasq"
+       if expr "$cfg" : "cfg[0-9a-f]*" >/dev/null != "9"; then
+               instancename="dnsmasq.$cfg" # named config section
+       fi
+
        # reset list of DOMAINS and DNS servers (for each dnsmasq instance)
        DNS_SERVERS=""
        DOMAIN=""
@@ -879,7 +885,8 @@ dnsmasq_start()
        append_bool "$cfg" localise_queries "--localise-queries"
        append_bool "$cfg" readethers "--read-ethers"
        append_bool "$cfg" dbus "--enable-dbus"
-       append_bool "$cfg" ubus "--enable-ubus" 1
+       config_get_bool ubus "$cfg" "ubus" 1
+       [ $ubus -eq 1 ] && xappend "--enable-ubus=$instancename"
        append_bool "$cfg" expandhosts "--expand-hosts"
        config_get tftp_root "$cfg" "tftp_root"
        [ -n "$tftp_root" ] && mkdir -p "$tftp_root" && append_bool "$cfg" 
enable_tftp "--enable-tftp"
-- 
2.30.1 (Apple Git-130)


_______________________________________________
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel

Reply via email to