Re: dhclient cause up/down cycle after 239356 ?

From: Adrian Chadd <adrian_at_freebsd.org>
Date: Wed, 22 Aug 2012 17:52:40 -0700
Ew. Be careful. Your admin may decide to change the VLAN you're on
(for example.) You definitely want to renegotiate your link state
then.



Adrian

On 22 August 2012 12:35, John Baldwin <jhb_at_freebsd.org> wrote:
> 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)
> _at__at_ -209,6 +209,7 _at__at_
>         int                      dead;
>         u_int16_t                index;
>         int                      linkstat;
> +       time_t                   linktime;
>  };
>
>  struct timeout {
> Index: dhclient.c
> ===================================================================
> --- dhclient.c  (revision 239564)
> +++ dhclient.c  (working copy)
> _at__at_ -285,8 +285,14 _at__at_
>                             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:
> _at__at_ -441,6 +447,7 _at__at_
>                 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
> _______________________________________________
> freebsd-current_at_freebsd.org mailing list
> http://lists.freebsd.org/mailman/listinfo/freebsd-current
> To unsubscribe, send any mail to "freebsd-current-unsubscribe_at_freebsd.org"
Received on Wed Aug 22 2012 - 22:52:42 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:29 UTC