From owner-freebsd-current@FreeBSD.ORG Tue Aug 21 23:14:07 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 896DE106566B; Tue, 21 Aug 2012 23:14:07 +0000 (UTC) (envelope-from slw@zxy.spb.ru) Received: from zxy.spb.ru (zxy.spb.ru [195.70.199.98]) by mx1.freebsd.org (Postfix) with ESMTP id 1B4958FC0C; Tue, 21 Aug 2012 23:14:06 +0000 (UTC) Received: from slw by zxy.spb.ru with local (Exim 4.69 (FreeBSD)) (envelope-from ) id 1T3xgU-0001hK-50; Wed, 22 Aug 2012 03:16:30 +0400 Date: Wed, 22 Aug 2012 03:16:30 +0400 From: Slawa Olhovchenkov To: John Baldwin Message-ID: <20120821231630.GF88729@zxy.spb.ru> References: <20120821095527.GA33206@hell.ukr.net> <1959717636.20120821155308@serebryakov.spb.ru> <201208210934.31484.jhb@freebsd.org> <201208211725.23381.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <201208211725.23381.jhb@freebsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: slw@zxy.spb.ru X-SA-Exim-Scanned: No (on zxy.spb.ru); SAEximRunCond expanded to false Cc: Garrett Cooper , freebsd-current@freebsd.org, lev@freebsd.org, current@freebsd.org, Peter Jeremy Subject: Re: r239356: does it mean, that synchronous dhcp and dhcplcinet with disabled devd gone? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 21 Aug 2012 23:14:07 -0000 On Tue, Aug 21, 2012 at 05:25:23PM -0400, John Baldwin wrote: > On Tuesday, August 21, 2012 9:34:31 am John Baldwin wrote: > > On Tuesday, August 21, 2012 7:53:08 am Lev Serebryakov wrote: > > > Hello, Garrett. > > > You wrote 21 августа 2012 г., 15:40:35: > > > > > > GC>> Try reverting r239356 -- if that works, then please let jhb@ know. > > > LS> I'm confused by this commit, because it seems (from comment alone), > > > LS> that dhclient will not work without devd anymore (with "synchronous > > > LS> dhcp" option in rc.conf). > > > LS> Am I right? > > > And if I'm right about understanding what this change does, it is > > > POLA violation for sure. Both consequences: unable to use dhcclient > > > without devd (user will need to restart it by hands after each cable > > > unplugging event) and removing IP address from interface on cable > > > unplugging or other interface down event but before lease is expired. > > > > > > If I'm right in understanding this commit, I vote to back it out and > > > find better solution, may be, two new options: one to remove IP and > > > one to exit on interface down. And default behavior should be OLD > > > ONE about IP address in any case and OLD ONE about exit in case when > > > dhclient isn't started by devd, but by rc scripts directly. > > > > Humm. devd is the more common case, and we explicitly don't use devd to start > > dhclient on boot even when devd is enabled (so out of the box dhcp would first > > be started by rc, but would be restarted by devd). > > > > Another option is to rework dhclient to work like it does on OpenBSD where it > > renews its lease if the link bounces, but to not exit when the link goes down. > > That case would fix the currently broken case that you unplug your cable, take > > your laptop over to another network (e.g. take it home if suspend/resume > > works), then plug it back in and are still stuck with your old IP. > > Ok, this is what I came up with, somewhat loosely based on OpenBSD's dhclient. > I tested that it survives the following: > > - Unplugging/replugging does not kill an existing ssh session > - Using ifconfig down/up does not kill an existing ssh session > - Plugging into a different network does cause dhclient to negotiate > a new lease on the new network Assign address on interface manualy cause exiting dhcpclient? > I've removed the bits to clear the old configuration if dhclient exits due to > 'ifconfig down', and dhclient no longer exits on link down, but instead tracks > the link state and enters the 'reboot' state when the link goes up. > > Index: dhcpd.h > =================================================================== > --- dhcpd.h (revision 239498) > +++ dhcpd.h (working copy) > @@ -208,6 +208,7 @@ > int errors; > int dead; > u_int16_t index; > + int linkstat; > }; > > struct timeout { > Index: dhclient.c > =================================================================== > --- dhclient.c (revision 239498) > +++ dhclient.c (working copy) > @@ -218,6 +218,7 @@ > struct sockaddr *sa; > struct iaddr a; > ssize_t n; > + int linkstat; > > n = read(routefd, &msg, sizeof(msg)); > rtm = (struct rt_msghdr *)msg; > @@ -278,10 +279,14 @@ > ifi->name); > goto die; > } > - if (!interface_link_status(ifi->name)) { > - warning("Interface %s is down, dhclient exiting", > - ifi->name); > - goto die; > + linkstat = interface_link_status(ifi->name); > + if (linkstat != ifi->linkstat) { > + debug("%s link state %s -> %s", ifi->name, > + ifi->linkstat ? "up" : "down", > + linkstat ? "up" : "down"); > + ifi->linkstat = linkstat; > + if (linkstat) > + state_reboot(ifi); > } > break; > case RTM_IFANNOUNCE: > @@ -321,8 +326,6 @@ > > 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(); > @@ -437,6 +440,7 @@ > } > fprintf(stderr, " got link\n"); > } > + ifi->linkstat = 1; > > if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) > error("cannot open %s: %m", _PATH_DEVNULL); > > -- > John Baldwin > _______________________________________________ > freebsd-current@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-current > To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"