]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix a crash with departing interfaces.
authorRoy Marples <roy@marples.name>
Wed, 12 Jun 2013 18:24:16 +0000 (18:24 +0000)
committerRoy Marples <roy@marples.name>
Wed, 12 Jun 2013 18:24:16 +0000 (18:24 +0000)
Fix more needless spam when an interface departs.

dhcpcd.c
if-options.h
ipv4.c

index f9d53a7f84d369332894f81bc1d962b8c6d6e06e..f57818697ec4bad79f071631b1c31e88f2284337 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -282,6 +282,8 @@ stop_interface(struct interface *ifp)
        dhcp_drop(ifp, "STOP");
        dhcp_close(ifp);
        eloop_timeout_delete(NULL, ifp);
+       if (ifp->options->options & DHCPCD_DEPARTED)
+               script_runreason(ifp, "DEPARTED");
        free_interface(ifp);
        if (!(options & (DHCPCD_MASTER | DHCPCD_TEST)))
                exit(EXIT_FAILURE);
@@ -470,7 +472,7 @@ static void
 handle_link(__unused void *arg)
 {
 
-       if (manage_link(linkfd) == -1)
+       if (manage_link(linkfd) == -1 && errno != ENXIO && errno != ENODEV)
                syslog(LOG_ERR, "manage_link: %m");
 }
 
@@ -526,8 +528,8 @@ handle_interface(int action, const char *ifname)
        if (action == -1) {
                ifp = find_interface(ifname);
                if (ifp != NULL) {
+                       ifp->options->options |= DHCPCD_DEPARTED;
                        stop_interface(ifp);
-                       script_runreason(ifp, "DEPARTED");
                }
                return;
        }
index 9cc91e7191e3851c67712b0cf494d1ad5fd1a95b..579a0ffa043d7c14259db1b1c958a9e9a0eb9dce 100644 (file)
@@ -92,6 +92,7 @@
 #define DHCPCD_STARTED                 (1ULL << 38)
 #define DHCPCD_NOALIAS                 (1ULL << 39)
 #define DHCPCD_IA_FORCED               (1ULL << 40)
+#define DHCPCD_DEPARTED                        (1ULL << 41)
 
 extern const struct option cf_options[];
 
diff --git a/ipv4.c b/ipv4.c
index 6329f2a0932a8112b44bc4bb20a0ca07b3c2e29b..567a1f23eed2defd2c48178c06612f79364e8141 100644 (file)
--- a/ipv4.c
+++ b/ipv4.c
@@ -548,7 +548,8 @@ delete_address(struct interface *iface)
        syslog(LOG_DEBUG, "%s: deleting IP address %s/%d",
            iface->name, inet_ntoa(state->addr), inet_ntocidr(state->net));
        retval = ipv4_deleteaddress(iface, &state->addr, &state->net);
-       if (retval == -1 && errno != EADDRNOTAVAIL && errno != ENXIO)
+       if (retval == -1 && errno != EADDRNOTAVAIL && errno != ENXIO &&
+           errno != ENODEV)
                syslog(LOG_ERR, "del_address: %m");
        state->addr.s_addr = 0;
        state->net.s_addr = 0;