]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix arping moving to the next test if we find the IP address
authorRoy Marples <roy@marples.name>
Mon, 24 Feb 2014 14:40:29 +0000 (14:40 +0000)
committerRoy Marples <roy@marples.name>
Mon, 24 Feb 2014 14:40:29 +0000 (14:40 +0000)
but do not have a profile for it.
Thanks to David McGurty for the analysis.

arp.c
dhcpcd.c
if-options.c

diff --git a/arp.c b/arp.c
index d6c5aeb041e03096f52881e231a3bf9a28b1f0fb..d7292edc22cf7169fdf6a6050300343bbc58ba5a 100644 (file)
--- 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);
index fb232164e51e22e0a40ec516a0cda8c2f949d94f..900f30112adbd1623d252ebd9405464fb2ae35e5 100644 (file)
--- 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
index 6e59c72bbbf18fb71dd1288f66a949ac2b7d46fd..8f5c6bc2460dacdbfc32ace5e1649e5920575a61 100644 (file)
@@ -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);