summaryrefslogtreecommitdiffstats
path: root/contrib/bind9/bin/named/xfrout.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/bind9/bin/named/xfrout.c')
-rw-r--r--contrib/bind9/bin/named/xfrout.c52
1 files changed, 19 insertions, 33 deletions
diff --git a/contrib/bind9/bin/named/xfrout.c b/contrib/bind9/bin/named/xfrout.c
index b036ed1..83c64f2 100644
--- a/contrib/bind9/bin/named/xfrout.c
+++ b/contrib/bind9/bin/named/xfrout.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2004-2010 Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2004-2011 Internet Systems Consortium, Inc. ("ISC")
* Copyright (C) 1999-2003 Internet Software Consortium.
*
* Permission to use, copy, modify, and/or distribute this software for any
@@ -15,7 +15,7 @@
* PERFORMANCE OF THIS SOFTWARE.
*/
-/* $Id: xfrout.c,v 1.139 2010-12-18 01:56:19 each Exp $ */
+/* $Id: xfrout.c,v 1.139.16.3 2011-07-28 04:30:54 marka Exp $ */
#include <config.h>
@@ -28,9 +28,7 @@
#include <dns/db.h>
#include <dns/dbiterator.h>
-#ifdef DLZ
#include <dns/dlz.h>
-#endif
#include <dns/fixedname.h>
#include <dns/journal.h>
#include <dns/message.h>
@@ -752,9 +750,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
char msg[NS_CLIENT_ACLMSGSIZE("zone transfer")];
char keyname[DNS_NAME_FORMATSIZE];
isc_boolean_t is_poll = ISC_FALSE;
-#ifdef DLZ
isc_boolean_t is_dlz = ISC_FALSE;
-#endif
switch (reqtype) {
case dns_rdatatype_axfr:
@@ -806,9 +802,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
result = dns_zt_find(client->view->zonetable, question_name, 0, NULL,
&zone);
- if (result != ISC_R_SUCCESS)
-#ifdef DLZ
- {
+ if (result != ISC_R_SUCCESS) {
/*
* Normal zone table does not have a match.
* Try the DLZ database
@@ -836,10 +830,8 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
goto failure;
}
if (result != ISC_R_SUCCESS)
-#endif
- FAILQ(DNS_R_NOTAUTH, "non-authoritative zone",
- question_name, question_class);
-#ifdef DLZ
+ FAILQ(DNS_R_NOTAUTH, "non-authoritative zone",
+ question_name, question_class);
is_dlz = ISC_TRUE;
/*
* DLZ only support full zone transfer, not incremental
@@ -859,7 +851,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
}
} else {
/* zone table has a match */
-#endif
switch(dns_zone_gettype(zone)) {
case dns_zone_master:
case dns_zone_slave:
@@ -870,9 +861,7 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
}
CHECK(dns_zone_getdb(zone, &db));
dns_db_currentversion(db, &ver);
-#ifdef DLZ
}
-#endif
xfrout_log1(client, question_name, question_class, ISC_LOG_DEBUG(6),
"%s question section OK", mnemonic);
@@ -926,22 +915,15 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
"%s authority section OK", mnemonic);
/*
- * Decide whether to allow this transfer.
- */
-#ifdef DLZ
- /*
- * if not a DLZ zone decide whether to allow this transfer.
+ * If not a DLZ zone, decide whether to allow this transfer.
*/
if (!is_dlz) {
-#endif
ns_client_aclmsg("zone transfer", question_name, reqtype,
client->view->rdclass, msg, sizeof(msg));
CHECK(ns_client_checkacl(client, NULL, msg,
dns_zone_getxfracl(zone),
ISC_TRUE, ISC_LOG_ERROR));
-#ifdef DLZ
}
-#endif
/*
* AXFR over UDP is not possible.
@@ -965,10 +947,9 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
/*
* Get a dynamically allocated copy of the current SOA.
*/
-#ifdef DLZ
if (is_dlz)
dns_db_currentversion(db, &ver);
-#endif
+
CHECK(dns_db_createsoatuple(db, ver, mctx, DNS_DIFFOP_EXISTS,
&current_soa_tuple));
@@ -1054,7 +1035,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
-#ifdef DLZ
if (is_dlz)
CHECK(xfrout_ctx_create(mctx, client, request->id,
question_name, reqtype, question_class,
@@ -1067,7 +1047,6 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
ISC_TRUE : ISC_FALSE,
&xfr));
else
-#endif
CHECK(xfrout_ctx_create(mctx, client, request->id,
question_name, reqtype, question_class,
zone, db, ver, quota, stream,
@@ -1085,9 +1064,9 @@ ns_xfr_start(ns_client_t *client, dns_rdatatype_t reqtype) {
CHECK(xfr->stream->methods->first(xfr->stream));
- if (xfr->tsigkey != NULL) {
+ if (xfr->tsigkey != NULL)
dns_name_format(&xfr->tsigkey->name, keyname, sizeof(keyname));
- } else
+ else
keyname[0] = '\0';
if (is_poll)
xfrout_log1(client, question_name, question_class,
@@ -1157,7 +1136,8 @@ xfrout_ctx_create(isc_mem_t *mctx, ns_client_t *client, unsigned int id,
xfr = isc_mem_get(mctx, sizeof(*xfr));
if (xfr == NULL)
return (ISC_R_NOMEMORY);
- xfr->mctx = mctx;
+ xfr->mctx = NULL;
+ isc_mem_attach(mctx, &xfr->mctx);
xfr->client = NULL;
ns_client_attach(client, &xfr->client);
xfr->id = id;
@@ -1531,6 +1511,7 @@ sendstream(xfrout_ctx_t *xfr) {
static void
xfrout_ctx_destroy(xfrout_ctx_t **xfrp) {
xfrout_ctx_t *xfr = *xfrp;
+ ns_client_t *client = NULL;
INSIST(xfr->sends == 0);
@@ -1554,9 +1535,14 @@ xfrout_ctx_destroy(xfrout_ctx_t **xfrp) {
if (xfr->db != NULL)
dns_db_detach(&xfr->db);
+ /*
+ * We want to detch the client after we have released the memory
+ * context as ns_client_detach checks the memory reference count.
+ */
+ ns_client_attach(xfr->client, &client);
ns_client_detach(&xfr->client);
-
- isc_mem_put(xfr->mctx, xfr, sizeof(*xfr));
+ isc_mem_putanddetach(&xfr->mctx, xfr, sizeof(*xfr));
+ ns_client_detach(&client);
*xfrp = NULL;
}
OpenPOWER on IntegriCloud