summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--RELNOTES5
-rw-r--r--common/dhcp-options.514
-rw-r--r--common/options.c6
-rw-r--r--server/confpars.c20
-rw-r--r--server/dhcp.c61
5 files changed, 52 insertions, 54 deletions
diff --git a/RELNOTES b/RELNOTES
index 5181e0eb..f25f18d6 100644
--- a/RELNOTES
+++ b/RELNOTES
@@ -66,6 +66,11 @@ work on other platforms. Please report any problems and suggested fixes to
scope, or having a DHCP client send any system hostname in the host-name or
FQDN options by default).
+- The dhcp-renewal-time and dhcp-rebinding-time options may now be configured
+ for DHCPv4 operation and used independently of the dhcp-lease-time
+ calculations. Invalid renew and rebinding times (e.g., greater than the
+ determined lease time) are omitted.
+
Changes since 4.1.0 (bug fixes)
- Remove infinite loop in token_print_indent_concat().
diff --git a/common/dhcp-options.5 b/common/dhcp-options.5
index 49cff10a..5b74a81b 100644
--- a/common/dhcp-options.5
+++ b/common/dhcp-options.5
@@ -1,4 +1,4 @@
-.\" $Id: dhcp-options.5,v 1.44 2009/07/23 18:52:19 sar Exp $
+.\" $Id: dhcp-options.5,v 1.45 2009/09/11 18:13:12 dhankins Exp $
.\"
.\" Copyright (c) 2004-2008 by Internet Systems Consortium, Inc. ("ISC")
.\" Copyright (c) 1996-2003 by Internet Software Consortium
@@ -364,7 +364,11 @@ return.
This option specifies the number of seconds from the time a client gets
an address until the client transitions to the REBINDING state.
.PP
-This option is not user configurable.
+This option is user configurable, but it will be ignored if the value is
+greater than the lease time.
+.PP
+To make DHCPv4+DHCPv6 migration easier in the future, any value configured
+in this option is also used as a DHCPv6 "T1" (renew) time.
.PP
.RE
.PP
@@ -374,7 +378,11 @@ This option is not user configurable.
This option specifies the number of seconds from the time a client gets
an address until the client transitions to the RENEWING state.
.PP
-This option is not user configurable.
+This option is user configurable, but it will be ignored if the value is
+greater than the rebinding time, or lease time.
+.PP
+To make DHCPv4+DHCPv6 migration easier in the future, any value configured
+in this option is also used as a DHCPv6 "T2" (rebind) time.
.PP
.RE
.PP
diff --git a/common/options.c b/common/options.c
index b67168d0..597cfe86 100644
--- a/common/options.c
+++ b/common/options.c
@@ -642,6 +642,8 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
priority_list[priority_len++] = DHO_DHCP_MESSAGE_TYPE;
priority_list[priority_len++] = DHO_DHCP_SERVER_IDENTIFIER;
priority_list[priority_len++] = DHO_DHCP_LEASE_TIME;
+ priority_list[priority_len++] = DHO_DHCP_RENEWAL_TIME;
+ priority_list[priority_len++] = DHO_DHCP_REBINDING_TIME;
priority_list[priority_len++] = DHO_DHCP_MESSAGE;
priority_list[priority_len++] = DHO_DHCP_REQUESTED_ADDRESS;
priority_list[priority_len++] = DHO_ASSOCIATED_IP;
@@ -656,6 +658,10 @@ cons_options(struct packet *inpacket, struct dhcp_packet *outpacket,
data_string_truncate(prl, (PRIORITY_COUNT - priority_len));
+ /*
+ * Copy the client's PRL onto the priority_list after our high
+ * priority header.
+ */
for (i = 0; i < prl->len; i++) {
/*
* Prevent client from changing order of delivery
diff --git a/server/confpars.c b/server/confpars.c
index c0a0922f..47e2bf45 100644
--- a/server/confpars.c
+++ b/server/confpars.c
@@ -754,26 +754,6 @@ int parse_statement (cfile, group, type, host_decl, declaration)
return declaration;
}
- /*
- * If the configuration attempts to define on option
- * that we ignore, then warn about it now.
- *
- * In DHCPv4 we do not use dhcp-renewal-time or
- * dhcp-rebinding-time, but we use these in DHCPv6.
- *
- * XXX: We may want to include a "blacklist" of
- * options we ignore in the future, as a table.
- */
- if ((option->code == DHO_DHCP_LEASE_TIME) ||
- ((local_family != AF_INET6) &&
- ((option->code == DHO_DHCP_RENEWAL_TIME) ||
- (option->code == DHO_DHCP_REBINDING_TIME))))
- {
- log_error("WARNING: server ignoring option %s "
- "in configuration file.",
- option->name);
- }
-
finish_option:
et = (struct executable_statement *)0;
if (!parse_option_statement
diff --git a/server/dhcp.c b/server/dhcp.c
index d322ecbd..f60c1377 100644
--- a/server/dhcp.c
+++ b/server/dhcp.c
@@ -2546,39 +2546,38 @@ void ack_lease (packet, lease, offer, when, msg, ms_nulltp, hp)
option_cache_dereference (&oc, MDL);
}
- /* Renewal time is lease time * 0.5. */
- offered_lease_time /= 2;
- putULong(state->renewal, (u_int32_t)offered_lease_time);
- i = DHO_DHCP_RENEWAL_TIME;
- oc = (struct option_cache *)0;
- if (option_cache_allocate (&oc, MDL)) {
- if (make_const_data(&oc->expression, state->renewal,
- 4, 0, 0, MDL)) {
- option_code_hash_lookup(&oc->option,
- dhcp_universe.code_hash,
- &i, 0, MDL);
- save_option (&dhcp_universe,
- state -> options, oc);
- }
- option_cache_dereference (&oc, MDL);
+ /*
+ * Validate any configured renew or rebinding times against
+ * the determined lease time. Do rebinding first so that
+ * the renew time can be validated against the rebind time.
+ */
+ if ((oc = lookup_option(&dhcp_universe, state->options,
+ DHO_DHCP_REBINDING_TIME)) != NULL &&
+ evaluate_option_cache(&d1, packet, lease, NULL,
+ packet->options, state->options,
+ &lease->scope, oc, MDL)) {
+ TIME rebind_time = getULong(d1.data);
+
+ /* Drop the configured (invalid) rebinding time. */
+ if (rebind_time >= offered_lease_time)
+ delete_option(&dhcp_universe, state->options,
+ DHO_DHCP_REBINDING_TIME);
+ else /* XXX: variable is reused. */
+ offered_lease_time = rebind_time;
+
+ data_string_forget(&d1, MDL);
}
- /* Rebinding time is lease time * 0.875. */
- offered_lease_time += (offered_lease_time / 2
- + offered_lease_time / 4);
- putULong(state->rebind, (u_int32_t)offered_lease_time);
- i = DHO_DHCP_REBINDING_TIME;
- oc = (struct option_cache *)0;
- if (option_cache_allocate (&oc, MDL)) {
- if (make_const_data(&oc->expression, state->rebind,
- 4, 0, 0, MDL)) {
- option_code_hash_lookup(&oc->option,
- dhcp_universe.code_hash,
- &i, 0, MDL);
- save_option (&dhcp_universe,
- state -> options, oc);
- }
- option_cache_dereference (&oc, MDL);
+ if ((oc = lookup_option(&dhcp_universe, state->options,
+ DHO_DHCP_RENEWAL_TIME)) != NULL &&
+ evaluate_option_cache(&d1, packet, lease, NULL,
+ packet->options, state->options,
+ &lease->scope, oc, MDL)) {
+ if (getULong(d1.data) >= offered_lease_time)
+ delete_option(&dhcp_universe, state->options,
+ DHO_DHCP_RENEWAL_TIME);
+
+ data_string_forget(&d1, MDL);
}
} else {
/* XXXSK: should we use get_server_source_address() here? */