summaryrefslogtreecommitdiffstats
path: root/dhcpcd.c
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-01-20 19:08:12 +0000
committerRoy Marples <roy@marples.name>2016-01-20 19:08:12 +0000
commit4507db941053c5af9608b7884f6abe1150cc5fa2 (patch)
tree66a6684d51768ca0d6bae28d49c6cdbdf1571e3f /dhcpcd.c
parent316ae8e265051c13ed9ba9e528bbc05b360f22ff (diff)
downloaddhcpcd-4507db941053c5af9608b7884f6abe1150cc5fa2.tar.xz
Fix delegation activating interfaces.dhcpcd-6.10.1
Diffstat (limited to 'dhcpcd.c')
-rw-r--r--dhcpcd.c106
1 files changed, 59 insertions, 47 deletions
diff --git a/dhcpcd.c b/dhcpcd.c
index 5ca9f321..5255ec2e 100644
--- 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