]> git.ipfire.org Git - thirdparty/dhcp.git/commitdiff
Handle some DDNS corner cases better. Maintain the DDNS transaction
authorShawn Routhier <sar@isc.org>
Fri, 18 Feb 2011 18:26:46 +0000 (18:26 +0000)
committerShawn Routhier <sar@isc.org>
Fri, 18 Feb 2011 18:26:46 +0000 (18:26 +0000)
information when updating a lease and cancel any existing transactions
when removing the ddns information.
[ISC-Bugs #23103]

RELNOTES
server/ddns.c
server/mdb.c

index 196829ac7cf16110acfec993daf542ad1777c7f9..325482a1a7cb3949d7a55d4dd9bc0a9d703f672a 100644 (file)
--- a/RELNOTES
+++ b/RELNOTES
@@ -50,6 +50,11 @@ work on other platforms. Please report any problems and suggested fixes to
                                ip6-address, array of ip-address };
        option 6rd 16 10 2001:: 1.2.3.4, 5.6.7.8;
 
+- Handle some DDNS corner cases better.  Maintain the DDNS transaction
+  information when updating a lease and cancel any existing transactions
+  when removing the ddns information.  
+  [ISC-Bugs #23103]
+
                        Changes since 4.2.0
 
 - 'get-host-names true;' now also works even if 'use-host-decl-names true;'
index 74e7c4409c9783da32224ea648a8a10282c41ddf..59c9c011d60e30b05251a02f44d43128bb0e9d33 100644 (file)
@@ -3,7 +3,7 @@
    Dynamic DNS updates. */
 
 /*
- * Copyright (c) 2009-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2009-2011 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 2004-2007 by Internet Systems Consortium, Inc. ("ISC")
  * Copyright (c) 2000-2003 by Internet Software Consortium
  *
@@ -108,7 +108,7 @@ ddns_updates(struct packet *packet, struct lease *lease, struct lease *old,
                }
        } else if (lease6 != NULL) {
                if ((old6 != NULL) && (old6->ddns_cb != NULL)) {
-                       ddns_cancel(old->ddns_cb);
+                       ddns_cancel(old6->ddns_cb);
                        old6->ddns_cb = NULL;
                }
        } else {
@@ -1303,9 +1303,24 @@ ddns_removals(struct lease    *lease,
        isc_result_t rcode, execute_add = ISC_R_FAILURE;
        struct binding_scope **scope = NULL;
        int result = 0;
-       dhcp_ddns_cb_t        *ddns_cb;
+       dhcp_ddns_cb_t        *ddns_cb = NULL;
        struct data_string     leaseid;
 
+       /*
+        * Cancel any outstanding requests.  When called
+        * from within the DNS code we probably will have
+        * already done the cancel but if called from outside
+        * - for example as part of a lease expiry - we won't.
+        */
+       if ((lease != NULL) && (lease->ddns_cb != NULL)) {
+               ddns_cancel(lease->ddns_cb);
+               lease->ddns_cb = NULL;
+       } else if ((lease6 != NULL) && (lease6->ddns_cb != NULL)) {
+               ddns_cancel(lease6->ddns_cb);
+               lease6->ddns_cb = NULL;
+       } else
+               goto cleanup;
+
        /* allocate our control block */
        ddns_cb = ddns_cb_alloc(MDL);
        if (ddns_cb == NULL) {
@@ -1466,7 +1481,8 @@ ddns_removals(struct lease    *lease,
         * we allocated here.
         */
        ddns_fwd_srv_connector(lease, lease6, scope, add_ddns_cb, execute_add);
-       ddns_cb_free(ddns_cb, MDL);
+       if (ddns_cb != NULL) 
+               ddns_cb_free(ddns_cb, MDL);
 
        return(result);
 }
index 85d0bacd9817e79a90684e0c25bb9f0bc6b2bb64..c5bf73e9f33fc624ff4d66ef13f855cfb0089592 100644 (file)
@@ -3,7 +3,7 @@
    Server-specific in-memory database support. */
 
 /*
- * Copyright (c) 2004-2010 by Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (c) 2004-2011 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
@@ -1225,8 +1225,15 @@ int supersede_lease (comp, lease, commit, propogate, pimmediate)
        comp->ends = lease->ends;
        comp->next_binding_state = lease->next_binding_state;
 
-       /* move the ddns control block information */
-       comp->ddns_cb = lease->ddns_cb;
+       /*
+        * If we have a control block pointer copy it in.
+        * We don't zero out an older ponter as it is still
+        * in use.  We shouldn't need to overwrite an
+        * old pointer with a new one as the old transaction
+        * should have been cancelled before getting here.
+        */
+       if (lease->ddns_cb != NULL)
+               comp->ddns_cb = lease->ddns_cb;
 
       just_move_it:
 #if defined (FAILOVER_PROTOCOL)