dnsmasq: add dhcp-script hook conditionally
authorHans Dedecker <dedeckeh@gmail.com>
Fri, 9 Jun 2017 14:24:12 +0000 (16:24 +0200)
committerHans Dedecker <dedeckeh@gmail.com>
Fri, 9 Jun 2017 14:44:04 +0000 (16:44 +0200)
Commit b32689afd6a661339861086c669e15c936293cf8 added support for dhcp-script hook.
Adding dhcp-script config option results into two instances of dnsmasq being run
which triggered oom issues on platforms having low memory.

The dnsmasq dhcp-script config option will now only be added if at least one of the
dhcp, tftp, neigh hotplug dirs has a regular hotplug file or if the dhcpscript uci
config option is specified.

Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
package/network/services/dnsmasq/Makefile
package/network/services/dnsmasq/files/dnsmasq.init

index 307b4defe710c8b30679f5e6fb4e0b95e13fb129..5b1073fc2c29a4d7483e96ff6073ff477c9f828b 100644 (file)
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=dnsmasq
 PKG_VERSION:=2.77
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
 PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq/
index 62a3169c6787e560b8321b048dd6a2c5a86bb6a0..2d05b77873c26be20889ee4a2f33ce1349c151cd 100644 (file)
@@ -89,6 +89,16 @@ log_once() {
                logger -t dnsmasq "$@"
 }
 
+has_handler() {
+       local file
+
+       for file in /etc/hotplug.d/dhcp/* /etc/hotplug.d/tftp/* /etc/hotplug.d/neigh/*; do
+               [ -f "$file" ] && return 0
+       done
+
+       return 1
+}
+
 append_bool() {
        local section="$1"
        local option="$2"
@@ -832,8 +842,10 @@ dnsmasq_start()
        config_get_bool readethers "$cfg" readethers
        [ "$readethers" = "1" -a \! -e "/etc/ethers" ] && touch /etc/ethers
 
-       xappend "--dhcp-script=$DHCPSCRIPT"
        config_get user_dhcpscript $cfg dhcpscript
+       if has_handler || [ -n "$user_dhcpscript" ]; then
+               xappend "--dhcp-script=$DHCPSCRIPT"
+       fi
 
        config_get leasefile $cfg leasefile "/tmp/dhcp.leases"
        [ -n "$leasefile" -a \! -e "$leasefile" ] && touch "$leasefile"