bin/166656: [patch] dhclient(8) doesn't exit os link down

Peter Jeremy peterjeremy at
Thu Apr 5 01:50:13 UTC 2012

>Number:         166656
>Category:       bin
>Synopsis:       [patch] dhclient(8) doesn't exit os link down
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Apr 05 01:50:00 UTC 2012
>Originator:     Peter Jeremy
>Release:        FreeBSD 8.2-STABLE amd64
System: FreeBSD 8.2-STABLE FreeBSD 8.2-STABLE #9: Fri Feb  3 07:57:14 EST 2012     root at  amd64

also tested on:
FreeBSD 10.0-CURRENT FreeBSD 10.0-CURRENT #20 r232545M: Tue Mar  6 06:58:47 EST 2012     root at  amd64


	/etc/devd.conf includes a rule to start dhclient when an Ethernet or
	802.11 interface reports "link up", with a comment: "No link down rule
	exists because dhclient automatically exits when the link goes down."
	IMHO, this is the desired behaviour, unfortunately it's not the way
	dhclient actually behaves.  In my experience, dhclient will exit when
	the interface goes down but ignores link status changes.
	Looking at the source, it seems to exit only when there's no usable
	route (by monitoring RTF_UP).
	dhclient does monitor the link status using SIOCGIFMEDIA but only at
	startup (it will exit if the link doesn't come up within 10s of
	dhclient starting) and during DHCP exchanges (if the link goes down
	when it's expecting a DHCP response then it exits).


	Start dhclient and verify a valid lease is obtained.
	Unplug network cable and verify that dhclient did not exit.	

	dhclient receives RTM_IFINFO messages on link change.  Currently
	the code just monitors RTF_UP on link change.  The attached patch
	adds a SIOCGIFMEDIA check when a RTM_IFINFO messages is received
	and exits if the link is now down.

Index: dhclient.c
--- dhclient.c	(revision 232545)
+++ dhclient.c	(working copy)
@@ -278,6 +278,11 @@
 			goto die;
+		if (!interface_link_status(ifi->name)) {
+			warning("Link %s is down, dhclient exiting",
+				ifi->name);
+			goto die;
+		}
 		ifan = (struct if_announcemsghdr *)rtm;


More information about the freebsd-bugs mailing list