Skip to content

Commit 2450603

Browse files
committed
Fix flaky DHCP in non-Thunder builds in rpi3
If your DHCP server is dnsmasq-based, you're not building Thunder and you're using a rpi3, there is a good chance half the time the rpi boots without an IP address. This is because: * udhcp sends 3 DISCOVER, waiting 3 seconds for a response in each case. * The NIC of the rpi3 usually takes slightly above 6 seconds from `ifconfig eth0 up` to being functional enough to send packets, so the first two DISCOVER packets never reach the network. * dnsmasq will do a 3 second long ping of an IP address before assigning it to a lease, unless its has done this recently and has it cached. If this happens on the last DISCOVER, by the time the rpi3 gets the OFFER packet, udhcp has already given up. Once identified the problem, a simple fix is trivial: patch udhcp to send more DISCOVER packets.
1 parent 84742d3 commit 2450603

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From 35b5e8804c8412546dd6a42c7d8979b82ba3ceec Mon Sep 17 00:00:00 2001
2+
From: Alicia Boya Garcia <[email protected]>
3+
Date: Tue, 15 Jul 2025 09:46:45 +0000
4+
Subject: [PATCH] Do more DISCOVER retries
5+
6+
---
7+
networking/udhcp/dhcpc.c | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
11+
index 739870b..e501d42 100644
12+
--- a/networking/udhcp/dhcpc.c
13+
+++ b/networking/udhcp/dhcpc.c
14+
@@ -1250,7 +1250,7 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
15+
llist_t *list_x = NULL;
16+
int tryagain_timeout = 20;
17+
int discover_timeout = 3;
18+
- int discover_retries = 3;
19+
+ int discover_retries = 6;
20+
uint32_t server_addr = server_addr; /* for compiler */
21+
uint32_t requested_ip = 0;
22+
uint32_t xid = xid; /* for compiler */
23+
--
24+
2.43.0
25+

0 commit comments

Comments
 (0)