dnsmasq: add specific interface procd triggers

Right now interface.update events are sent out by netifd upon interface state,
route, address (lifetime), prefix lifetime changes.
Dnsmasq is only interested in interface state changes and currently adds an
interface trigger for all the "interface.*" events.
In combination with commit 23bba9cb33, which triggers a SIGHUP signal to dnsmasq,
IPv6 address/prefix lifetime changes on the wan will trigger dnsmasq reloads which
can become frequent in case of shorter lifetimes.

To avoid frequent dnsmasq reload, this patch adds specific interface triggers.
During dnsmasq init it loops dhcp uci section; if the value of the ignore option
is set to 0, then the corresponding interface trigger is not installed.
Otherwise, if the ignore option value is 1, then procd_add_interface_trigger is
called which adds the interface trigger.

Signed-off-by: hux <xinxing.huchn@gmail.com>
This commit is contained in:
hux 2018-05-08 00:37:48 +02:00 committed by Hans Dedecker
parent dc629d9cf5
commit ecd954d530
2 changed files with 14 additions and 2 deletions

View file

@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=dnsmasq PKG_NAME:=dnsmasq
PKG_VERSION:=2.79 PKG_VERSION:=2.79
PKG_RELEASE:=3 PKG_RELEASE:=4
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq/ PKG_SOURCE_URL:=http://thekelleys.org.uk/dnsmasq/

View file

@ -1042,10 +1042,22 @@ dnsmasq_stop()
rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp rm -f ${BASEDHCPSTAMPFILE}.${cfg}.*.dhcp
} }
add_interface_trigger()
{
local interface ignore
config_get interface "$1" interface
config_get_bool ignore "$1" ignore 0
[ -n "$interface" -a $ignore -eq 0 ] && procd_add_interface_trigger "interface.*" "$interface" /etc/init.d/dnsmasq reload
}
service_triggers() service_triggers()
{ {
procd_add_reload_trigger "dhcp" "system" procd_add_reload_trigger "dhcp" "system"
procd_add_raw_trigger "interface.*" 2000 /etc/init.d/dnsmasq reload
config_load dhcp
config_foreach add_interface_trigger dhcp
} }
boot() boot()