From owner-svn-src-head@FreeBSD.ORG Fri Aug 17 17:02:17 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A978A106564A for ; Fri, 17 Aug 2012 17:02:17 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from qmta15.emeryville.ca.mail.comcast.net (qmta15.emeryville.ca.mail.comcast.net [76.96.27.228]) by mx1.freebsd.org (Postfix) with ESMTP id 858518FC12 for ; Fri, 17 Aug 2012 17:02:17 +0000 (UTC) Received: from omta07.emeryville.ca.mail.comcast.net ([76.96.30.59]) by qmta15.emeryville.ca.mail.comcast.net with comcast id nrba1j0091GXsucAFt2H3M; Fri, 17 Aug 2012 17:02:17 +0000 Received: from damnhippie.dyndns.org ([24.8.232.202]) by omta07.emeryville.ca.mail.comcast.net with comcast id nt2G1j0014NgCEG8Ut2GAd; Fri, 17 Aug 2012 17:02:17 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id q7HH2EOB018230; Fri, 17 Aug 2012 11:02:14 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) From: Ian Lepore To: John Baldwin In-Reply-To: <201208171553.q7HFrhuf090457@svn.freebsd.org> References: <201208171553.q7HFrhuf090457@svn.freebsd.org> Content-Type: multipart/mixed; boundary="=-0VwgxFO6omcOAMrSi85E" Date: Fri, 17 Aug 2012 11:02:14 -0600 Message-ID: <1345222934.27688.110.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r239356 - head/sbin/dhclient X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2012 17:02:17 -0000 --=-0VwgxFO6omcOAMrSi85E Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On Fri, 2012-08-17 at 15:53 +0000, John Baldwin wrote: > Author: jhb > Date: Fri Aug 17 15:53:43 2012 > New Revision: 239356 > URL: http://svn.freebsd.org/changeset/base/239356 > > Log: > Fix dhclient to properly exit and teardown the configured lease when > link is lost. devd will start a new dhclient instance when link is > restored. > > PR: bin/166656 > Submitted by: Peter Jeremy (mostly) > Reviewed by: brooks (earlier version from Peter) > MFC after: 1 month > > Modified: > head/sbin/dhclient/dhclient.c > > Modified: head/sbin/dhclient/dhclient.c > ============================================================================== > --- head/sbin/dhclient/dhclient.c Fri Aug 17 14:22:56 2012 (r239355) > +++ head/sbin/dhclient/dhclient.c Fri Aug 17 15:53:43 2012 (r239356) > @@ -278,6 +278,11 @@ routehandler(struct protocol *p) > ifi->name); > goto die; > } > + if (!interface_link_status(ifi->name)) { > + warning("Interface %s is down, dhclient exiting", > + ifi->name); > + goto die; > + } > break; > case RTM_IFANNOUNCE: > ifan = (struct if_announcemsghdr *)rtm; > @@ -316,6 +321,8 @@ routehandler(struct protocol *p) > > die: > script_init("FAIL", NULL); > + if (ifi->client->active) > + script_write_params("old_", ifi->client->active); > if (ifi->client->alias) > script_write_params("alias_", ifi->client->alias); > script_go(); I think the attached patch should give the same result without needing to create/destroy a socket to check the link status every time a routing info message arrives. I've actually had this patch in my head for several years, I just hadn't gotten around to submitting it yet. -- Ian --=-0VwgxFO6omcOAMrSi85E Content-Description: Content-Disposition: inline; filename="dhclient.diff" Content-Type: text/x-patch; name="dhclient.diff"; charset="us-ascii" Content-Transfer-Encoding: 7bit diff -r 6cb112d8486e sbin/dhclient/dhclient.c --- a/sbin/dhclient/dhclient.c Mon Aug 13 15:06:09 2012 -0600 +++ b/sbin/dhclient/dhclient.c Fri Aug 17 10:48:02 2012 -0600 @@ -273,7 +273,7 @@ routehandler(struct protocol *p) ifm = (struct if_msghdr *)rtm; if (ifm->ifm_index != ifi->index) break; - if ((rtm->rtm_flags & RTF_UP) == 0) { + if (ifm->ifm_data.ifi_link_state != LINK_STATE_UP) { warning("Interface %s is down, dhclient exiting", ifi->name); goto die; --=-0VwgxFO6omcOAMrSi85E--