|
|
45d60a |
diff --git a/includes/dhcpd.h b/includes/dhcpd.h
|
|
|
45d60a |
index 52ba677..deea2a7 100644
|
|
|
45d60a |
--- a/includes/dhcpd.h
|
|
|
45d60a |
+++ b/includes/dhcpd.h
|
|
|
45d60a |
@@ -1521,8 +1521,9 @@ struct iasubopt {
|
|
|
45d60a |
*/
|
|
|
45d60a |
#define EXPIRED_IPV6_CLEANUP_TIME (60*60)
|
|
|
45d60a |
|
|
|
45d60a |
- int heap_index; /* index into heap, or -1
|
|
|
45d60a |
- (internal use only) */
|
|
|
45d60a |
+ /* index into heaps, or -1 (internal use only) */
|
|
|
45d60a |
+ int active_index;
|
|
|
45d60a |
+ int inactive_index;
|
|
|
45d60a |
|
|
|
45d60a |
/*
|
|
|
45d60a |
* A pointer to the state of the ddns update for this lease.
|
|
|
45d60a |
diff --git a/server/mdb6.c b/server/mdb6.c
|
|
|
45d60a |
index 0e76264..711ab3d 100644
|
|
|
45d60a |
--- a/server/mdb6.c
|
|
|
45d60a |
+++ b/server/mdb6.c
|
|
|
45d60a |
@@ -130,7 +130,8 @@ iasubopt_allocate(struct iasubopt **iasubopt, const char *file, int line) {
|
|
|
45d60a |
|
|
|
45d60a |
tmp->refcnt = 1;
|
|
|
45d60a |
tmp->state = FTS_FREE;
|
|
|
45d60a |
- tmp->heap_index = -1;
|
|
|
45d60a |
+ tmp->active_index = -1;
|
|
|
45d60a |
+ tmp->inactive_index = -1;
|
|
|
45d60a |
tmp->plen = 255;
|
|
|
45d60a |
|
|
|
45d60a |
*iasubopt = tmp;
|
|
|
45d60a |
@@ -504,10 +505,14 @@ lease_older(void *a, void *b) {
|
|
|
45d60a |
* Callback when an address's position in the heap changes.
|
|
|
45d60a |
*/
|
|
|
45d60a |
static void
|
|
|
45d60a |
-lease_index_changed(void *iasubopt, unsigned int new_heap_index) {
|
|
|
45d60a |
- ((struct iasubopt *)iasubopt)-> heap_index = new_heap_index;
|
|
|
45d60a |
+active_changed(void *iasubopt, unsigned int new_heap_index) {
|
|
|
45d60a |
+ ((struct iasubopt *)iasubopt)-> active_index = new_heap_index;
|
|
|
45d60a |
}
|
|
|
45d60a |
|
|
|
45d60a |
+static void
|
|
|
45d60a |
+inactive_changed(void *iasubopt, unsigned int new_heap_index) {
|
|
|
45d60a |
+ ((struct iasubopt *)iasubopt)-> inactive_index = new_heap_index;
|
|
|
45d60a |
+}
|
|
|
45d60a |
|
|
|
45d60a |
/*
|
|
|
45d60a |
* Create a new IPv6 lease pool structure.
|
|
|
45d60a |
@@ -544,13 +549,13 @@ ipv6_pool_allocate(struct ipv6_pool **pool, u_int16_t type,
|
|
|
45d60a |
dfree(tmp, file, line);
|
|
|
45d60a |
return ISC_R_NOMEMORY;
|
|
|
45d60a |
}
|
|
|
45d60a |
- if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, lease_index_changed,
|
|
|
45d60a |
+ if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, active_changed,
|
|
|
45d60a |
0, &(tmp->active_timeouts)) != ISC_R_SUCCESS) {
|
|
|
45d60a |
iasubopt_free_hash_table(&(tmp->leases), file, line);
|
|
|
45d60a |
dfree(tmp, file, line);
|
|
|
45d60a |
return ISC_R_NOMEMORY;
|
|
|
45d60a |
}
|
|
|
45d60a |
- if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, lease_index_changed,
|
|
|
45d60a |
+ if (isc_heap_create(dhcp_gbl_ctx.mctx, lease_older, inactive_changed,
|
|
|
45d60a |
0, &(tmp->inactive_timeouts)) != ISC_R_SUCCESS) {
|
|
|
45d60a |
isc_heap_destroy(&(tmp->active_timeouts));
|
|
|
45d60a |
iasubopt_free_hash_table(&(tmp->leases), file, line);
|
|
|
45d60a |
@@ -1045,7 +1050,7 @@ cleanup_lease6(ia_hash_t *ia_table,
|
|
|
45d60a |
* Remove the old lease from the active heap and from the hash table
|
|
|
45d60a |
* then remove the lease from the IA and clean up the IA if necessary.
|
|
|
45d60a |
*/
|
|
|
45d60a |
- isc_heap_delete(pool->active_timeouts, test_iasubopt->heap_index);
|
|
|
45d60a |
+ isc_heap_delete(pool->active_timeouts, test_iasubopt->active_index);
|
|
|
45d60a |
pool->num_active--;
|
|
|
45d60a |
|
|
|
45d60a |
iasubopt_hash_delete(pool->leases, &test_iasubopt->addr,
|
|
|
45d60a |
@@ -1110,11 +1115,11 @@ add_lease6(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
45d60a |
if ((test_iasubopt->state == FTS_ACTIVE) ||
|
|
|
45d60a |
(test_iasubopt->state == FTS_ABANDONED)) {
|
|
|
45d60a |
isc_heap_delete(pool->active_timeouts,
|
|
|
45d60a |
- test_iasubopt->heap_index);
|
|
|
45d60a |
+ test_iasubopt->active_index);
|
|
|
45d60a |
pool->num_active--;
|
|
|
45d60a |
} else {
|
|
|
45d60a |
isc_heap_delete(pool->inactive_timeouts,
|
|
|
45d60a |
- test_iasubopt->heap_index);
|
|
|
45d60a |
+ test_iasubopt->inactive_index);
|
|
|
45d60a |
pool->num_inactive--;
|
|
|
45d60a |
}
|
|
|
45d60a |
|
|
|
45d60a |
@@ -1225,14 +1230,13 @@ lease6_usable(struct iasubopt *lease) {
|
|
|
45d60a |
static isc_result_t
|
|
|
45d60a |
move_lease_to_active(struct ipv6_pool *pool, struct iasubopt *lease) {
|
|
|
45d60a |
isc_result_t insert_result;
|
|
|
45d60a |
- int old_heap_index;
|
|
|
45d60a |
|
|
|
45d60a |
- old_heap_index = lease->heap_index;
|
|
|
45d60a |
insert_result = isc_heap_insert(pool->active_timeouts, lease);
|
|
|
45d60a |
if (insert_result == ISC_R_SUCCESS) {
|
|
|
45d60a |
iasubopt_hash_add(pool->leases, &lease->addr,
|
|
|
45d60a |
sizeof(lease->addr), lease, MDL);
|
|
|
45d60a |
- isc_heap_delete(pool->inactive_timeouts, old_heap_index);
|
|
|
45d60a |
+ isc_heap_delete(pool->inactive_timeouts,
|
|
|
45d60a |
+ lease->inactive_index);
|
|
|
45d60a |
pool->num_active++;
|
|
|
45d60a |
pool->num_inactive--;
|
|
|
45d60a |
lease->state = FTS_ACTIVE;
|
|
|
45d60a |
@@ -1278,16 +1282,16 @@ renew_lease6(struct ipv6_pool *pool, struct iasubopt *lease) {
|
|
|
45d60a |
if (lease->state == FTS_ACTIVE) {
|
|
|
45d60a |
if (old_end_time <= lease->hard_lifetime_end_time) {
|
|
|
45d60a |
isc_heap_decreased(pool->active_timeouts,
|
|
|
45d60a |
- lease->heap_index);
|
|
|
45d60a |
+ lease->active_index);
|
|
|
45d60a |
} else {
|
|
|
45d60a |
isc_heap_increased(pool->active_timeouts,
|
|
|
45d60a |
- lease->heap_index);
|
|
|
45d60a |
+ lease->active_index);
|
|
|
45d60a |
}
|
|
|
45d60a |
return ISC_R_SUCCESS;
|
|
|
45d60a |
} else if (lease->state == FTS_ABANDONED) {
|
|
|
45d60a |
char tmp_addr[INET6_ADDRSTRLEN];
|
|
|
45d60a |
lease->state = FTS_ACTIVE;
|
|
|
45d60a |
- isc_heap_increased(pool->active_timeouts, lease->heap_index);
|
|
|
45d60a |
+ isc_heap_increased(pool->active_timeouts, lease->active_index);
|
|
|
45d60a |
log_info("Reclaiming previously abandoned address %s",
|
|
|
45d60a |
inet_ntop(AF_INET6, &(lease->addr), tmp_addr,
|
|
|
45d60a |
sizeof(tmp_addr)));
|
|
|
45d60a |
@@ -1304,9 +1308,7 @@ static isc_result_t
|
|
|
45d60a |
move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
45d60a |
binding_state_t state) {
|
|
|
45d60a |
isc_result_t insert_result;
|
|
|
45d60a |
- int old_heap_index;
|
|
|
45d60a |
|
|
|
45d60a |
- old_heap_index = lease->heap_index;
|
|
|
45d60a |
insert_result = isc_heap_insert(pool->inactive_timeouts, lease);
|
|
|
45d60a |
if (insert_result == ISC_R_SUCCESS) {
|
|
|
45d60a |
#if defined (NSUPDATE)
|
|
|
45d60a |
@@ -1325,7 +1327,7 @@ move_lease_to_inactive(struct ipv6_pool *pool, struct iasubopt *lease,
|
|
|
45d60a |
|
|
|
45d60a |
iasubopt_hash_delete(pool->leases,
|
|
|
45d60a |
&lease->addr, sizeof(lease->addr), MDL);
|
|
|
45d60a |
- isc_heap_delete(pool->active_timeouts, old_heap_index);
|
|
|
45d60a |
+ isc_heap_delete(pool->active_timeouts, lease->active_index);
|
|
|
45d60a |
lease->state = state;
|
|
|
45d60a |
pool->num_active--;
|
|
|
45d60a |
pool->num_inactive++;
|
|
|
45d60a |
@@ -1390,7 +1392,7 @@ decline_lease6(struct ipv6_pool *pool, struct iasubopt *lease) {
|
|
|
45d60a |
}
|
|
|
45d60a |
lease->state = FTS_ABANDONED;
|
|
|
45d60a |
lease->hard_lifetime_end_time = MAX_TIME;
|
|
|
45d60a |
- isc_heap_decreased(pool->active_timeouts, lease->heap_index);
|
|
|
45d60a |
+ isc_heap_decreased(pool->active_timeouts, lease->active_index);
|
|
|
45d60a |
return ISC_R_SUCCESS;
|
|
|
45d60a |
}
|
|
|
45d60a |
|
|
|
45d60a |
@@ -1663,7 +1665,7 @@ cleanup_old_expired(struct ipv6_pool *pool) {
|
|
|
45d60a |
break;
|
|
|
45d60a |
}
|
|
|
45d60a |
|
|
|
45d60a |
- isc_heap_delete(pool->inactive_timeouts, tmp->heap_index);
|
|
|
45d60a |
+ isc_heap_delete(pool->inactive_timeouts, tmp->inactive_index);
|
|
|
45d60a |
pool->num_inactive--;
|
|
|
45d60a |
|
|
|
45d60a |
if (tmp->ia != NULL) {
|