From: Philip Prindeville Date: Wed, 1 Aug 2018 18:41:21 +0000 (-0600) Subject: isc-dhcp: improve startup performance X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=refs%2Fpull%2F11897%2Fhead;p=feed%2Fpackages.git isc-dhcp: improve startup performance On some platforms where interfaces come up very slowly, this can cause a race-condition with dhcpd coming up before all the interfaces have finished initializing. Signed-off-by: Philip Prindeville --- diff --git a/net/isc-dhcp/Makefile b/net/isc-dhcp/Makefile index ec1ece1448..d80d23113c 100644 --- a/net/isc-dhcp/Makefile +++ b/net/isc-dhcp/Makefile @@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=isc-dhcp UPSTREAM_NAME:=dhcp PKG_VERSION:=4.4.1 -PKG_RELEASE:=5 +PKG_RELEASE:=6 PKG_LICENSE:=BSD-3-Clause PKG_LICENSE_FILES:=LICENSE diff --git a/net/isc-dhcp/files/dhcpd.init b/net/isc-dhcp/files/dhcpd.init index 954d332b48..33e45ad88c 100644 --- a/net/isc-dhcp/files/dhcpd.init +++ b/net/isc-dhcp/files/dhcpd.init @@ -270,7 +270,16 @@ general_config() { echo "nameserver 127.0.0.1" >> /tmp/resolv.conf } +# base procd hooks + +boot() { + DHCPD_BOOT=1 + start "$@" +} + start_service() { + local domain dhcp_ifs authoritative + if [ -n "$DHCPD_BOOT" ] ; then return 0 fi @@ -279,15 +288,13 @@ start_service() { touch $lease_file fi - local domain dhcp_ifs - if [ -e "/etc/dhcpd.conf" ] ; then config_file="/etc/dhcpd.conf" else . /lib/functions/network.sh config_load dhcp - local authoritative + general_config > $config_file config_foreach dhcpd_add dhcp @@ -302,13 +309,33 @@ start_service() { procd_close_instance } -boot() { - DHCPD_BOOT=1 - start "$@" +reload_service() { + rc_procd start_service "$@" + prodcd_send_signal dhcpd "$@" } -service_triggers() -{ - procd_add_reload_trigger "dhcp" - procd_add_raw_trigger "interface.*" 3000 /etc/init.d/dhcpd reload +add_interface_trigger() { + local cfg=$1 + local trigger ignore + + config_get trigger "$cfg" interface + config_get_bool ignore "$cfg" ignore 0 + + if [ -n "$trigger" -a $ignore -eq 0 ] ; then + procd_add_reload_interface_trigger "$trigger" + fi } + +service_triggers() { + if [ -n "$DHCPD_BOOT" ] ; then + # Make the first start robust to slow interfaces; wait a while + procd_add_raw_trigger "interface.*.up" 5000 /etc/init.d/dhcpd restart + + else + # reload with normal parameters + procd_add_reload_trigger "network" "dhcp" + config_load dhcp + config_foreach add_interface_trigger dhcp + fi +} +