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