|
|
3681f4 |
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
|
|
|
3681f4 |
index aac2c108..c83dc9a6 100644
|
|
|
3681f4 |
--- a/includes/dhcpd.h
|
|
|
3681f4 |
+++ b/includes/dhcpd.h
|
|
|
3681f4 |
@@ -1622,8 +1622,9 @@ struct iasubopt {
|
|
|
3681f4 |
*/
|
|
|
3681f4 |
#define EXPIRED_IPV6_CLEANUP_TIME (60*60)
|
|
|
3681f4 |
|
|
|
3681f4 |
- int heap_index; /* index into heap, or -1
|
|
|
3681f4 |
- (internal use only) */
|
|
|
3681f4 |
+ /* index into heaps, or -1 (internal use only) */
|
|
|
3681f4 |
+ int active_index;
|
|
|
3681f4 |
+ int inactive_index;
|
|
|
3681f4 |
|
|
|
3681f4 |
/*
|
|
|
3681f4 |
* A pointer to the state of the ddns update for this lease.
|
|
|
3681f4 |
diff --git a/server/mdb6.c b/server/mdb6.c
|
|
|
3681f4 |
index 1a728eb3..418ff606 100644
|
|
|
3681f4 |
--- a/server/mdb6.c
|
|
|
3681f4 |
+++ b/server/mdb6.c
|
|
|
3681f4 |
@@ -216,7 +216,8 @@ iasubopt_allocate(struct iasubopt **iasubopt, const char *file, int line) {
|
|
|
3681f4 |
|
|
|
3681f4 |
tmp->refcnt = 1;
|
|
|
3681f4 |
tmp->state = FTS_FREE;
|
|
|
3681f4 |
- tmp->heap_index = -1;
|
|
|
3681f4 |
+ tmp->active_index = -1;
|
|
|
3681f4 |
+ tmp->inactive_index = -1;
|
|
|
3681f4 |
tmp->plen = 255;
|
|
|
3681f4 |
|
|
|
3681f4 |
*iasubopt = tmp;
|
|
|
3681f4 |
@@ -604,10 +605,14 @@ lease_older(void *a, void *b) {
|
|
|
3681f4 |
* Callback when an address's position in the heap changes.
|
|
|
3681f4 |
*/
|
|
|
3681f4 |
static void
|
|
|
3681f4 |
-lease_index_changed(void *iasubopt, unsigned int new_heap_index) {
|
|
|
3681f4 |
- ((struct iasubopt *)iasubopt)-> heap_index = new_heap_index;
|
|
|
3681f4 |
+active_changed(void *iasubopt, unsigned int new_heap_index) {
|
|
|
3681f4 |
+ ((struct iasubopt *)iasubopt)-> active_index = new_heap_index;
|
|
|
3681f4 |
}
|
|
|
3681f4 |
|
|
|
3681f4 |
+static void
|
|
|
3681f4 |
+inactive_changed(void *iasubopt, unsigned int new_heap_index) {
|
|
|
3681f4 |
+ ((struct iasubopt *)iasubopt)-> inactive_index = new_heap_index;
|
|
|
3681f4 |
+}
|
|
|
3681f4 |
|
|
|
3681f4 |
/*!
|
|
|
3681f4 |
*
|
|
|
3681f4 |
@@ -660,13 +665,13 @@ ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type,
|
|
|
3681f4 |
dfree(tmp, file, line);
|
|
|
3681f4 |
return ISC_R_NOMEMORY;
|
|
|
3681f4 |
}
|
|
|
3681f4 |
- if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, lease_index_changed,
|
|
|
3681f4 |
+ if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, active_changed,
|
|
|
3681f4 |
0, &(tmp->active_timeouts)) != ISC_R_SUCCESS) {
|
|
|
3681f4 |
iasubopt_free_hash_table(&(tmp->leases), file, line);
|
|
|
3681f4 |
dfree(tmp, file, line);
|
|
|
3681f4 |
return ISC_R_NOMEMORY;
|
|
|
3681f4 |
}
|
|
|
3681f4 |
- if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, lease_index_changed,
|
|
|
3681f4 |
+ if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, inactive_changed,
|
|
|
3681f4 |
0, &(tmp->inactive_timeouts)) != ISC_R_SUCCESS) {
|
|
|
3681f4 |
isc_heap_destroy(&(tmp->active_timeouts));
|
|
|
3681f4 |
iasubopt_free_hash_table(&(tmp->leases), file, line);
|
|
|
3681f4 |
@@ -1361,7 +1366,7 @@ cleanup_lease6(ia_hash_t *ia_table,
|
|
|
3681f4 |
* Remove the old lease from the active heap and from the hash table
|
|
|
3681f4 |
* then remove the lease from the IA and clean up the IA if necessary.
|
|
|
3681f4 |
*/
|
|
|
3681f4 |
- isc_heap_delete(pool->active_timeouts, test_iasubopt->heap_index);
|
|
|
3681f4 |
+ isc_heap_delete(pool->active_timeouts, test_iasubopt->active_index);
|
|
|
3681f4 |
pool->num_active--;
|
|
|
3681f4 |
if (pool->ipv6_pond)
|
|
|
3681f4 |
pool->ipv6_pond->num_active--;
|
|
|
3681f4 |
@@ -1434,7 +1439,7 @@ add_lease6(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
3681f4 |
if ((test_iasubopt->state == FTS_ACTIVE) ||
|
|
|
3681f4 |
(test_iasubopt->state == FTS_ABANDONED)) {
|
|
|
3681f4 |
isc_heap_delete(pool->active_timeouts,
|
|
|
3681f4 |
- test_iasubopt->heap_index);
|
|
|
3681f4 |
+ test_iasubopt->active_index);
|
|
|
3681f4 |
pool->num_active--;
|
|
|
3681f4 |
if (pool->ipv6_pond)
|
|
|
3681f4 |
pool->ipv6_pond->num_active--;
|
|
|
3681f4 |
@@ -1446,7 +1451,7 @@ add_lease6(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
3681f4 |
}
|
|
|
3681f4 |
} else {
|
|
|
3681f4 |
isc_heap_delete(pool->inactive_timeouts,
|
|
|
3681f4 |
- test_iasubopt->heap_index);
|
|
|
3681f4 |
+ test_iasubopt->inactive_index);
|
|
|
3681f4 |
pool->num_inactive--;
|
|
|
3681f4 |
}
|
|
|
3681f4 |
|
|
|
3681f4 |
@@ -1567,14 +1572,13 @@ lease6_usable(struct iasubopt *lease) {
|
|
|
3681f4 |
static isc_result_t
|
|
|
3681f4 |
move_lease_to_active(struct ipv6_pool *pool, struct iasubopt *lease) {
|
|
|
3681f4 |
isc_result_t insert_result;
|
|
|
3681f4 |
- int old_heap_index;
|
|
|
3681f4 |
|
|
|
3681f4 |
- old_heap_index = lease->heap_index;
|
|
|
3681f4 |
insert_result = isc_heap_insert(pool->active_timeouts, lease);
|
|
|
3681f4 |
if (insert_result == ISC_R_SUCCESS) {
|
|
|
3681f4 |
iasubopt_hash_add(pool->leases, &lease->addr,
|
|
|
3681f4 |
sizeof(lease->addr), lease, MDL);
|
|
|
3681f4 |
- isc_heap_delete(pool->inactive_timeouts, old_heap_index);
|
|
|
3681f4 |
+ isc_heap_delete(pool->inactive_timeouts,
|
|
|
3681f4 |
+ lease->inactive_index);
|
|
|
3681f4 |
pool->num_active++;
|
|
|
3681f4 |
pool->num_inactive--;
|
|
|
3681f4 |
lease->state = FTS_ACTIVE;
|
|
|
3681f4 |
@@ -1624,16 +1628,16 @@ renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease) {
|
|
|
3681f4 |
if (lease->state == FTS_ACTIVE) {
|
|
|
3681f4 |
if (old_end_time <= lease->hard_lifetime_end_time) {
|
|
|
3681f4 |
isc_heap_decreased(pool->active_timeouts,
|
|
|
3681f4 |
- lease->heap_index);
|
|
|
3681f4 |
+ lease->active_index);
|
|
|
3681f4 |
} else {
|
|
|
3681f4 |
isc_heap_increased(pool->active_timeouts,
|
|
|
3681f4 |
- lease->heap_index);
|
|
|
3681f4 |
+ lease->active_index);
|
|
|
3681f4 |
}
|
|
|
3681f4 |
return ISC_R_SUCCESS;
|
|
|
3681f4 |
} else if (lease->state == FTS_ABANDONED) {
|
|
|
3681f4 |
char tmp_addr[INET6_ADDRSTRLEN];
|
|
|
3681f4 |
lease->state = FTS_ACTIVE;
|
|
|
3681f4 |
- isc_heap_increased(pool->active_timeouts, lease->heap_index);
|
|
|
3681f4 |
+ isc_heap_increased(pool->active_timeouts, lease->active_index);
|
|
|
3681f4 |
log_info("Reclaiming previously abandoned address %s",
|
|
|
3681f4 |
inet_ntop(AF_INET6, &(lease->addr), tmp_addr,
|
|
|
3681f4 |
sizeof(tmp_addr)));
|
|
|
3681f4 |
@@ -1655,9 +1659,7 @@ static isc_result_t
|
|
|
3681f4 |
move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
3681f4 |
binding_state_t state) {
|
|
|
3681f4 |
isc_result_t insert_result;
|
|
|
3681f4 |
- int old_heap_index;
|
|
|
3681f4 |
|
|
|
3681f4 |
- old_heap_index = lease->heap_index;
|
|
|
3681f4 |
insert_result = isc_heap_insert(pool->inactive_timeouts, lease);
|
|
|
3681f4 |
if (insert_result == ISC_R_SUCCESS) {
|
|
|
3681f4 |
/*
|
|
|
3681f4 |
@@ -1708,7 +1710,7 @@ move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
3681f4 |
|
|
|
3681f4 |
iasubopt_hash_delete(pool->leases,
|
|
|
3681f4 |
&lease->addr, sizeof(lease->addr), MDL);
|
|
|
3681f4 |
- isc_heap_delete(pool->active_timeouts, old_heap_index);
|
|
|
3681f4 |
+ isc_heap_delete(pool->active_timeouts, lease->active_index);
|
|
|
3681f4 |
lease->state = state;
|
|
|
3681f4 |
pool->num_active--;
|
|
|
3681f4 |
pool->num_inactive++;
|
|
|
3681f4 |
@@ -1786,7 +1788,7 @@ decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease) {
|
|
|
3681f4 |
pool->ipv6_pond->num_abandoned++;
|
|
|
3681f4 |
|
|
|
3681f4 |
lease->hard_lifetime_end_time = MAX_TIME;
|
|
|
3681f4 |
- isc_heap_decreased(pool->active_timeouts, lease->heap_index);
|
|
|
3681f4 |
+ isc_heap_decreased(pool->active_timeouts, lease->active_index);
|
|
|
3681f4 |
return ISC_R_SUCCESS;
|
|
|
3681f4 |
}
|
|
|
3681f4 |
|
|
|
3681f4 |
@@ -2059,7 +2061,7 @@ cleanup_old_expired(struct ipv6_pool *pool) {
|
|
|
3681f4 |
break;
|
|
|
3681f4 |
}
|
|
|
3681f4 |
|
|
|
3681f4 |
- isc_heap_delete(pool->inactive_timeouts, tmp->heap_index);
|
|
|
3681f4 |
+ isc_heap_delete(pool->inactive_timeouts, tmp->inactive_index);
|
|
|
3681f4 |
pool->num_inactive--;
|
|
|
3681f4 |
|
|
|
3681f4 |
if (tmp->ia != NULL) {
|