diff options
| author | Roy Marples <roy@marples.name> | 2016-01-20 19:08:12 +0000 |
|---|---|---|
| committer | Roy Marples <roy@marples.name> | 2016-01-20 19:08:12 +0000 |
| commit | 4507db941053c5af9608b7884f6abe1150cc5fa2 (patch) | |
| tree | 66a6684d51768ca0d6bae28d49c6cdbdf1571e3f | |
| parent | 316ae8e265051c13ed9ba9e528bbc05b360f22ff (diff) | |
| download | dhcpcd-6.10.1.tar.xz | |
Fix delegation activating interfaces.dhcpcd-6.10.1
| -rw-r--r-- | dhcp6.c | 22 | ||||
| -rw-r--r-- | dhcpcd.c | 106 | ||||
| -rw-r--r-- | dhcpcd.h | 2 |
3 files changed, 74 insertions, 56 deletions
@@ -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); + } + } } } @@ -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 @@ -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 |
