From: Roy Marples Date: Wed, 12 Jun 2013 18:24:16 +0000 (+0000) Subject: Fix a crash with departing interfaces. X-Git-Tag: v6.0.0~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6fb316a6688ffc37388063e0a74b334489ccadfd;p=thirdparty%2Fdhcpcd.git Fix a crash with departing interfaces. Fix more needless spam when an interface departs. --- diff --git a/dhcpcd.c b/dhcpcd.c index f9d53a7f..f5781869 100644 --- 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; } diff --git a/if-options.h b/if-options.h index 9cc91e71..579a0ffa 100644 --- a/if-options.h +++ b/if-options.h @@ -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 6329f2a0..567a1f23 100644 --- 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;