[OpenWrt-Devel] [PATCH] odhcpd: add network dependent start trigger

Eric Luehrsen ericluehrsen at gmail.com
Sun Feb 24 01:05:42 EST 2019


Recent (20190207) changes to odhcpd makee it dependent on OpenWrt
logical interfaces. Boot time race conditions may make odhcpd binding
a challenge. Intermittent or inconsistent problems can occur with DHCP
requests until odhcpd is restarted. Change start up scripts to use
procd interface triggers such as dnsmasq and others have already.

Signed-off-by: Eric Luehrsen <ericluehrsen at gmail.com>
---
  .../network/services/odhcpd/files/odhcpd.init | 20 +++++++++++++++++--
  1 file changed, 18 insertions(+), 2 deletions(-)

--- a/package/network/services/odhcpd/files/odhcpd.init
+++ b/package/network/services/odhcpd/files/odhcpd.init
@@ -1,10 +1,20 @@
  #!/bin/sh /etc/rc.common

-START=35
+START=19
  STOP=85
  USE_PROCD=1

+boot() {
+	ODHCPD_BOOT=1
+	start "$@"
+}
+
  start_service() {
+	if [ -n "$ODHCPD_BOOT" ] ; then
+		# odhcpd needs to wait for OpenWrt logical interfaces
+		return 0
+	fi
+
  	procd_open_instance
  	procd_set_param command /usr/sbin/odhcpd
  	procd_set_param respawn
@@ -17,6 +27,12 @@ reload_service() {

  service_triggers()
  {
-	procd_add_reload_trigger "dhcp"
+	if [ -n "$ODHCPD_BOOT" ] ; then
+		# one time trigger at boot to wait for logical interface setup
+		procd_add_raw_trigger "interface.*.up" 3000 /etc/init.d/odhcpd restart
+	else
+		# reload odhcpd also for network reconfiguration
+		procd_add_reload_trigger "dhcp" "network"
+	fi
  }

-- 
2.20.1

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



More information about the openwrt-devel mailing list