]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix delegation activating interfaces. v6.10.1
authorRoy Marples <roy@marples.name>
Wed, 20 Jan 2016 19:08:12 +0000 (19:08 +0000)
committerRoy Marples <roy@marples.name>
Wed, 20 Jan 2016 19:08:12 +0000 (19:08 +0000)
dhcp6.c
dhcpcd.c
dhcpcd.h

diff --git a/dhcp6.c b/dhcp6.c
index 5f8ced85a48752dffcd09fe5bc9edd1cd2d5bab0..9abe78e78f0013b9fc38fc94e9d61d7992ec5ced 100644 (file)
--- a/dhcp6.c
+++ b/dhcp6.c
@@ -2482,14 +2482,20 @@ dhcp6_delegate_prefix(struct interface *ifp)
                        for (k = 0; k < i; j++)
                                if (strcmp(sla->ifname, ia->sla[j].ifname) == 0)
                                        break;
-                       if (j >= i &&
-                           ((ifd = if_find(ifp->ctx->ifaces,
-                               sla->ifname)) == NULL ||
-                           !ifd->active))
-                               logger(ifp->ctx, LOG_ERR,
-                                   "%s: interface does not exist"
-                                   " for delegation",
-                                   sla->ifname);
+                       if (j >= i) {
+                               ifd = if_find(ifp->ctx->ifaces, sla->ifname);
+                               if (ifd == NULL)
+                                       logger(ifp->ctx, LOG_ERR,
+                                           "%s: interface does not exist"
+                                           " for delegation",
+                                           sla->ifname);
+                               else if (!ifd->active) {
+                                       logger(ifp->ctx, LOG_INFO,
+                                           "%s: activating for delegation",
+                                           sla->ifname);
+                                       dhcpcd_activateinterface(ifd);
+                               }
+                       }
                }
        }
 
index 5ca9f321fd88c218be1d6f1136252917ae93881b..5255ec2e4d95e5f4b271405f8add7edba81a1f6a 100644 (file)
--- a/dhcpcd.c
+++ b/dhcpcd.c
@@ -670,6 +670,41 @@ dhcpcd_pollup(void *arg)
        dhcpcd_handlecarrier(ifp->ctx, carrier, ifp->flags, ifp->name);
 }
 
+static void
+dhcpcd_initstate1(struct interface *ifp, int argc, char **argv,
+    unsigned long long options)
+{
+       struct if_options *ifo;
+
+       configure_interface(ifp, argc, argv, options);
+       ifo = ifp->options;
+
+       if (ifo->options & DHCPCD_IPV4 && ipv4_init(ifp->ctx) == -1) {
+               logger(ifp->ctx, LOG_ERR, "ipv4_init: %m");
+               ifo->options &= ~DHCPCD_IPV4;
+       }
+       if (ifo->options & DHCPCD_IPV6 && ipv6_init(ifp->ctx) == NULL) {
+               logger(ifp->ctx, LOG_ERR, "ipv6_init: %m");
+               ifo->options &= ~DHCPCD_IPV6RS;
+       }
+
+       /* Add our link-local address before upping the interface
+        * so our RFC7217 address beats the hwaddr based one.
+        * This needs to happen before PREINIT incase a hook script
+        * inadvertently ups the interface. */
+       if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
+               logger(ifp->ctx, LOG_ERR, "%s: ipv6_start: %m", ifp->name);
+               ifo->options &= ~DHCPCD_IPV6;
+       }
+}
+
+static void
+dhcpcd_initstate(struct interface *ifp, unsigned long long options)
+{
+
+       dhcpcd_initstate1(ifp, ifp->ctx->argc, ifp->ctx->argv, options);
+}
+
 void
 dhcpcd_handlecarrier(struct dhcpcd_ctx *ctx, int carrier, unsigned int flags,
     const char *ifname)
@@ -947,67 +982,44 @@ dhcpcd_prestartinterface(void *arg)
 }
 
 static void
