From 9baf6577a57a44b415dbab0045a5f05a2b93e9b6 Mon Sep 17 00:00:00 2001 From: Shawn Routhier Date: Fri, 18 Feb 2011 18:26:46 +0000 Subject: [PATCH] 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] --- RELNOTES | 5 +++++ server/ddns.c | 24 ++++++++++++++++++++---- server/mdb.c | 13 ++++++++++--- 3 files changed, 35 insertions(+), 7 deletions(-) diff --git a/RELNOTES b/RELNOTES index 196829ac7..325482a1a 100644 --- 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;' diff --git a/server/ddns.c b/server/ddns.c index 74e7c4409..59c9c011d 100644 --- a/server/ddns.c +++ b/server/ddns.c @@ -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); } diff --git a/server/mdb.c b/server/mdb.c index 85d0bacd9..c5bf73e9f 100644 --- a/server/mdb.c +++ b/server/mdb.c @@ -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) -- 2.47.3