Skip to content

Commit a32e0ae

Browse files
committed
iapd: handle no-prefix-avail error in RENEW
1 parent 4cbc5ce commit a32e0ae

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

src/iapd.c

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -724,17 +724,39 @@ dhcp_time_t dhcp_iapd_step(struct dhcp_iapd *iapd, struct dhcp_context *ctx)
724724

725725
static void handle_iaprefix_noprefixavail(struct dhcp_iapd *iapd)
726726
{
727-
if (iapd->state != IAPD_STATE_REQUEST)
727+
enum iapd_prefix_selection sel;
728+
729+
switch (iapd->state) {
730+
case IAPD_STATE_REQUEST:
731+
sel = IAPD_PREFIX_SEL_PENDING;
732+
break;
733+
734+
case IAPD_STATE_RENEW:
735+
/* on no-prefix-available during RENEW, reset lifetimes which
736+
will trigger the condition in check #3 */
737+
sel = IAPD_PREFIX_SEL_ACTIVE;
738+
break;
739+
740+
default:
728741
return;
742+
}
729743

730744
for (size_t i = 0; i < ARRAY_SIZE(iapd->iaprefix); ++i) {
731-
struct dhcp_iaprefix *tmp = &iapd->iaprefix[i].pending;
745+
struct dhcp_iaprefix *tmp = get_iaprefix(iapd, i, sel);
732746

733-
tmp->net.len = 0;
734-
tmp->lease_tm = TIME_EPOCH;
735747
tmp->pref_lt = 0;
736748
tmp->valid_lt = 0;
737-
memset(&tmp->net.prefix, 0, sizeof tmp->net.prefix);
749+
750+
switch (iapd->state) {
751+
case IAPD_STATE_REQUEST:
752+
tmp->lease_tm = TIME_EPOCH;
753+
tmp->net.len = 0;
754+
memset(&tmp->net.prefix, 0, sizeof tmp->net.prefix);
755+
break;
756+
757+
default:
758+
break;
759+
}
738760
}
739761

740762
iapd->iostate = IAPD_IOSTATE_ERROR;

0 commit comments

Comments
 (0)