diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-12-10 01:05:14 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2014-12-10 01:05:14 +0000 |
commit | d7c702156bfce1dde4eb314f56e08769dc8f7aea (patch) | |
tree | b2a1a6dca04c7c0c85cbe893a06295d9ec547c73 /sbin | |
parent | 4057a0f832f3a46a70e872855622beb01a748644 (diff) |
The consensus is that RTM_IFINFO messages do not always carry the
latest information. So back off to using interface_status() to
directly query the interface when link status is in question. Partly
from Nathanael Rensen's original diff.
Also, while waiting for initial link, keep checking every second
rather than backing off to checking every (default) 60 seconds after
(default) 10 seconds.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/dhclient/dhclient.c | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/sbin/dhclient/dhclient.c b/sbin/dhclient/dhclient.c index fb9f9450ae8..6cf52bb7f83 100644 --- a/sbin/dhclient/dhclient.c +++ b/sbin/dhclient/dhclient.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dhclient.c,v 1.344 2014/12/09 02:27:54 krw Exp $ */ +/* $OpenBSD: dhclient.c,v 1.345 2014/12/10 01:05:13 krw Exp $ */ /* * Copyright 2004 Henning Brauer <henning@openbsd.org> @@ -338,10 +338,7 @@ routehandler(void) } } - linkstat = - LINK_STATE_IS_UP(ifm->ifm_data.ifi_link_state) ? 1 : 0; - linkstat = linkstat || (ifi->flags & IFI_NOMEDIA); - linkstat = linkstat && (ifm->ifm_flags & IFF_UP); + linkstat = interface_status(ifi->name); if (linkstat != ifi->linkstat) { #ifdef DEBUG debug("link state %s -> %s", @@ -353,9 +350,10 @@ routehandler(void) if (client->state == S_PREBOOT) { state_preboot(); get_hw_address(); + } else { + client->state = S_REBOOTING; + state_reboot(); } - client->state = S_REBOOTING; - set_timeout_interval(1, state_reboot); } else if (strlen(path_option_db)) { /* Let monitoring programs see link loss. */ write_file(path_option_db, @@ -641,6 +639,8 @@ state_preboot(void) interval = (int)(cur_time - client->first_sending); + ifi->linkstat = interface_status(ifi->name); + if (log_perror && interval > 3) { if (!preamble && !ifi->linkstat) { fprintf(stderr, "%s: no link ....", ifi->name); @@ -657,13 +657,14 @@ state_preboot(void) } } - if (!ifi->linkstat) { - if (interval > config->link_timeout) { + if (ifi->linkstat) { + client->state = S_REBOOTING; + set_timeout_interval(1, state_reboot); + } else { + if (interval > config->link_timeout) go_daemon(); - set_timeout_interval(config->retry_interval, - state_preboot); - } else - set_timeout_interval(1, state_preboot); + client->state = S_PREBOOT; + set_timeout_interval(1, state_preboot); } } |