From 8beb1d12d186e53e37c12ef94aa787f14479e031 Mon Sep 17 00:00:00 2001 From: "Nicholas J. Kain" Date: Wed, 6 Jul 2011 11:41:49 -0400 Subject: [PATCH] Fix a regression: if renewing or rebinding a dhcp lease that matches our previous client ip, make sure to stop listening for dhcp packets, set the proper timeout interval, and make sure we're in AS_DEFENSE state. --- ndhc/arp.c | 7 ++++++- ndhc/arp.h | 3 ++- ndhc/state.c | 5 +++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ndhc/arp.c b/ndhc/arp.c index 2018ffc..f0ded3a 100644 --- a/ndhc/arp.c +++ b/ndhc/arp.c @@ -1,5 +1,5 @@ /* arp.c - arp ping checking - * Time-stamp: <2011-07-06 09:18:58 njk> + * Time-stamp: <2011-07-06 11:39:23 njk> * * Copyright 2010-2011 Nicholas J. Kain * @@ -419,6 +419,11 @@ static int act_if_arp_gw_failed(struct client_state_t *cs) return 0; } +void arp_set_defense_mode(struct client_state_t *cs) +{ + arp_switch_state(cs, AS_DEFENSE); +} + void arp_success(struct client_state_t *cs) { cs->timeout = (cs->renewTime * 1000) - (curms() - cs->leaseStartTime); diff --git a/ndhc/arp.h b/ndhc/arp.h index 3c8d1ab..8328392 100644 --- a/ndhc/arp.h +++ b/ndhc/arp.h @@ -1,5 +1,5 @@ /* arp.h - functions to call the interface change daemon - * Time-stamp: <2011-07-05 15:54:33 njk> + * Time-stamp: <2011-07-06 11:39:42 njk> * * Copyright 2010-2011 Nicholas J. Kain * @@ -51,6 +51,7 @@ void arp_reset_send_stats(void); int arp_close_fd(struct client_state_t *cs); int arp_check(struct client_state_t *cs, struct dhcpmsg *packet); int arp_gw_check(struct client_state_t *cs); +void arp_set_defense_mode(struct client_state_t *cs); void arp_success(struct client_state_t *cs); void arp_retransmit(struct client_state_t *cs); void handle_arp_response(struct client_state_t *cs); diff --git a/ndhc/state.c b/ndhc/state.c index d7f77a9..25e9fec 100644 --- a/ndhc/state.c +++ b/ndhc/state.c @@ -212,6 +212,11 @@ static void an_packet(struct client_state_t *cs, struct dhcpmsg *packet, log_warning("arp_check failed to make arp socket, retrying lease"); reinit_selecting(cs, 3000); } + } else { + cs->dhcpState = DS_BOUND; + cs->timeout = cs->renewTime * 1000; + arp_set_defense_mode(cs); + set_listen_none(cs); } } else if (*message == DHCPNAK) {