Skip to content

Commit

Permalink
DHCP6: Improve logging when changing IA type
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rsmarples committed Dec 18, 2023
1 parent 411e653 commit c7a142a
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/dhcp6.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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 &&
Expand Down

0 comments on commit c7a142a

Please sign in to comment.