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

index ea0d2498a807446cf0c50e37e3af8d12efb464af..6a38dc70d5d015058bcc28eff94a3dbfefbeab73 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 b196147e0e11294d0cfcc31ae3f812c5548e2a4d..10a2c03c371c552cc262b859a007ff632a2d4e13 100644 (file)
@@ -3,7 +3,9 @@
    Dynamic DNS updates. */
 
 /*
- * Copyright (c) 2004-2007,2009 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
@@ -328,18 +330,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 f29e431bbafba9694339cc20b75dae9976c8153e..43d9efaab757cdaa2c0220265154418bd9aaf2d0 100644 (file)
@@ -3,7 +3,7 @@
    DHCP Server Daemon. */
 
 /*
- * Copyright (c) 2004-2009 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 1996-2003 by Internet Software Consortium
  *
  * Permission to use, copy, modify, and distribute this software for any
@@ -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