diff --git a/ndhc/dhcp.h b/ndhc/dhcp.h index 415cd67..b43f560 100644 --- a/ndhc/dhcp.h +++ b/ndhc/dhcp.h @@ -1,5 +1,5 @@ /* 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 * (c) 2001 Russ Dill @@ -51,7 +51,7 @@ struct dhcpmsg { uint16_t secs; // Filled by client: seconds since client began address // aquisition or renewal process. uint16_t flags; // DHCP flags - uint32_t ciaddr; // Client IP: only filled in if client is inBOUND, RENEW, + uint32_t ciaddr; // Client IP: only filled in if client is in BOUND, RENEW, // or REBINDING and can reply to ARP requests uint32_t yiaddr; // 'your' (client) IP address uint32_t siaddr; // IP address of next server to use in bootstrap; returned diff --git a/ndhc/state.c b/ndhc/state.c index da162dd..d7f77a9 100644 --- a/ndhc/state.c +++ b/ndhc/state.c @@ -292,17 +292,19 @@ 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 it fails, state -> SELECTING. - if (cs->dhcpState == DS_BOUND || cs->dhcpState == DS_RENEWING || - cs->dhcpState == DS_REBINDING) { - if (arp_gw_check(cs) == -1) - log_warning("nl: arp_gw_check could not make arp socket, assuming lease is still OK"); - else + if (cs->routerAddr && (cs->dhcpState == DS_BOUND || + cs->dhcpState == DS_RENEWING || + cs->dhcpState == DS_REBINDING)) { + if (arp_gw_check(cs) != -1) { log_line("nl: interface back, revalidating lease"); - // If we don't have a lease, state -> SELECTING. - } else if (cs->dhcpState != DS_SELECTING) { - log_line("nl: %s back, querying for new lease", client_config.interface); - reinit_selecting(cs, 0); + return; + } 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); + reinit_selecting(cs, 0); } void ifdown_action(struct client_state_t *cs)