From 6916ca8d33db0ab11434a8fb45f72abd70065c5e Mon Sep 17 00:00:00 2001
From: Felix Fietkau <nbd@nbd.name>
Date: Fri, 29 Jul 2016 14:26:55 +0200
Subject: [PATCH] dnsmasq: make the check for existing DHCP servers more
 reliable

If there is no carrier yet, wait for 2 seconds (STP forwarding delay)

Signed-off-by: Felix Fietkau <nbd@nbd.name>
---
 package/network/services/dnsmasq/files/dnsmasq.init | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/package/network/services/dnsmasq/files/dnsmasq.init b/package/network/services/dnsmasq/files/dnsmasq.init
index 3809e6c119..0941f87fa8 100644
--- a/package/network/services/dnsmasq/files/dnsmasq.init
+++ b/package/network/services/dnsmasq/files/dnsmasq.init
@@ -64,6 +64,12 @@ dhcp_check() {
 
 	[ -s "$stamp" ] && return $(cat "$stamp")
 
+	# If there's no carrier yet, skip this interface.
+	# The init script will be called again once the link is up
+	case "$(devstatus "$ifname" | jsonfilter -e @.carrier)" in
+		false) return 1;;
+	esac
+
 	udhcpc -n -q -s /bin/true -t 1 -i "$ifname" >&- && rv=1 || rv=0
 
 	[ $rv -eq 1 ] && \
-- 
GitLab