]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Modify the determination of the ttl to use for ddns updates [ISC-Bugs #21126]
authorShawn Routhier <sar@isc.org>
Thu, 27 May 2010 17:29:22 +0000 (17:29 +0000)
committerShawn Routhier <sar@isc.org>
Thu, 27 May 2010 17:29:22 +0000 (17:29 +0000)
RELNOTES
includes/dhcpd.h
includes/site.h
server/ddns.c
server/dhcpd.c

index 046619085e64a556907934fb8dcc408b6f99d52f..f99dfb9378fb27a4eb3fee6dc8dce4343721dd2a 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -66,7 +66,14 @@ work on other platforms. Please report any problems and suggested fixes to
 - Add some debugging output for use with the DDNS code. [ISC-Bugs #20916]
 
 - Fix the trace code to handle timing events better and to truncate a file
-  before using instead of overwriting it.  [ISC-Bugs 20969]
+  before using instead of overwriting it.  [ISC-Bugs #20969]
+
+- Modify the determination of the default TTL to use for DDNS updates.
+  The user may still configure the ttl via ddns-ttl.  The default for
+  both v4 and v6 is now 1/2 the (preferred) lease time with a limit.  The
+  previous defaults (1/2 lease time without a limit for v4 and a default
+  value for v6) may be used by defining USE_OLD_DDNS_TTL in site.h
+  [ISC-Bugs #21126]
 
                        Changes since 4.2.0a2
 
index 015f22ea53a5fd5c39f2212c3aecee9219082086..cd7d962ec4bd55c5d557d0be81b4eef15b382902 100644 (file)
@@ -750,6 +750,9 @@ struct lease_state {
 #if !defined (DEFAULT_DDNS_TTL)
 # define DEFAULT_DDNS_TTL 3600
 #endif
+#if !defined (MAX_DEFAULT_DDNS_TTL)
+# define MAX_DEFAULT_DDNS_TTL 3600
+#endif
 
 /* Client option names */
 
index 2238fe7a35d1735ad11fd61350c226d4277c4afe..91a5d98f10426938a281e86b8b07f6c44752d25e 100644 (file)
    traces. */
 
 /* #define TRACING */
+
+/* Define this if you want the server to use the previous behavior
+   when determining the DDNS TTL.  If the user has specified a ddns-ttl
+   option that is used to detemine the ttl.  (If the user specifies
+   an option that references the lease structure it is only usable
+   for v4.  In that case v6 will use the default.) Otherwise when
+   defined the defaults are: v4 - 1/2 the lease time,
+   v6 - DEFAULT_DDNS_TTL.  When undefined the defaults are 1/2 the
+   (preferred) lease time for both but with a cap on the maximum. */
+
+/* #define USE_OLD_DDNS_TTL */
+
index 904c98e2b1c51c8d2a2b023f6bb0ddb7ba9850f9..74e7c4409c9783da32224ea648a8a10282c41ddf 100644 (file)
@@ -3,8 +3,8 @@
    Dynamic DNS updates. */
 
 /*
- * Copyright (c) 2004-2007,2009-2010
- *                             by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 2000-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -329,18 +329,50 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old,
 
        /*
         * Compute the RR TTL.
+        *
+        * We have two ways of computing the TTL.
+        * The old behavior was to allow for the customer to set up
+        * the option or to default things.  For v4 this was 1/2
+        * of the lease time, for v6 this was DEFAULT_DDNS_TTL.
+        * The new behavior continues to allow the customer to set
+        * up an option but the defaults are a little different.
+        * We now use 1/2 of the (preferred) lease time for both
+        * v4 and v6 and cap them at a maximum value. 
+        * If the customer chooses to use an experession that references
+        * part of the lease the v6 value will be the default as there
+        * isn't a lease available for v6.
         */
+
        ddns_ttl = DEFAULT_DDNS_TTL;
+       if (lease != NULL) {
+               if (lease->ends <= cur_time) {
+                       ddns_ttl = 0;
+               } else {
+                       ddns_ttl = (lease->ends - cur_time)/2;
+               }
+       }
+#ifndef USE_OLD_DDNS_TTL
+       else if (lease6 != NULL) {
+               ddns_ttl = lease6->prefer/2;
+       }
+
+       if (ddns_ttl > MAX_DEFAULT_DDNS_TTL) {
+               ddns_ttl = MAX_DEFAULT_DDNS_TTL;
+       }
+#endif                 
+
        if ((oc = lookup_option(&server_universe, options, SV_DDNS_TTL))) {
                if (evaluate_option_cache(&d1, packet, lease, NULL,
-                                         packet->options, options, scope,
-                                         oc, MDL)) {
+                                         packet->options, options,
+                                         scope, oc, MDL)) {
                        if (d1.len == sizeof (u_int32_t))
-                               ddns_cb->ttl = getULong (d1.data);
+                               ddns_ttl = getULong (d1.data);
                        data_string_forget (&d1, MDL);
                }
        }
 
+       ddns_cb->ttl = ddns_ttl;
+
        /*
         * Compute the reverse IP name, starting with the domain name.
         */
index ff42315902e5c15f9924c858ffb6db8bb20722d4..5297175b7ae549ab4fddd3fd11bc22790d53ef7b 100644 (file)
@@ -72,7 +72,6 @@ char std_nsupdate [] = "                                                  \n\
 option server.ddns-hostname =                                              \n\
   pick (option fqdn.hostname, option host-name);                           \n\
 option server.ddns-domainname =        config-option domain-name;                  \n\
-option server.ddns-ttl = encode-int(lease-time / 2, 32);                   \n\
 option server.ddns-rev-domainname = \"in-addr.arpa.\";";
 
 /* This is the old-style name service updater that is executed