From: Roy Marples Date: Thu, 30 May 2013 22:39:17 +0000 (+0000) Subject: In the event DHCPv6 is started without IPv6RS, we should wait for X-Git-Tag: v5.99.7~22 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e74fdc60d4963ed618098904337f51d49fed09b2;p=thirdparty%2Fdhcpcd.git In the event DHCPv6 is started without IPv6RS, we should wait for a LL address to appear. Also, use DH6S_INIT or DH6S_INFORM to dhcp6_start instead of 0 or 1 for clarity. --- diff --git a/dhcp6.c b/dhcp6.c index 2d0bbeca..795d2f8b 100644 --- a/dhcp6.c +++ b/dhcp6.c @@ -1989,8 +1989,25 @@ errexit: return -1; } +static void +dhcp6_start1(void *arg) +{ + struct interface *ifp = arg; + struct dhcp6_state *state; + + state = D6_STATE(ifp); + syslog(LOG_INFO, "%s: %s", ifp->name, + state->state == DH6S_INFORM ? + "requesting DHCPv6 information" : + "soliciting a DHCPv6 address"); + if (state->state == DH6S_INFORM) + dhcp6_startinform(ifp); + else + dhcp6_startinit(ifp); +} + int -dhcp6_start(struct interface *ifp, int manage) +dhcp6_start(struct interface *ifp, int init_state) { struct dhcp6_state *state; @@ -2022,20 +2039,20 @@ dhcp6_start(struct interface *ifp, int manage) if (dhcp6_find_delegates(ifp)) return 0; - syslog(LOG_INFO, "%s: %s", ifp->name, - manage ? "soliciting a DHCPv6 address" : - "requesting DHCPv6 information"); - - state->state = manage ? DH6S_INIT : DH6S_INFORM; + state->state = init_state; snprintf(state->leasefile, sizeof(state->leasefile), LEASEFILE6, ifp->name); - if (state->state == DH6S_INFORM) - dhcp6_startinform(ifp); - else - dhcp6_startinit(ifp); + if (ipv6_linklocal(ifp) == NULL) { + syslog(LOG_DEBUG, + "%s: delaying DHCPv6 soliciation for LL address", + ifp->name); + ipv6_addlinklocalcallback(ifp, dhcp6_start1, ifp); + return 0; + } - return 1; + dhcp6_start1(ifp); + return 0; } static void diff --git a/dhcpcd.c b/dhcpcd.c index 11c22e7f..8fd99844 100644 --- a/dhcpcd.c +++ b/dhcpcd.c @@ -425,7 +425,7 @@ start_interface(void *arg) if (!(ifo->options & DHCPCD_IPV6RS)) { if (ifo->options & DHCPCD_IA_FORCED) - nolease = dhcp6_start(ifp, 1); + nolease = dhcp6_start(ifp, DH6S_INIT); else { nolease = dhcp6_find_delegates(ifp); /* Enabling the below doesn't really make @@ -439,7 +439,7 @@ start_interface(void *arg) /* With no RS or delegates we might * as well try and solicit a DHCPv6 address */ if (nolease == 0) - nolease = dhcp6_start(ifp, 1); + nolease = dhcp6_start(ifp, DH6S_INIT); #endif } if (nolease == -1) diff --git a/ipv6rs.c b/ipv6rs.c index 29d4d94d..6c475862 100644 --- a/ipv6rs.c +++ b/ipv6rs.c @@ -951,10 +951,10 @@ ipv6rs_handledata(__unused void *arg) handle_flag: if (rap->flags & ND_RA_FLAG_MANAGED) { - if (dhcp6_start(ifp, 1) == -1) + if (dhcp6_start(ifp, DH6S_INIT) == -1) syslog(LOG_ERR, "dhcp6_start: %s: %m", ifp->name); } else if (rap->flags & ND_RA_FLAG_OTHER) { - if (dhcp6_start(ifp, 0) == -1) + if (dhcp6_start(ifp, DH6S_INFORM) == -1) syslog(LOG_ERR, "dhcp6_start: %s: %m", ifp->name); } else { if (new_data)