Merges in rt41815.
a cut and paste error.
[ISC-Bugs #42253]
+- Added global configuration parameter, abandon-lease-time, which determines
+ the amount of time a lease remains abandoned. The default is 84600 seconds.
+ Additionaly, the server now conducts a ping check (if ping checks are
+ enabled) prior to offering an abandoned lease to client.
+ [ISC-Bugs #41815]
+
Changes since 4.1-ESV-R13b1
- None
#define SV_DELAYED_ACK 58
#define SV_MAX_ACK_DELAY 59
#define SV_DHCPV6_SET_TEE_TIMES 60
+#define SV_ABANDON_LEASE_TIME 61
#if !defined (DEFAULT_PING_TIMEOUT)
# define DEFAULT_PING_TIMEOUT 1
# define MIN_LEASE_WRITE 15
#endif
+#if !defined (DEFAULT_ABANDON_LEASE_TIME)
+# define DEFAULT_ABANDON_LEASE_TIME 86400
+#endif
+
/* Client option names */
#define CL_TIMEOUT 1
extern int ddns_update_style;
extern int authoring_byte_order;
+extern u_int32_t abandon_lease_time;
extern const char *path_dhcpd_conf;
extern const char *path_dhcpd_db;
/* If this is a DHCPOFFER, ping the lease address before actually
sending the offer. */
if (offer == DHCPOFFER && !(lease -> flags & STATIC_LEASE) &&
- ((cur_time - lease_cltt) > 60) &&
+ (((cur_time - lease_cltt) > 60) ||
+ (lease->binding_state == FTS_ABANDONED)) &&
(!(oc = lookup_option (&server_universe, state -> options,
SV_PING_CHECKS)) ||
evaluate_boolean_option_cache (&ignorep, packet, lease,
* "no free leases" error when the last lease has been
* offered, but it's not exactly broken either.
*/
- if (!candl || (candl -> ends > cur_time))
+ if (!candl ||
+ (candl->binding_state != FTS_ABANDONED &&
+ (candl->ends > cur_time))) {
continue;
+ }
if (!lease) {
lease = candl;
#endif /* NSUPDATE */
int authoring_byte_order = 0; /* 0 = not set */
+u_int32_t abandon_lease_time = DEFAULT_ABANDON_LEASE_TIME;
const char *path_dhcpd_conf = _PATH_DHCPD_CONF;
const char *path_dhcpd_db = _PATH_DHCPD_DB;
}
#endif
+ // Set global abandon-lease-time option.
+ oc = lookup_option (&server_universe, options, SV_ABANDON_LEASE_TIME);
+ if ((oc != NULL) &&
+ evaluate_option_cache(&db, NULL, NULL, NULL, options, NULL,
+ &global_scope, oc, MDL)) {
+ if (db.len == sizeof (u_int32_t)) {
+ abandon_lease_time = getULong (db.data);
+ } else {
+ log_fatal("invalid abandon-lease-time");
+ }
+
+ data_string_forget (&db, MDL);
+ }
+
/* Don't need the options anymore. */
option_state_dereference (&options, MDL);
If a response is received to an ICMP Echo request, the DHCP server
assumes that there is a configuration error - the IP address is in use
by some host on the network that is not a DHCP client. It marks the
-address as abandoned, and will not assign it to clients.
+address as abandoned, and will not assign it to clients. The lease will
++remain abandoned for a minimum of abandon-lease-time seconds.
.PP
If a DHCP client tries to get an IP address, but none are available,
but there are abandoned IP addresses, then the DHCP server will
e.g. 4 2007/08/24 11:14:32 -7200
.SH REFERENCE: PARAMETERS
The
+.I abandon-lease-time
+statement
+.RS 0.25i
+.PP
+.B adandon-lease-time \fItime\fR\fB;\fR
+.PP
+.I Time
+should be the maximum amount of time (in seconds) that an abandoned IPv4 lease
+remains unavailable for assignment to a client. Abandoned leases will only be
+offered to clients if there are no free leases. If not defined, the default
+abandon lease time is 86400 seconds (24 hours). Note the abandoned lease time
+for a given lease is preserved across server restarts. The parameter may only
+be set at the global scope and is evaluated only once during server startup.
+.PP
+Values less than sixty seconds are not recommended as this is below the ping
+check threshold and can cause leases once abandoned but since returned to the
+free state to not be pinged before being offered. If the requested time is
+larger than 0x7FFFFFFF - 1 or the sum of the current time plus the abandoned time isgreater than 0x7FFFFFFF it is treated as infinite.
+.RE
+.PP
+The
.I adaptive-lease-time-threshold
statement
.RS 0.25i
to the address being assigned. It waits for a second, and if no
ICMP Echo response has been heard, it assigns the address. If a
response \fIis\fR heard, the lease is abandoned, and the server does
-not respond to the client.
+not respond to the client. The lease will remain abandoned for a minimum
+of abandon-lease-time seconds.
+.PP
+If a there are no free addressses but there are abandoned IP addresses, the
+DHCP server will attempt to reclaim an abandoned IP address regardless of the
+value of abandon-lease-time.
.PP
This \fIping check\fR introduces a default one-second delay in responding
to DHCPDISCOVER messages, which can be a problem for some clients. The
struct lease *lease;
const char *message;
{
- struct lease *lt = (struct lease *)0;
+ struct lease *lt = NULL;
#if defined (NSUPDATE)
ddns_removals(lease, NULL);
#endif
- if (!lease_copy (<, lease, MDL))
+ if (!lease_copy(<, lease, MDL)) {
return;
+ }
- if (lt->scope)
+ if (lt->scope) {
binding_scope_dereference(<->scope, MDL);
+ }
- lt -> ends = cur_time; /* XXX */
- lt -> next_binding_state = FTS_ABANDONED;
+ /* Calculate the abandone expiry time. If it wraps,
+ * use the maximum expiry time. */
+ lt->ends = cur_time + abandon_lease_time;
+ if (lt->ends < cur_time || lt->ends > MAX_TIME) {
+ lt->ends = MAX_TIME;
+ }
- log_error ("Abandoning IP address %s: %s",
- piaddr (lease -> ip_addr), message);
- lt -> hardware_addr.hlen = 0;
- if (lt -> uid && lt -> uid != lt -> uid_buf)
- dfree (lt -> uid, MDL);
- lt -> uid = (unsigned char *)0;
- lt -> uid_len = 0;
- lt -> uid_max = 0;
- supersede_lease (lease, lt, 1, 1, 1, 0);
- lease_dereference (<, MDL);
+ lt->next_binding_state = FTS_ABANDONED;
+
+ log_error ("Abandoning IP address %s: %s", piaddr(lease -> ip_addr),
+ message);
+ lt->hardware_addr.hlen = 0;
+ if (lt->uid && lt->uid != lt->uid_buf) {
+ dfree(lt->uid, MDL);
+ }
+
+ lt->uid = NULL;
+ lt->uid_len = 0;
+ lt->uid_max = 0;
+ supersede_lease(lease, lt, 1, 1, 1, 0);
+ lease_dereference(<, MDL);
}
/* Abandon the specified lease (set its timeout to infinity and its
{ "max-ack-delay", "L", &server_universe, 59, 1 },
#endif
{ "dhcpv6-set-tee-times", "f", &server_universe, SV_DHCPV6_SET_TEE_TIMES, 1 },
+ { "abandon-lease-time", "T", &server_universe, SV_ABANDON_LEASE_TIME, 1 },
{ NULL, NULL, NULL, 0, 0 }
};