]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP6: Fix --rebind on the control socket to really rebind
authorRoy Marples <roy@marples.name>
Fri, 7 Feb 2025 12:04:43 +0000 (12:04 +0000)
committerRoy Marples <roy@marples.name>
Fri, 7 Feb 2025 12:04:43 +0000 (12:04 +0000)
Rather than start a REBIND and then change straight to CONFIRM.
Fixes #437.

src/dhcp6.c
src/dhcp6.h

index 0eeebdec47b27fe75d7526771e579e92411be0ea..6a1eac3cc068c70f2f4a1c8b84d84c95e638eb6e 100644 (file)
@@ -2833,7 +2833,6 @@ dhcp6_startinit(struct interface *ifp)
 
        state = D6_STATE(ifp);
        ifo = ifp->options;
-       state->state = DH6S_INIT;
        state->expire = ND6_INFINITE_LIFETIME;
        state->lowpl = ND6_INFINITE_LIFETIME;
 
@@ -2862,7 +2861,8 @@ dhcp6_startinit(struct interface *ifp)
                {
                        /* RFC 3633 section 12.1 */
 #ifndef SMALL
-                       if (dhcp6_hasprefixdelegation(ifp))
+                       if (state->state == DH6S_MANUALREBIND ||
+                           dhcp6_hasprefixdelegation(ifp))
                                dhcp6_startrebind(ifp);
                        else
 #endif
@@ -4124,7 +4124,10 @@ dhcp6_start(struct interface *ifp, enum DH6S init_state)
                         * Now that we don't remove delegated addresses when
                         * reading the lease file this is the safe path.
                         */
-                       init_state = DH6S_INIT;
+                       if (state->state == DH6S_MANUALREBIND)
+                               init_state = DH6S_MANUALREBIND;
+                       else
+                               init_state = DH6S_INIT;
                        goto gogogo;
                default:
                        /* Not possible, but sushes some compiler warnings. */
@@ -4158,8 +4161,8 @@ dhcp6_start(struct interface *ifp, enum DH6S init_state)
        TAILQ_INIT(&state->addrs);
 
 gogogo:
-       state->new_start = true;
        state->state = init_state;
+       state->new_start = true;
        state->lerror = 0;
        state->failed = false;
        dhcp_set_leasefile(state->leasefile, sizeof(state->leasefile),
@@ -4183,15 +4186,17 @@ dhcp6_reboot(struct interface *ifp)
        if (state == NULL)
                return;
 
-       state->lerror = 0;
        switch (state->state) {
-       case DH6S_BOUND:
-               dhcp6_startrebind(ifp);
+       case DH6S_RENEW: /* FALLTHROUGH */
+       case DH6S_BOUND: /* FALLTHROUGH */
+       case DH6S_REBIND:
+               state->state = DH6S_MANUALREBIND;
                break;
-       default:
-               dhcp6_startdiscoinform(ifp);
+       default: /* Appease compilers */
                break;
        }
+
+       /* Do nothing. On confirming the next lease we will REBIND instead. */
 }
 
 static void
index 5fbc41b3665f5bdcb310024b5404df5543f38183..51251962a65204aae9dd8900e35b11b52f1c8b6b 100644 (file)
@@ -173,6 +173,7 @@ enum DH6S {
        DH6S_DELEGATED,
        DH6S_RELEASE,
        DH6S_RELEASED,
+       DH6S_MANUALREBIND,
 };
 
 struct dhcp6_state {