From: Roy Marples Date: Wed, 13 Aug 2008 19:41:40 +0000 (+0000) Subject: Fix INFORM and document it in dhcpcd-run-hooks. X-Git-Tag: v4.0.2~43 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4cec793b2485516c1bd8f6405c08166e7ac73a67;p=thirdparty%2Fdhcpcd.git Fix INFORM and document it in dhcpcd-run-hooks. --- diff --git a/client.c b/client.c index 3d982a26..66a7f9d3 100644 --- a/client.c +++ b/client.c @@ -1252,7 +1252,7 @@ handle_timeout(struct if_state *state, const struct options *options) * INIT-REBOOT state correctly. */ lease->server.s_addr = 0; state->messages = 0; - if (lease->addr.s_addr) { + if (lease->addr.s_addr && !(state->options & DHCPCD_INFORM)) { logger(LOG_INFO, "renewing lease of %s", inet_ntoa(lease->addr)); state->state = STATE_RENEWING; @@ -1467,10 +1467,9 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp, dhcp, DHO_SERVERID); log_dhcp(LOG_INFO, "acknowledged", dhcp); } - if (!state->offer) { - state->offer = dhcp; - *dhcpp = NULL; - } + free(state->offer); + state->offer = dhcp; + *dhcpp = NULL; break; default: logger(LOG_ERR, "wrong state %d", state->state); @@ -1479,8 +1478,9 @@ handle_dhcp(struct if_state *state, struct dhcp_message **dhcpp, do_socket(state, SOCKET_CLOSED); r = bind_dhcp(state, options); if (!(state->options & DHCPCD_ARP)) { - logger(LOG_DEBUG, "renew in %ld seconds", - (long int)state->stop.tv_sec); + if (!(state->options & DHCPCD_INFORM)) + logger(LOG_DEBUG, "renew in %ld seconds", + (long int)state->stop.tv_sec); return r; } state->state = STATE_ANNOUNCING; diff --git a/configure.c b/configure.c index db2228eb..dad3bce6 100644 --- a/configure.c +++ b/configure.c @@ -350,10 +350,12 @@ configure(struct interface *iface, const char *reason, #endif /* Grab our IP config */ - if (dhcp == NULL || dhcp->yiaddr == 0) + if (dhcp == NULL) up = 0; else { addr.s_addr = dhcp->yiaddr; + if (addr.s_addr == 0) + addr.s_addr = lease->addr.s_addr; /* Ensure we have all the needed values */ if (get_option_addr(&net.s_addr, dhcp, DHO_SUBNETMASK) == -1) net.s_addr = get_netmask(addr.s_addr); diff --git a/dhcpcd-run-hooks.8.in b/dhcpcd-run-hooks.8.in index 556601ed..fb435ccd 100644 --- a/dhcpcd-run-hooks.8.in +++ b/dhcpcd-run-hooks.8.in @@ -22,7 +22,7 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd July 12, 2008 +.Dd August 13, 2008 .Dt DHCPCD.SH 8 SMM .Sh NAME .Nm dhcpcd-run-hooks @@ -69,6 +69,9 @@ Here's a list of reasons why .Nm could be invoked: .Bl -tag -width indent +.It Dv INFORM +dhcpcd informed a DHCP server about it's address and obtained other +configuration details. .It Dv BOUND dhcpcd obtained a new lease from a DHCP server. .It Dv RENEW