From: Roy Marples Date: Tue, 26 Mar 2013 10:42:30 +0000 (+0000) Subject: Fix rebooting. X-Git-Tag: v5.99.6~40 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=891ca6fad34271f26d26bfd08b95d186f3471cd6;p=thirdparty%2Fdhcpcd.git Fix rebooting. --- diff --git a/dhcp.c b/dhcp.c index e757cbb1..3c183a95 100644 --- a/dhcp.c +++ b/dhcp.c @@ -1935,7 +1935,7 @@ dhcp_inform(struct interface *ifp) } void -dhcp_reboot(struct interface *ifp, int oldopts) +dhcp_reboot_newopts(struct interface *ifp, int oldopts) { struct if_options *ifo = ifp->options; struct dhcp_state *state = D_STATE(ifp); @@ -1943,17 +1943,25 @@ dhcp_reboot(struct interface *ifp, int oldopts) if (state == NULL) return; ifo = ifp->options; - state->interval = 0; if ((ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC) && state->addr.s_addr != ifo->req_addr.s_addr) || (oldopts & (DHCPCD_INFORM | DHCPCD_STATIC) && !(ifo->options & (DHCPCD_INFORM | DHCPCD_STATIC)))) { dhcp_drop(ifp, "EXPIRE"); - } else { - free(state->offer); - state->offer = NULL; } +} + +static void +dhcp_reboot(struct interface *ifp) +{ + struct if_options *ifo = ifp->options; + struct dhcp_state *state = D_STATE(ifp); + + if (state == NULL) + return; + ifo = ifp->options; + state->interval = 0; if (ifo->options & DHCPCD_LINK && ifp->carrier == LINK_DOWN) { syslog(LOG_INFO, "%s: waiting for carrier", ifp->name); @@ -2670,6 +2678,6 @@ dhcp_start(struct interface *ifp) ifp->options->options & DHCPCD_IPV4LL) ipv4ll_start(ifp); else - dhcp_reboot(ifp, ifp->options->options); + dhcp_reboot(ifp); } diff --git a/dhcp.h b/dhcp.h index 8b59b852..a452ca7a 100644 --- a/dhcp.h +++ b/dhcp.h @@ -266,7 +266,7 @@ void dhcp_discover(void *); void dhcp_inform(struct interface *); void dhcp_release(struct interface *); void dhcp_bind(void *); -void dhcp_reboot(struct interface *, int); +void dhcp_reboot_newopts(struct interface *, int); void dhcp_close(struct interface *); void dhcp_free(struct interface *); int dhcp_dump(const char *); diff --git a/dhcpcd.c b/dhcpcd.c index f7f782d3..2e121d5c 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -604,7 +604,7 @@ if_reboot(struct interface *ifp, int argc, char **argv) oldopts = ifp->options->options; configure_interface(ifp, argc, argv); - dhcp_reboot(ifp, oldopts); + dhcp_reboot_newopts(ifp, oldopts); start_interface(ifp); } @@ -692,9 +692,6 @@ handle_signal(int sig) break; case SIGALRM: syslog(LOG_INFO, "received SIGALRM, rebinding"); - /* We shouldn't modify any variables in the signal - * handler, so simply add reboot function to the queue - * for an immediate callout. */ eloop_timeout_add_now(sig_reboot, NULL); return; case SIGHUP: