]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
*** empty log message ***
authorDavid Hankins <dhankins@isc.org>
Fri, 11 Sep 2009 18:13:12 +0000 (18:13 +0000)
committerDavid Hankins <dhankins@isc.org>
Fri, 11 Sep 2009 18:13:12 +0000 (18:13 +0000)
RELNOTES
common/dhcp-options.5
common/options.c
server/confpars.c
server/dhcp.c

index 5181e0eb18b334e1dbf0ef2d105816638028a2e3..f25f18d694ea2080dd4b0967db4a580d1b7d7c7b 100644 (file)
--- 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().
index 49cff10abfb220621fd0e88a4b654c8c4a56a216..5b74a81bb7b850300c55ab7ab3c2d3666d2c3a6d 100644 (file)
@@ -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
index b67168d056ac9c838a741fecdced9694f26f33f8..597cfe86bb2cd6523e902a875eccb10ec6bd312e 100644 (file)
@@ -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
index c0a0922fa590be614385ab980e04c18ff62e615d..47e2bf45b8a34efc92510daee3b65ccd8ed3547f 100644 (file)
@@ -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
index d322ecbdaee7c71f9c0b65d80937c4509b549c42..f60c13773e15ec660de9adb5965456359b21f128 100644 (file)
@@ -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? */