]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
In the event DHCPv6 is started without IPv6RS, we should wait for
authorRoy Marples <roy@marples.name>
Thu, 30 May 2013 22:39:17 +0000 (22:39 +0000)
committerRoy Marples <roy@marples.name>
Thu, 30 May 2013 22:39:17 +0000 (22:39 +0000)
a LL address to appear.
Also, use DH6S_INIT or DH6S_INFORM to dhcp6_start instead of 0 or
1 for clarity.

dhcp6.c
dhcpcd.c
ipv6rs.c

diff --git a/dhcp6.c b/dhcp6.c
index 2d0bbeca9704bf252e9a8bdaa5aa8154c209abe1..795d2f8b97372f4ca68347087939130b49f7065c 100644 (file)
--- 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
index 11c22e7f280a6d2ea9b1d20a43e8344a5291161f..8fd99844801b6121ce09c81d7f016e81016cd9c9 100644 (file)
--- 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)
index 29d4d94d6cbad573555019872a3e56383f073b51..6c4758629171dcd014f62a37163ef5b4eaefdc15 100644 (file)
--- 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)