aboutsummaryrefslogtreecommitdiffstats
path: root/main/busybox/udhcpc.patch
blob: baf7c6138ed2ac9d7c822915917d8744d2093ecb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
udhcpc: Don't background if -n is given

we need add -b to our udhcpc options to prevent boot forever if there are no
dhcp server. We also need a way for users to disable this behavior by making
it possible to set -n option at runtime.

diff --git a/networking/udhcp/dhcpc.c b/networking/udhcp/dhcpc.c
index 6aa6731fb..2c0307413 100644
--- a/networking/udhcp/dhcpc.c
+++ b/networking/udhcp/dhcpc.c
@@ -1504,19 +1504,19 @@ int udhcpc_main(int argc UNUSED_PARAM, char **argv)
 				}
  leasefail:
 				udhcp_run_script(NULL, "leasefail");
+				if (opt & OPT_n) { /* abort if no lease */
+					bb_error_msg("no lease, failing");
+					retval = 1;
+					goto ret;
+				}
 #if BB_MMU /* -b is not supported on NOMMU */
 				if (opt & OPT_b) { /* background if no lease */
 					bb_error_msg("no lease, forking to background");
 					client_background();
 					/* do not background again! */
 					opt = ((opt & ~OPT_b) | OPT_f);
-				} else
-#endif
-				if (opt & OPT_n) { /* abort if no lease */
-					bb_error_msg("no lease, failing");
-					retval = 1;
-					goto ret;
 				}
+#endif
 				/* wait before trying again */
 				timeout = tryagain_timeout;
 				packet_num = 0;