]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
OK, the loop was caused by the initial carrier timeout. Also, always log carrier...
authorRoy Marples <roy@marples.name>
Mon, 21 Jul 2008 14:05:35 +0000 (14:05 +0000)
committerRoy Marples <roy@marples.name>
Mon, 21 Jul 2008 14:05:35 +0000 (14:05 +0000)
client.c

index 9a7930c5b4cc5e84a5dcf1313bb8a9920f2b2754..59d504598945a485edc01cb8efd4adb213efcf6a 100644 (file)
--- a/client.c
+++ b/client.c
@@ -600,14 +600,11 @@ client_setup(struct if_state *state, const struct options *options)
                }
        }
 #endif
+
        if (state->options & DHCPCD_LINK) {
                open_link_socket(iface);
-               if (carrier_status(iface->name) == 0) {
-                       if (state->options & DHCPCD_DAEMONISE &&
-                           !(state->options & DHCPCD_BACKGROUND))
-                               logger(LOG_INFO, "waiting for carrier");
+               if (carrier_status(iface->name) == 0)
                        state->carrier = LINK_DOWN;
-               }
        }
 
        if (options->timeout > 0 &&
@@ -1026,7 +1023,8 @@ handle_timeout_fail(struct if_state *state, const struct options *options)
                        if (iface->addr.s_addr != 0 &&
                            !(state->options & DHCPCD_INFORM))
                                logger(LOG_ERR, "lost lease");
-                       else
+                       else if (state->carrier != LINK_DOWN || 
+                               !(state->options & DHCPCD_DAEMONISED)) 
                                logger(LOG_ERR, "timed out");
                }
                do_socket(state, SOCKET_CLOSED);
@@ -1224,7 +1222,13 @@ handle_timeout(struct if_state *state, const struct options *options)
        }
 #endif
 
+       if (timerisset(&state->stop)) {
+               get_time(&tv);
+               if (timercmp(&tv, &state->stop, >))
+                       return handle_timeout_fail(state, options);
+       }
        timerclear(&tv);
+
        switch (state->state) {
        case STATE_BOUND: /* FALLTHROUGH */
        case STATE_RENEW_REQUESTED:
@@ -1237,13 +1241,6 @@ handle_timeout(struct if_state *state, const struct options *options)
                state->nakoff = 1;
                iface->start_uptime = uptime();
                break;
-       default:
-               if (!timerisset(&state->stop))
-                       break;
-               get_time(&tv);
-               if (timercmp(&tv, &state->stop, >))
-                       return handle_timeout_fail(state, options);
-               break;
        }
 
        switch(state->state) {
@@ -1710,6 +1707,9 @@ dhcp_run(const struct options *options, int *pid_fd)
                if (daemonise(state, options) == -1)
                        goto eexit;
 
+       if (state->carrier == LINK_DOWN)
+               logger(LOG_INFO, "waiting for carrier");
+
        for (;;) {
                /* We should always handle our signals first */
                if ((sig = (signal_read(state->signal_fd))) != -1) {