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);
+ }
+ }
}
}
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)
}
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