Bug 98577 - [patch] dhclient(8): the link check by dhclient slows down booting on a laptop
Summary: [patch] dhclient(8): the link check by dhclient slows down booting on a laptop
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-06 06:30 UTC by Nick Hibma
Modified: 2018-01-03 05:16 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nick Hibma freebsd_committer 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