Bug 98577

Summary: [patch] dhclient(8): the link check by dhclient slows down booting on a laptop
Product: Base System Reporter: Nick Hibma <n_hibma>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Open ---    
Severity: Affects Only Me Keywords: patch
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Nick Hibma freebsd_committer freebsd_triage 2006-06-06 06:30:17 UTC
Dhclient is nowadays waiting for the link to come up before continuing. That
makes the -b (become a daemon immediately) less useful. Ctrl-C at that point
makes the whole rc.d script fail.

Fix: 

Move the checking for link (/usr/src/sbin/dhclient/dhclient.c) after the first
go_daemon case. Problems might be chroot and fork_privchild. Untested.
How-To-Repeat: 
Set
	background_dhclient="YES"
in rc.conf, remove ethernet plug (I assume that it is a rl0 iface) and run
	/etc/rc.d/netif restart rl0
Notice the long wait.
Comment 1 Jan Rochel 2007-05-25 13:27:28 UTC
Currently, the "no link"-timeout is wired-in (10 seconds) in line 364.
It's probably the best solution to add a linkdown-timeout-option to
dhclient.conf where the timeout can be set (as all the other timeouts).
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2008-01-28 09:16:03 UTC
State Changed
From-To: open->suspended

Mark suspended awaiting patches.
Comment 3 Nick Hibma 2008-10-29 18:00:46 UTC
I actually did a patch quite some time ago. Below a block of code is simply 
moved from one spot to another.

Index: dhclient.c
===================================================================
--- dhclient.c	(revision 184060)
+++ dhclient.c	(working copy)
@@ -371,22 +371,6 @@
 
 	read_client_conf();
 
-	if (!interface_link_status(ifi->name)) {
-		fprintf(stderr, "%s: no link ...", ifi->name);
-		fflush(stderr);
-		sleep(1);
-		while (!interface_link_status(ifi->name)) {
-			fprintf(stderr, ".");
-			fflush(stderr);
-			if (++i > 10) {
-				fprintf(stderr, " giving up\n");
-				exit(1);
-			}
-			sleep(1);
-		}
-		fprintf(stderr, " got link\n");
-	}
-
 	if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1)
 		error("cannot open %s: %m", _PATH_DEVNULL);
 
@@ -438,6 +422,22 @@
 	if (immediate_daemon)
 		go_daemon();
 
+	if (!interface_link_status(ifi->name)) {
+		fprintf(stderr, "%s: no link ...", ifi->name);
+		fflush(stderr);
+		sleep(1);
+		while (!interface_link_status(ifi->name)) {
+			fprintf(stderr, ".");
+			fflush(stderr);
+			if (++i > 10) {
+				fprintf(stderr, " giving up\n");
+				exit(1);
+			}
+			sleep(1);
+		}
+		fprintf(stderr, " got link\n");
+	}
+
 	ifi->client->state = S_INIT;
 	state_reboot(ifi);
Comment 4 Mark Linimon freebsd_committer freebsd_triage 2008-10-29 18:18:19 UTC
State Changed
From-To: suspended->open

Patch received.
Comment 5 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:50 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:35:53 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>