From owner-freebsd-net@FreeBSD.ORG Fri Aug 17 15:54:20 2012 Return-Path: Delivered-To: freebsd-net@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 500561065686 for ; Fri, 17 Aug 2012 15:54:20 +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 24CE28FC15 for ; Fri, 17 Aug 2012 15:54:20 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id 5ECF1B922; Fri, 17 Aug 2012 11:54:19 -0400 (EDT) From: John Baldwin To: freebsd-net@freebsd.org Date: Fri, 17 Aug 2012 11:48:17 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <4FFF3683.7020107@rawbw.com> <500066F4.2030102@rawbw.com> <20120815003151.GF33399@server.rulingia.com> In-Reply-To: <20120815003151.GF33399@server.rulingia.com> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-15" Content-Transfer-Encoding: 7bit Message-Id: <201208171148.17427.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Fri, 17 Aug 2012 11:54:19 -0400 (EDT) Cc: Yuri , Peter Jeremy Subject: Re: System doesn't detect unplugged network cable and doesn't set interface up properly with DHCP X-BeenThere: freebsd-net@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Networking and TCP/IP with FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 17 Aug 2012 15:54:20 -0000 On Tuesday, August 14, 2012 8:31:51 pm Peter Jeremy wrote: > On 2012-Jul-13 11:20:36 -0700, Yuri wrote: > >On 07/13/2012 02:48, Peter Jeremy wrote: > >> This is a bug in dhclient - see PR bin/166656, which includes a fix. > > > >I think this PR addresses part of the problem: dhclient doesn't exit when the link goes down. > >But even if it exits, it leaves the IP address that it has set, which is wrong. This IP address survives through the next DHCP setup process and ends up being the second IP address. > >Should be very easy to on exit remove any IP address that was set during dhclient process lifetime. > > I agree that it _should_ be easy to remove the existing address and the > existing patch in that PR should already do that. Unfortunately, > there seems to be another issue in dhclient that means that it isn't. Hmm, I think I see the issue. It doesn't export the existing lease info to the script when running the FAIL action. I just tested this change and it removed the old IP on my laptop when I tested it just now. Note that I kept the warning as "Interface foo is down" rather than "Link foo is down" since dhclient consistently uses that language elsewhere. Index: dhclient.c =================================================================== --- dhclient.c (revision 239333) +++ dhclient.c (working copy) @@ -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 (ip->client->active) + script_write_params("old_", ip->client->active); if (ifi->client->alias) script_write_params("alias_", ifi->client->alias); script_go(); -- John Baldwin