mirror of
https://gitlab.isc.org/isc-projects/dhcp
synced 2025-09-04 16:25:21 +00:00
- A new dhcp server option 'adaptive-lease-time-threshold' has been added
which causes the server to substantially reduce lease-times if there are few (configured percentage) remaining leases. Thanks to a patch submitted from Christof Chen. [ISC-Bugs #15409]
This commit is contained in:
5
RELNOTES
5
RELNOTES
@@ -162,6 +162,11 @@ and for prodding me into improving it.
|
||||
language. Thanks to a patch written by Mattias Ronnblom, gotten to us
|
||||
via Robin Breathe.
|
||||
|
||||
- A new dhcp server option 'adaptive-lease-time-threshold' has been added
|
||||
which causes the server to substantially reduce lease-times if there are
|
||||
few (configured percentage) remaining leases. Thanks to a patch submitted
|
||||
from Christof Chen.
|
||||
|
||||
Changes since 3.0.4
|
||||
|
||||
- A warning that host statements declared within subnet or shared-network
|
||||
|
@@ -512,6 +512,7 @@ struct lease_state {
|
||||
#define SV_RESERVE_INFINITE 47
|
||||
#define SV_DDNS_CONFLICT_DETECT 48
|
||||
#define SV_LEASEQUERY 49
|
||||
#define SV_ADAPTIVE_LEASE_TIME_THRESHOLD 50
|
||||
|
||||
#if !defined (DEFAULT_PING_TIMEOUT)
|
||||
# define DEFAULT_PING_TIMEOUT 1
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: dhcp.c,v 1.209 2006/07/25 13:26:00 shane Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
|
||||
"$Id: dhcp.c,v 1.210 2006/07/31 23:17:24 dhankins Exp $ Copyright (c) 2004-2006 Internet Systems Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@@ -2021,6 +2021,62 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
|
||||
}
|
||||
}
|
||||
|
||||
/* CC: If there are less than
|
||||
adaptive-lease-time-threshold % free leases,
|
||||
hand out only short term leases */
|
||||
|
||||
memset(&d1, 0, sizeof(d1));
|
||||
if (lease->pool &&
|
||||
(oc = lookup_option(&server_universe, state->options,
|
||||
SV_ADAPTIVE_LEASE_TIME_THRESHOLD)) &&
|
||||
evaluate_option_cache(&d1, packet, lease, NULL,
|
||||
packet->options, state->options,
|
||||
&lease->scope, oc, MDL)) {
|
||||
if (d1.len == 1 && d1.data[0] > 0 &&
|
||||
d1.data[0] < 100) {
|
||||
TIME adaptive_time;
|
||||
int poolfilled, total, count;
|
||||
|
||||
if (min_lease_time)
|
||||
adaptive_time = min_lease_time;
|
||||
else
|
||||
adaptive_time = DEFAULT_MIN_LEASE_TIME;
|
||||
|
||||
/* Allow the client to keep its lease. */
|
||||
if (lease->ends - cur_time > adaptive_time)
|
||||
adaptive_time = lease->ends - cur_time;
|
||||
|
||||
count = lease->pool->lease_count;
|
||||
total = count - (lease->pool->free_leases +
|
||||
lease->pool->backup_leases);
|
||||
|
||||
poolfilled = (total > (INT_MAX / 100)) ?
|
||||
total / (count / 100) :
|
||||
(total * 100) / count;
|
||||
|
||||
log_debug("Adap-lease: Total: %d, Free: %d, "
|
||||
"Ends: %d, Adaptive: %d, Fill: %d, "
|
||||
"Threshold: %d",
|
||||
lease->pool->lease_count,
|
||||
lease->pool->free_leases,
|
||||
(int)(lease->ends - cur_time),
|
||||
(int)adaptive_time, poolfilled,
|
||||
d1.data[0]);
|
||||
|
||||
if (poolfilled >= d1.data[0] &&
|
||||
lease_time > adaptive_time) {
|
||||
log_info("Pool over threshold, time "
|
||||
"for %s reduced from %d to "
|
||||
"%d.", piaddr(lease->ip_addr),
|
||||
(int)lease_time,
|
||||
(int)adaptive_time);
|
||||
|
||||
lease_time = adaptive_time;
|
||||
}
|
||||
}
|
||||
data_string_forget(&d1, MDL);
|
||||
}
|
||||
|
||||
if (lease_time < min_lease_time) {
|
||||
if (min_lease_time)
|
||||
lease_time = min_lease_time;
|
||||
|
@@ -28,7 +28,7 @@
|
||||
.\" see ``http://www.vix.com''. To learn more about Nominum, Inc., see
|
||||
.\" ``http://www.nominum.com''.
|
||||
.\"
|
||||
.\" $Id: dhcpd.conf.5,v 1.78 2006/07/25 13:26:00 shane Exp $
|
||||
.\" $Id: dhcpd.conf.5,v 1.79 2006/07/31 23:17:24 dhankins Exp $
|
||||
.\"
|
||||
.TH dhcpd.conf 5
|
||||
.SH NAME
|
||||
@@ -617,7 +617,7 @@ The
|
||||
statement
|
||||
.RS 0.25i
|
||||
.PP
|
||||
.B max-lease-misbalance \fIinteger\fR\fB;\fR
|
||||
.B max-lease-misbalance \fIpercentage\fR\fB;\fR
|
||||
.PP
|
||||
The \fBmax-lease-misbalance\fR statement tells the DHCP server what
|
||||
percentage of total free leases (as defined as the total number of
|
||||
@@ -636,7 +636,7 @@ The
|
||||
statement
|
||||
.RS 0.25i
|
||||
.PP
|
||||
.B max-lease-ownership \fIinteger\fR\fB;\fR
|
||||
.B max-lease-ownership \fIpercentage\fR\fB;\fR
|
||||
.PP
|
||||
The \fBmax-lease-ownership\fR statement tells the DHCP server what
|
||||
percentage of total free leases either it or its peer are normally allowed to
|
||||
@@ -1737,6 +1737,24 @@ force all clients that have been allocated addresses from this pool to
|
||||
obtain new addresses immediately when they next renew.
|
||||
.SH REFERENCE: PARAMETERS
|
||||
The
|
||||
.I adaptive-lease-time-threshold
|
||||
statement
|
||||
.RS 0.25i
|
||||
.PP
|
||||
.B adaptive-lease-time-threshold \fIpercentage\fR\fB;\fR
|
||||
.PP
|
||||
When the number of allocated leases within a pool rises above
|
||||
the \fIpercentage\fR given in this statement, the DHCP server decreases
|
||||
the lease length for new clients within this pool to \fImin-lease-time\fR
|
||||
seconds. Clients renewing an already valid (long) leases get at least the
|
||||
remaining time from the current lease. Since the leases expire faster,
|
||||
the server may either recover more quickly or avoid pool exhaustion
|
||||
entirely. Once the number of allocated leases drop below the threshold,
|
||||
the server reverts back to normal lease times. Valid percentages are
|
||||
between 1 and 99.
|
||||
.RE
|
||||
.PP
|
||||
The
|
||||
.I always-broadcast
|
||||
statement
|
||||
.RS 0.25i
|
||||
|
@@ -34,7 +34,7 @@
|
||||
|
||||
#ifndef lint
|
||||
static char copyright[] =
|
||||
"$Id: stables.c,v 1.32 2006/07/19 17:14:55 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
|
||||
"$Id: stables.c,v 1.33 2006/07/31 23:17:24 dhankins Exp $ Copyright (c) 2004 Internet Systems Consortium. All rights reserved.\n";
|
||||
#endif /* not lint */
|
||||
|
||||
#include "dhcpd.h"
|
||||
@@ -234,6 +234,7 @@ static struct option server_options[] = {
|
||||
{ "ping-timeout", "T", &server_universe, 46, 1 },
|
||||
{ "infinite-is-reserved", "f", &server_universe, 47, 1 },
|
||||
{ "update-conflict-detection", "f", &server_universe, 48, 1 },
|
||||
{ "adaptive-lease-time-threshold", "B", &server_universe, 50, 1 },
|
||||
{ NULL, NULL, NULL, 0, 0 }
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user