From owner-svn-src-all@FreeBSD.ORG Fri Aug 17 17:34:24 2012 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 13E46106566B; Fri, 17 Aug 2012 17:34:24 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigknife-pt.tunnel.tserv9.chi1.ipv6.he.net [IPv6:2001:470:1f10:75::2]) by mx1.freebsd.org (Postfix) with ESMTP id DB6AD8FC16; Fri, 17 Aug 2012 17:34:23 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 22DEDB91C; Fri, 17 Aug 2012 13:34:23 -0400 (EDT) From: John Baldwin To: Ian Lepore Date: Fri, 17 Aug 2012 13:31:10 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <201208171553.q7HFrhuf090457@svn.freebsd.org> <1345222934.27688.110.camel@revolution.hippie.lan> In-Reply-To: <1345222934.27688.110.camel@revolution.hippie.lan> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201208171331.10655.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 17 Aug 2012 13:34:23 -0400 (EDT) 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-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2012 17:34:24 -0000 On Friday, August 17, 2012 1:02:14 pm Ian Lepore wrote: > 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. Hmm, OpenBSD does check that, but they also seem to verify it via SIOCGMEDIA as well. Do we think this is as reliable? In the kernel we only seem to honor this if the NIC explicitly supports the capability: #define RT_LINK_IS_UP(ifp) (!((ifp)->if_capabilities & IFCAP_LINKSTATE) \ || (ifp)->if_link_state == LINK_STATE_UP) Also, I don't think routing info messages are all that common of an event are they? -- John Baldwin