Handle hardware link state loss and restoration on networks that lack a

default gw properly.
This commit is contained in:
Nicholas J. Kain 2011-07-06 11:32:22 -04:00
parent ad5c5d6803
commit 080fefaea0
2 changed files with 13 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/* packet.h - send and react to DHCP message packets /* packet.h - send and react to DHCP message packets
* Time-stamp: <2011-06-11 11:12:26 njk> * Time-stamp: <2011-07-06 11:17:15 njk>
* *
* (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com> * (c) 2004-2011 Nicholas J. Kain <njkain at gmail dot com>
* (c) 2001 Russ Dill <Russ.Dill@asu.edu> * (c) 2001 Russ Dill <Russ.Dill@asu.edu>

View File

@ -292,18 +292,20 @@ void ifup_action(struct client_state_t *cs)
{ {
// If we have a lease, check to see if our gateway is still valid via ARP. // If we have a lease, check to see if our gateway is still valid via ARP.
// If it fails, state -> SELECTING. // If it fails, state -> SELECTING.
if (cs->dhcpState == DS_BOUND || cs->dhcpState == DS_RENEWING || if (cs->routerAddr && (cs->dhcpState == DS_BOUND ||
cs->dhcpState == DS_REBINDING) { cs->dhcpState == DS_RENEWING ||
if (arp_gw_check(cs) == -1) cs->dhcpState == DS_REBINDING)) {
log_warning("nl: arp_gw_check could not make arp socket, assuming lease is still OK"); if (arp_gw_check(cs) != -1) {
else
log_line("nl: interface back, revalidating lease"); log_line("nl: interface back, revalidating lease");
// If we don't have a lease, state -> SELECTING. return;
} else if (cs->dhcpState != DS_SELECTING) { } else
log_warning("nl: arp_gw_check could not make arp socket");
}
if (cs->dhcpState == DS_SELECTING)
return;
log_line("nl: %s back, querying for new lease", client_config.interface); log_line("nl: %s back, querying for new lease", client_config.interface);
reinit_selecting(cs, 0); reinit_selecting(cs, 0);
} }
}
void ifdown_action(struct client_state_t *cs) void ifdown_action(struct client_state_t *cs)
{ {