isc-dhcp: improve startup performance 11897/head
authorPhilip Prindeville <philipp@redfish-solutions.com>
Wed, 1 Aug 2018 18:41:21 +0000 (12:41 -0600)
committerPhilip Prindeville <philipp@redfish-solutions.com>
Wed, 22 Apr 2020 05:57:33 +0000 (23:57 -0600)
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 <philipp@redfish-solutions.com>
net/isc-dhcp/Makefile
net/isc-dhcp/files/dhcpd.init

index ec1ece144818b96085b119d0c703071f22819a71..d80d23113cdaac3f2f0591bca98ac843aee2cfd2 100644 (file)
@@ -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
index 954d332b48bb262f486bded53779ab6b8f8b1746..33e45ad88c7637656ee317cf071d51b8f93faad4 100644 (file)
@@ -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
+}
+