Date: Thu, 5 Apr 2012 11:47:47 +1000 (EST) From: Peter Jeremy <peterjeremy@acm.org> To: FreeBSD-gnats-submit@FreeBSD.org Subject: bin/166656: [patch] dhclient(8) doesn't exit os link down Message-ID: <201204050147.q351llg8075598@server.vk2pj.dyndns.org> Resent-Message-ID: <201204050150.q351o1L8006254@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>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 >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Thu Apr 05 01:50:00 UTC 2012 >Closed-Date: >Last-Modified: >Originator: Peter Jeremy >Release: FreeBSD 8.2-STABLE amd64 >Organization: >Environment: System: FreeBSD pjdesk.au.alcatel-lucent.com 8.2-STABLE FreeBSD 8.2-STABLE #9: Fri Feb 3 07:57:14 EST 2012 root@pjdesk.au.alcatel-lucent.com:/var/obj/usr/src/sys/pjdesk amd64 also tested on: FreeBSD C2B0004103.au.alcatel-lucent.com 10.0-CURRENT FreeBSD 10.0-CURRENT #20 r232545M: Tue Mar 6 06:58:47 EST 2012 root@C2B0004103.au.alcatel-lucent.com:/usr/obj/usr/src/sys/pjdesk amd64 >Description: /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). >How-To-Repeat: Start dhclient and verify a valid lease is obtained. Unplug network cable and verify that dhclient did not exit. >Fix: 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 @@ ifi->name); goto die; } + if (!interface_link_status(ifi->name)) { + warning("Link %s is down, dhclient exiting", + ifi->name); + goto die; + } break; case RTM_IFANNOUNCE: ifan = (struct if_announcemsghdr *)rtm; >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204050147.q351llg8075598>