]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix rebooting.
authorRoy Marples <roy@marples.name>
Tue, 26 Mar 2013 10:42:30 +0000 (10:42 +0000)
committerRoy Marples <roy@marples.name>
Tue, 26 Mar 2013 10:42:30 +0000 (10:42 +0000)
dhcp.c
dhcp.h
dhcpcd.c

diff --git a/dhcp.c b/dhcp.c
index e757cbb1c4c59f8dcc7ae03ac923130379690b30..3c183a9577cf5e71e32c71f9ee417815ce9ac953 100644 (file)
--- 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 8b59b852cab9c90473976a19a9c0007001cba424..a452ca7a0dae3774c26cf513fa5a80e4e266c224 100644 (file)
--- 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 *);
index f7f782d3fa75a219c6acb5bb3653b2be61cb1f2c..2e121d5c97dec26578407f9f3679fe54c0dc2bfb 100644 (file)
--- 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: