From e3c0d25e1257609428cf46d15c90f7de5175c785 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 31 Aug 2011 15:20:19 +0000 Subject: [PATCH 1/4] file rbt_test.c was added on branch rt25419b on 2012-02-07 00:44:16 +0000 From 2c70be8eb05247d451a5902403189066df00355f Mon Sep 17 00:00:00 2001 From: cvs2git Date: Fri, 3 Feb 2012 13:16:20 +0000 Subject: [PATCH 2/4] This commit was manufactured by cvs2git to create branch 'rt27173'. From 0615e540d691192e17c898c019a69a2a5b9dfaf7 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Mon, 6 Feb 2012 23:00:45 +0000 Subject: [PATCH 3/4] file named.conf was added on branch rt25419b on 2012-02-07 00:44:13 +0000 From 8a4689070a0b13935822e1bb7138d1d2f8ce237b Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 22 Feb 2012 05:03:39 +0000 Subject: [PATCH 4/4] dns_message_logpacket --- lib/dns/include/dns/message.h | 12 +++++++++- lib/dns/message.c | 42 ++++++++++++++++++++++++++++++++- lib/dns/resolver.c | 44 ++++------------------------------- lib/dns/xfrin.c | 11 ++++++++- 4 files changed, 66 insertions(+), 43 deletions(-) diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 25aceb1309..1c6a6362b3 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.h,v 1.132 2010/03/04 23:50:34 tbox Exp $ */ +/* $Id: message.h,v 1.132.528.1 2012/02/22 05:03:39 marka Exp $ */ #ifndef DNS_MESSAGE_H #define DNS_MESSAGE_H 1 @@ -1349,6 +1349,16 @@ dns_message_gettimeadjust(dns_message_t *msg); * Requires: *\li msg be a valid message. */ +void +dns_message_logpacket(dns_message_t *message, const char *description, + isc_logcategory_t *category, isc_logmodule_t *module, + int level, isc_mem_t *mctx); +/*%< + * Log 'message' at the specified logging parameters. + * 'description' will be emitted at the start of the message and will + * normally end with a newline. + */ + ISC_LANG_ENDDECLS diff --git a/lib/dns/message.c b/lib/dns/message.c index 3d248ee28d..c6319220fe 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.c,v 1.257 2011/06/08 22:13:50 each Exp $ */ +/* $Id: message.c,v 1.257.214.1 2012/02/22 05:03:38 marka Exp $ */ /*! \file */ @@ -3449,3 +3449,43 @@ dns_opcode_totext(dns_opcode_t opcode, isc_buffer_t *target) { isc_buffer_putstr(target, opcodetext[opcode]); return (ISC_R_SUCCESS); } + +void +dns_message_logpacket(dns_message_t *message, const char *description, + isc_logcategory_t *category, isc_logmodule_t *module, + int level, isc_mem_t *mctx) +{ + isc_buffer_t buffer; + char *buf = NULL; + int len = 1024; + isc_result_t result; + + if (! isc_log_wouldlog(dns_lctx, level)) + return; + + /* + * Note that these are multiline debug messages. We want a newline + * to appear in the log after each message. + */ + + do { + buf = isc_mem_get(mctx, len); + if (buf == NULL) + break; + isc_buffer_init(&buffer, buf, len); + result = dns_message_totext(message, &dns_master_style_debug, + 0, &buffer); + if (result == ISC_R_NOSPACE) { + isc_mem_put(mctx, buf, len); + len += 1024; + } else if (result == ISC_R_SUCCESS) + isc_log_write(dns_lctx, category, module, level, + "%s%.*s", description, + (int)isc_buffer_usedlength(&buffer), + buf); + } while (result == ISC_R_NOSPACE); + + if (buf != NULL) + isc_mem_put(mctx, buf, len); +} + diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index cf647f9ca8..7967f047bd 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: resolver.c,v 1.448 2012/02/14 23:47:15 tbox Exp $ */ +/* $Id: resolver.c,v 1.448.8.1 2012/02/22 05:03:38 marka Exp $ */ /*! \file */ @@ -6463,43 +6463,6 @@ log_nsid(dns_rdataset_t *opt, resquery_t *query, int level, isc_mem_t *mctx) return (ISC_R_SUCCESS); } -static void -log_packet(dns_message_t *message, int level, isc_mem_t *mctx) { - isc_buffer_t buffer; - char *buf = NULL; - int len = 1024; - isc_result_t result; - - if (! isc_log_wouldlog(dns_lctx, level)) - return; - - /* - * Note that these are multiline debug messages. We want a newline - * to appear in the log after each message. - */ - - do { - buf = isc_mem_get(mctx, len); - if (buf == NULL) - break; - isc_buffer_init(&buffer, buf, len); - result = dns_message_totext(message, &dns_master_style_debug, - 0, &buffer); - if (result == ISC_R_NOSPACE) { - isc_mem_put(mctx, buf, len); - len += 1024; - } else if (result == ISC_R_SUCCESS) - isc_log_write(dns_lctx, DNS_LOGCATEGORY_RESOLVER, - DNS_LOGMODULE_RESOLVER, level, - "received packet:\n%.*s", - (int)isc_buffer_usedlength(&buffer), - buf); - } while (result == ISC_R_NOSPACE); - - if (buf != NULL) - isc_mem_put(mctx, buf, len); -} - static isc_boolean_t iscname(fetchctx_t *fctx) { isc_result_t result; @@ -6734,11 +6697,12 @@ resquery_response(isc_task_t *task, isc_event_t *event) { } } - /* * Log the incoming packet. */ - log_packet(message, ISC_LOG_DEBUG(10), fctx->res->mctx); + dns_message_logpacket(message, "received packet:\n", + DNS_LOGCATEGORY_RESOLVER, DNS_LOGMODULE_RESOLVER, + ISC_LOG_DEBUG(10), fctx->res->mctx); /* * Did we request NSID? If so, and if the response contains diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index b53e720e98..17db94924a 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: xfrin.c,v 1.172 2011/12/22 07:32:41 each Exp $ */ +/* $Id: xfrin.c,v 1.172.54.1 2012/02/22 05:03:39 marka Exp $ */ /*! \file */ @@ -1240,6 +1240,15 @@ xfrin_recv_done(isc_task_t *task, isc_event_t *ev) { result = dns_message_parse(msg, &tcpmsg->buffer, DNS_MESSAGEPARSE_PRESERVEORDER); + if (result == ISC_R_SUCCESS) + dns_message_logpacket(msg, "received message:\n", + DNS_LOGCATEGORY_XFER_IN, + DNS_LOGMODULE_XFER_IN, + ISC_LOG_DEBUG(10), xfr->mctx); + else + xfrin_log(xfr, ISC_LOG_DEBUG(10), "dns_message_parse: %s", + dns_result_totext(result)); + if (result != ISC_R_SUCCESS || msg->rcode != dns_rcode_noerror || (xfr->checkid && msg->id != xfr->id)) { if (result == ISC_R_SUCCESS)