]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
DHCP6: Improve logging when changing IA type
authorRoy Marples <roy@marples.name>
Mon, 18 Dec 2023 12:15:10 +0000 (12:15 +0000)
committerRoy Marples <roy@marples.name>
Mon, 18 Dec 2023 12:15:10 +0000 (12:15 +0000)
Changing from PD to IA or IA to PD can result in a diagnostic
when there is no address to confirm AND we haven't loaded
a lease.
This improves the check and no more Success errors should
be reported.

src/dhcp6.c

index 63fe2dc64584ce81f1b5060a52b52d42af639f91..6703f5cf43f2edf393ae37adb4cca51681711a40 100644 (file)
@@ -2589,21 +2589,17 @@ dhcp6_validatelease(struct interface *ifp,
        }
        state->has_no_binding = false;
        nia = dhcp6_findia(ifp, m, len, sfrom, acquired);
-       if (nia == 0) {
-               if (state->state != DH6S_CONFIRM && ok_errno != 0) {
-                       logerrx("%s: no useable IA found in lease", ifp->name);
-                       return -1;
-               }
-
-               /* We are confirming and have an OK,
-                * so look for ia's in our old lease.
-                * IA's must have existed here otherwise we would
-                * have rejected it earlier. */
-               assert(state->new != NULL && state->new_len != 0);
+       if (nia == 0 && state->state == DH6S_CONFIRM && ok_errno == 0 &&
+           state->new && state->new_len)
+       {
                state->has_no_binding = false;
                nia = dhcp6_findia(ifp, state->new, state->new_len,
                    sfrom, acquired);
        }
+       if (nia == 0) {
+               logerrx("%s: no useable IA found in lease", ifp->name);
+               return -1;
+       }
        return nia;
 }
 
@@ -2657,8 +2653,10 @@ dhcp6_readlease(struct interface *ifp, int validate)
        /* Check to see if the lease is still valid */
        fd = dhcp6_validatelease(ifp, &buf.dhcp6, (size_t)bytes, NULL,
            &state->acquired);
-       if (fd == -1)
+       if (fd == -1) {
+               bytes = 0; /* We have already reported the error */
                goto ex;
+       }
 
        if (state->expire != ND6_INFINITE_LIFETIME &&
            (time_t)state->expire < now - mtime &&