From: Roy Marples Date: Mon, 24 Feb 2014 14:40:29 +0000 (+0000) Subject: Fix arping moving to the next test if we find the IP address X-Git-Tag: v6.3.0~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=658bfd5e0cc0dc56d8bb7caf2e6d2a58821798a9;p=thirdparty%2Fdhcpcd.git Fix arping moving to the next test if we find the IP address but do not have a profile for it. Thanks to David McGurty for the analysis. --- diff --git a/arp.c b/arp.c index d6c5aeb0..d7292edc 100644 --- a/arp.c +++ b/arp.c @@ -179,8 +179,19 @@ arp_packet(void *arg) "%s: found %s on hardware address %s", ifp->name, inet_ntoa(ina), hwaddr); if (select_profile(ifp, hwaddr) == -1 && - errno == ENOENT) - select_profile(ifp, inet_ntoa(ina)); + select_profile(ifp, inet_ntoa(ina)) == -1) + { + state->probes = 0; + /* We didn't find a profile for this + * address or hwaddr, so move to the next + * arping profile */ + if (state->arping_index < + ifp->options->arping_len) + { + arp_probe(ifp); + return; + } + } dhcp_close(ifp); eloop_timeout_delete(ifp->ctx->eloop, NULL, ifp); start_interface(ifp); diff --git a/dhcpcd.c b/dhcpcd.c index fb232164..900f3011 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -461,14 +461,11 @@ int select_profile(struct interface *ifp, const char *profile) { struct if_options *ifo; - int ret; - ret = 0; ifo = read_config(ifp->ctx, ifp->name, ifp->ssid, profile); if (ifo == NULL) { syslog(LOG_DEBUG, "%s: no profile %s", ifp->name, profile); - ret = -1; - goto exit; + return -1; } if (profile != NULL) { strlcpy(ifp->profile, profile, sizeof(ifp->profile)); @@ -478,11 +475,9 @@ select_profile(struct interface *ifp, const char *profile) *ifp->profile = '\0'; free_options(ifp->options); ifp->options = ifo; - -exit: if (profile) configure_interface1(ifp); - return ret; + return 1; } static void diff --git a/if-options.c b/if-options.c index 6e59c72b..8f5c6bc2 100644 --- a/if-options.c +++ b/if-options.c @@ -1995,7 +1995,7 @@ read_config(struct dhcpcd_ctx *ctx, if (profile && !have_profile) { free_options(ifo); errno = ENOENT; - ifo = NULL; + return NULL; } finish_config(ifo);