From 1e2698b4027f306748d1c2e5b835981e44aa2423 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Sun, 26 Jun 2011 18:21:40 -0400 Subject: [PATCH] If a lease is negotiated, then expires after renewal attempts, don't time out and exit the daemon as would be desirable at startup. Just keep trying. --- ndhc/arp.c | 1 + ndhc/config.h | 1 + ndhc/ndhc.c | 1 + ndhc/timeout.c | 14 ++++++++------ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/ndhc/arp.c b/ndhc/arp.c index 6523681..69d9f64 100644 --- a/ndhc/arp.c +++ b/ndhc/arp.c @@ -218,6 +218,7 @@ void arp_success(struct client_state_t *cs) inet_ntoa(temp_addr), cs->lease); cs->requestedIP = arp_dhcp_packet.yiaddr; cs->dhcpState = DS_BOUND; + cs->init = 0; ifchange(&arp_dhcp_packet, ((cs->arpPrevState == DS_RENEWING || cs->arpPrevState == DS_REBINDING) diff --git a/ndhc/config.h b/ndhc/config.h index 0a664f1..cc19d2b 100644 --- a/ndhc/config.h +++ b/ndhc/config.h @@ -65,6 +65,7 @@ struct client_state_t { uint32_t requestedIP, serverAddr, routerAddr; uint32_t lease, t1, t2, xid; uint8_t routerArp[6]; + uint8_t init; }; struct client_config_t { diff --git a/ndhc/ndhc.c b/ndhc/ndhc.c index b6a55fd..f9485bb 100644 --- a/ndhc/ndhc.c +++ b/ndhc/ndhc.c @@ -67,6 +67,7 @@ struct client_state_t cs = { .packetNum = 0, .xid = 0, .timeout = 0, + .init = 1, .oldTimeout = 0, .leaseStartTime = 0, .requestedIP = 0, diff --git a/ndhc/timeout.c b/ndhc/timeout.c index 401f039..00785ae 100644 --- a/ndhc/timeout.c +++ b/ndhc/timeout.c @@ -39,12 +39,14 @@ static void init_selecting_timeout(struct client_state_t *cs) cs->timeout = DELAY_SEC * (cs->packetNum + 1) * 1000; cs->packetNum++; } else { - if (client_config.background_if_no_lease) { - log_line("No lease, going to background."); - background(cs); - } else if (client_config.abort_if_no_lease) { - log_line("No lease, failing."); - exit(EXIT_FAILURE); + if (cs->init) { + if (client_config.background_if_no_lease) { + log_line("No lease, going to background."); + background(cs); + } else if (client_config.abort_if_no_lease) { + log_line("No lease, failing."); + exit(EXIT_FAILURE); + } } /* wait to try again */ cs->packetNum = 0;