From owner-freebsd-current@FreeBSD.ORG Wed Aug 22 20:06:32 2012 Return-Path: Delivered-To: current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9A865106566B; Wed, 22 Aug 2012 20:06:32 +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 57A438FC25; Wed, 22 Aug 2012 20:06:32 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id AA632B9A0; Wed, 22 Aug 2012 16:06:31 -0400 (EDT) From: John Baldwin To: freebsd-current@freebsd.org Date: Wed, 22 Aug 2012 15:35:01 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p17; KDE/4.5.5; amd64; ; ) References: <20120821095527.GA33206@hell.ukr.net> <20120822171253.GB3300@michelle.cdnetworks.com> <20120822172822.GA52909@hell.ukr.net> In-Reply-To: <20120822172822.GA52909@hell.ukr.net> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201208221535.01598.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Wed, 22 Aug 2012 16:06:31 -0400 (EDT) Cc: YongHyeon PYUN , Vitalij Satanivskij , Peter Jeremy , current@freebsd.org Subject: Re: dhclient cause up/down cycle after 239356 ? 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: Wed, 22 Aug 2012 20:06:32 -0000 On Wednesday, August 22, 2012 1:28:22 pm Vitalij Satanivskij wrote: > ok next round :) > > dhclient updated to Revision 239564 > > with fxp : > > Aug 22 20:06:48 home kernel: fxp0: link state changed to DOWN > Aug 22 20:06:48 home dhclient: New Subnet Mask (fxp0): 255.255.255.0 > Aug 22 20:06:48 home dhclient: New Broadcast Address (fxp0): xx.xx.xx.255 > Aug 22 20:06:48 home dhclient: New Routers (fxp0): xx.xx.xx.1 > Aug 22 20:06:50 home kernel: fxp0: link state changed to UP > Aug 22 20:06:53 home dhclient: New IP Address (fxp0): xx.xx.xx.xx > Aug 22 20:06:53 home kernel: fxp0: link state changed to DOWN > Aug 22 20:06:53 home dhclient: New Subnet Mask (fxp0): 255.255.255.0 > Aug 22 20:06:53 home dhclient: New Broadcast Address (fxp0): xx.xx.xx.255 > Aug 22 20:06:53 home dhclient: New Routers (fxp0): xx.xx.xx.xx > Aug 22 20:06:55 home kernel: fxp0: link state changed to UP > Aug 22 20:07:01 home dhclient: New IP Address (fxp0): xx.xx.xx.xx > Aug 22 20:07:01 home kernel: fxp0: link state changed to DOWN > Aug 22 20:07:01 home dhclient: New Subnet Mask (fxp0): 255.255.255.0 > Aug 22 20:07:01 home dhclient: New Broadcast Address (fxp0): xx.xx.xx.255 > Aug 22 20:07:01 home dhclient: New Routers (fxp0): xx.xx.xx.xx > Aug 22 20:07:03 home kernel: fxp0: link state changed to UP > Aug 22 20:07:07 home dhclient: New IP Address (fxp0): xx.xx.xx.xx > Aug 22 20:07:07 home kernel: fxp0: link state changed to DOWN > Aug 22 20:07:07 home dhclient: New Subnet Mask (fxp0): 255.255.255.0 > Aug 22 20:07:07 home dhclient: New Broadcast Address (fxp0): xx.xx.xx.255 > Aug 22 20:07:07 home dhclient: New Routers (fxp0): xx.xx.xx.xx > Aug 22 20:07:09 home kernel: fxp0: link state changed to UP > Aug 22 20:07:13 home dhclient: New IP Address (fxp0): xx.xx.xx.xx > Aug 22 20:07:13 home kernel: fxp0: link state changed to DOWN > Aug 22 20:07:13 home dhclient: New Subnet Mask (fxp0): 255.255.255.0 > Aug 22 20:07:13 home dhclient: New Broadcast Address (fxp0): xx.xx.xx.255 > Aug 22 20:07:13 home dhclient: New Routers (fxp0): xx.xx.xx.xx > Aug 22 20:07:15 home kernel: fxp0: link state changed to UP Hmm. Perhaps we could use a debouncer to ignore "short" link flaps? Kind of gross (and OpenBSD doesn't do this). For now this change basically ignores link up events if they occur with 5 seconds of the link down event. The 5 is hardcoded which is kind of yuck. Index: dhcpd.h =================================================================== --- dhcpd.h (revision 239564) +++ dhcpd.h (working copy) @@ -209,6 +209,7 @@ int dead; u_int16_t index; int linkstat; + time_t linktime; }; struct timeout { Index: dhclient.c =================================================================== --- dhclient.c (revision 239564) +++ dhclient.c (working copy) @@ -285,8 +285,14 @@ ifi->linkstat ? "up" : "down", linkstat ? "up" : "down"); ifi->linkstat = linkstat; - if (linkstat) + + /* + * XXX: Hardcoded 5 second grace window on + * link flaps. + */ + if (linkstat && (cur_time - ifi->linktime) >= 5) state_reboot(ifi); + ifi->linktime = cur_time; } break; case RTM_IFANNOUNCE: @@ -441,6 +447,7 @@ fprintf(stderr, " got link\n"); } ifi->linkstat = 1; + ifi->linktime = cur_time; if ((nullfd = open(_PATH_DEVNULL, O_RDWR, 0)) == -1) error("cannot open %s: %m", _PATH_DEVNULL); -- John Baldwin