From: Roy Marples Date: Thu, 4 Feb 2016 21:51:10 +0000 (+0000) Subject: Fix activating a stopped interface. X-Git-Tag: v6.10.2~69 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2fbd1900657fcbb0e5c8ab955ccf2b35c94f4f5c;p=thirdparty%2Fdhcpcd.git Fix activating a stopped interface. --- diff --git a/dhcp6.c b/dhcp6.c index 7dd5a192..9cacb635 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -3130,16 +3130,44 @@ errexit: return -1; } +static void +dhcp6_activateinterfaces(struct interface *ifp) +{ + struct interface *ifd; + size_t i, j; + struct if_ia *ia; + struct if_sla *sla; + + for (i = 0; i < ifp->options->ia_len; i++) { + ia = &ifp->options->ia[i]; + for (j = 0; j < ia->sla_len; j++) { + sla = &ia->sla[j]; + ifd = if_find(ifp->ctx->ifaces, sla->ifname); + if (ifd == NULL) { + logger(ifp->ctx, LOG_WARNING, + "%s: cannot delegate to %s: %m", + ifp->name, sla->ifname); + continue; + } + if (!ifd->active) { + logger(ifp->ctx, LOG_INFO, + "%s: activating for delegation", + sla->ifname); + dhcpcd_activateinterface(ifd, + DHCPCD_IPV6 | DHCPCD_DHCP6); + } + } + } +} + static void dhcp6_start1(void *arg) { - struct interface *ifp = arg, *ifd; + struct interface *ifp = arg; struct if_options *ifo = ifp->options; struct dhcp6_state *state; - size_t i, j; + size_t i; const struct dhcp_compat *dhc; - struct if_ia *ia; - struct if_sla *sla; state = D6_STATE(ifp); /* If no DHCPv6 options are configured, @@ -3171,28 +3199,7 @@ dhcp6_start1(void *arg) dhcp6_startinit(ifp); } - /* Activate any interfaces we need to */ - /* Ensure we have all interfaces */ - for (i = 0; i < ifo->ia_len; i++) { - ia = &ifo->ia[i]; - for (j = 0; j < ia->sla_len; j++) { - sla = &ia->sla[j]; - ifd = if_find(ifp->ctx->ifaces, sla->ifname); - if (ifd == NULL) { - logger(ifp->ctx, LOG_WARNING, - "%s: cannot delegate to %s: %m", - ifp->name, sla->ifname); - continue; - } - if (!ifd->active) { - logger(ifp->ctx, LOG_INFO, - "%s: activating for delegation", - sla->ifname); - dhcpcd_activateinterface(ifd, - DHCPCD_IPV6 | DHCPCD_DHCP6); - } - } - } + dhcp6_activateinterfaces(ifp); } int @@ -3219,6 +3226,7 @@ dhcp6_start(struct interface *ifp, enum DH6S init_state) } /* We're already running DHCP6 */ /* XXX: What if the managed flag vanishes from all RA? */ + dhcp6_activateinterfaces(ifp); return 0; } diff --git a/dhcpcd.c b/dhcpcd.c index 28e4d0a0..6b227bfe 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -425,6 +425,7 @@ stop_interface(struct interface *ifp) /* De-activate the interface */ ifp->active = IF_INACTIVE; + ifp->options->options &= ~DHCPCD_STOPPING; stop: if (!(ctx->options & (DHCPCD_MASTER | DHCPCD_TEST)))