... | ... | @@ -335,11 +335,12 @@ and section 8.2: |
|
|
Thus kea-dhcp4 will need to extrapolate all of the free leases based on pool knowledge. Remembering that assigned leases are fetched, ordered by lease address, then the algorithm to process the results might look something like this:
|
|
|
|
|
|
```
|
|
|
current_pool = none
|
|
|
prev_pool = none
|
|
|
last_sent = none
|
|
|
pool_start = none
|
|
|
pool_end = none
|
|
|
current_pool = nul
|
|
|
prev_pool = nul
|
|
|
last_sent = nul
|
|
|
pool_start = nul
|
|
|
pool_end = nul
|
|
|
|
|
|
|
|
|
// Fetch leases in chunks
|
|
|
while (results = fetchNext()) {
|
... | ... | @@ -353,10 +354,9 @@ while (results = fetchNext()) { |
|
|
// Changed pools
|
|
|
if (current_pool != prev_pool) {
|
|
|
// Finish out previous pool
|
|
|
if (last_sent < pool_end) {
|
|
|
if (prev_pool && (last_sent < pool_end)) {
|
|
|
for (free_address = last_sent + 1; free_address <= pool_end; ++free_address) {
|
|
|
lease = makeFreeLease(free_address);
|
|
|
pushToSend(XID, free_lease);
|
|
|
pushToSend(XID, makeFreeLease(free_address));
|
|
|
}
|
|
|
}
|
|
|
|
... | ... | @@ -368,8 +368,7 @@ while (results = fetchNext()) { |
|
|
// If there are free leases between where we are and were we were, send them out
|
|
|
if (lease->address > pool_start && lease->address <= pool_end) {
|
|
|
for (free_address = pool_start; free_address < lease->address; ++free_address) {
|
|
|
lease = makeFreeLease(free_address);
|
|
|
pushToSend(XID, free_lease);
|
|
|
pushToSend(XID, makeFreeLease(free_address));
|
|
|
}
|
|
|
|
|
|
pool_start = lease->address + 1;
|
... | ... | @@ -390,6 +389,7 @@ if (last_sent < pool_end) { |
|
|
}
|
|
|
}
|
|
|
```
|
|
|
Note the above is intended to suggest a possible direction, producing the full set of free addresses is a more involved that depicted. The algorithm above would not produce entries for pools that have no allocated addresses. Those would need to be back-filled probably by tracking the pools that are fulfilled by the above algorithm and then producing free leases for all unrepresented pools.
|
|
|
|
|
|
There is also some questions as to how to treat host reservations for fixed addresses. Those that are in-pool but without a lease would be sent back as free by extrapolation. Technically accurate in terms of lease state but functionally it is only available to a single client. For out-of-pool addresses without leases, we would send back nothing without doing some sort of explicit search for them.
|
|
|
|
... | ... | |