diff --git a/ndhc.h b/ndhc.h index 613c545..68baeae 100644 --- a/ndhc.h +++ b/ndhc.h @@ -29,7 +29,7 @@ struct client_state_t { int listenFd, arpFd, nlFd, rfkillFd; int server_arp_sent, router_arp_sent; uint32_t nlPortId; - unsigned int num_dhcp_requests, num_dhcp_renews; + unsigned int num_dhcp_requests; uint32_t clientAddr, serverAddr, srcAddr, routerAddr; uint32_t clientSubnet; uint32_t lease, xid; diff --git a/state.c b/state.c index eb9f338..6e56f48 100644 --- a/state.c +++ b/state.c @@ -18,8 +18,6 @@ #include "netlink.h" #include "coroutine.h" -#define IGNORED_RENEWS_BEFORE_REBIND 3 - #define SEL_SUCCESS 0 #define SEL_FAIL -1 @@ -56,7 +54,6 @@ static void reinit_shared_deconfig(struct client_state_t *cs) advance_xid(cs); cs->clientAddr = 0; cs->num_dhcp_requests = 0; - cs->num_dhcp_renews = 0; cs->server_arp_sent = 0; cs->router_arp_sent = 0; cs->server_arp_state = ARP_QUERY; @@ -129,7 +126,7 @@ static int renewing_timeout(struct client_state_t *cs, long long nowts) { long long rbt = cs->leaseStartTime + cs->rebindTime * 1000; - if (nowts >= rbt || cs->num_dhcp_renews >= IGNORED_RENEWS_BEFORE_REBIND) + if (nowts >= rbt) return rebinding_timeout(cs, nowts); start_dhcp_listen(cs); if (send_renew(cs) < 0) { @@ -138,7 +135,6 @@ static int renewing_timeout(struct client_state_t *cs, return BTO_HARDFAIL; } cs->sent_renew_or_rebind = true; - ++cs->num_dhcp_renews; long long ts0 = nowts + (50 + nk_random_u32(&cs->rnd_state) % 20) * 1000; cs->dhcp_wake_ts = ts0 < rbt ? ts0 : rbt; return BTO_WAIT; @@ -214,7 +210,6 @@ static int extend_packet(struct client_state_t *cs, if (!validate_acknak(cs, packet, "DHCPACK", srcaddr)) return ANP_IGNORE; cs->sent_renew_or_rebind = false; - cs->num_dhcp_renews = 0; get_leasetime(cs, packet); // Did we receive a lease with a different IP than we had before? @@ -240,7 +235,6 @@ static int extend_packet(struct client_state_t *cs, if (!validate_acknak(cs, packet, "DHCPNAK", srcaddr)) return ANP_IGNORE; cs->sent_renew_or_rebind = false; - cs->num_dhcp_renews = 0; log_line("%s: Our request was rejected. Searching for a new lease...\n", client_config.interface); reinit_selecting(cs, 3000);