From d7c702156bfce1dde4eb314f56e08769dc8f7aea Mon Sep 17 00:00:00 2001 From: Kenneth R Westerback Date: Wed, 10 Dec 2014 01:05:14 +0000 Subject: 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. --- sbin/dhclient/dhclient.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'sbin') 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 @@ -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); } } -- cgit v1.2.3