-handle_link(void *arg)
-{
-       struct dhcpcd_ctx *ctx;
-
-       ctx = arg;
-       if (if_managelink(ctx) == -1) {
-               logger(ctx, LOG_ERR, "if_managelink: %m");
-               eloop_event_delete(ctx->eloop, ctx->link_fd);
-               close(ctx->link_fd);
-               ctx->link_fd = -1;
-       }
-}
-
-static void
-dhcpcd_initstate1(struct interface *ifp, int argc, char **argv,
-    unsigned long long options)
+run_preinit(struct interface *ifp)
 {
-       struct if_options *ifo;
 
-       configure_interface(ifp, argc, argv, options);
-       ifo = ifp->options;
+       pre_start(ifp);
+       if (ifp->ctx->options & DHCPCD_TEST)
+               return;
 
-       if (ifo->options & DHCPCD_IPV4 && ipv4_init(ifp->ctx) == -1) {
-               logger(ifp->ctx, LOG_ERR, "ipv4_init: %m");
-               ifo->options &= ~DHCPCD_IPV4;
-       }
-       if (ifo->options & DHCPCD_IPV6 && ipv6_init(ifp->ctx) == NULL) {
-               logger(ifp->ctx, LOG_ERR, "ipv6_init: %m");
-               ifo->options &= ~DHCPCD_IPV6RS;
-       }
+       script_runreason(ifp, "PREINIT");
 
-       /* Add our link-local address before upping the interface
-        * so our RFC7217 address beats the hwaddr based one.
-        * This needs to happen before PREINIT incase a hook script
-        * inadvertently ups the interface. */
-       if (ifo->options & DHCPCD_IPV6 && ipv6_start(ifp) == -1) {
-               logger(ifp->ctx, LOG_ERR, "%s: ipv6_start: %m", ifp->name);
-               ifo->options &= ~DHCPCD_IPV6;
-       }
+       if (ifp->options->options & DHCPCD_LINK && ifp->carrier != LINK_UNKNOWN)
+               script_runreason(ifp,
+                   ifp->carrier == LINK_UP ? "CARRIER" : "NOCARRIER");
 }
 
 void
-dhcpcd_initstate(struct interface *ifp, unsigned long long options)
+dhcpcd_activateinterface(struct interface *ifp)
 {
 
-       dhcpcd_initstate1(ifp, ifp->ctx->argc, ifp->ctx->argv, options);
+       if (!ifp->active) {
+               ifp->active = 1;
+               dhcpcd_initstate(ifp, 0);
+               run_preinit(ifp);
+               dhcpcd_prestartinterface(ifp);
+       }
 }
 
 static void
-run_preinit(struct interface *ifp)
+handle_link(void *arg)
 {
+       struct dhcpcd_ctx *ctx;
 
-       pre_start(ifp);
-       if (ifp->ctx->options & DHCPCD_TEST)
-               return;
-
-       script_runreason(ifp, "PREINIT");
-
-       if (ifp->options->options & DHCPCD_LINK && ifp->carrier != LINK_UNKNOWN)
-               script_runreason(ifp,
-                   ifp->carrier == LINK_UP ? "CARRIER" : "NOCARRIER");
+       ctx = arg;
+       if (if_managelink(ctx) == -1) {
+               logger(ctx, LOG_ERR, "if_managelink: %m");
+               eloop_event_delete(ctx->eloop, ctx->link_fd);
+               close(ctx->link_fd);
+               ctx->link_fd = -1;
+       }
 }
 
 int
index 2de383f8b8b09829dcfbd4989fa1844ee3470c70..3ad736648ff0268f86919ee2d70642982bf68e5e 100644 (file)
--- a/dhcpcd.h
+++ b/dhcpcd.h
@@ -202,6 +202,6 @@ void dhcpcd_dropinterface(struct interface *, const char *);
 int dhcpcd_selectprofile(struct interface *, const char *);
 
 void dhcpcd_startinterface(void *);
-void dhcpcd_initstate(struct interface *, unsigned long long);
+void dhcpcd_activateinterface(struct interface *);
 
 #endif