From 89d03d4715120fd0c968775bf0724b5a2a647539 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 28 May 2001 05:17:05 +0000 Subject: [PATCH] Redo: 839. [func] Dump packets for which there was no view or that the class could not be determined to category "unmatched". --- CHANGES | 2 +- bin/named/client.c | 37 +++++++++---------------------- bin/named/include/named/globals.h | 3 +-- bin/named/include/named/log.h | 9 +++++++- bin/named/log.c | 12 +++++++++- bin/named/logconf.c | 11 ++++++++- bin/named/main.c | 7 ++---- bin/named/server.c | 4 +++- doc/arm/Bv9ARM-book.xml | 11 ++++++++- 9 files changed, 56 insertions(+), 40 deletions(-) diff --git a/CHANGES b/CHANGES index 258a3c87a0..7b564627e1 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,5 @@ 839. [func] Dump packets for which there was no view or that the - class could not be determined to file, (-e filename). + class could not be determined to category "unmatched". 838. [port] UnixWare 7.x.x is now suported by bin/tests/system/ifconfig.sh. diff --git a/bin/named/client.c b/bin/named/client.c index f4211c6fed..46b2f4fe9c 100644 --- a/bin/named/client.c +++ b/bin/named/client.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: client.c,v 1.168 2001/05/25 07:39:45 marka Exp $ */ +/* $Id: client.c,v 1.169 2001/05/28 05:16:54 marka Exp $ */ #include @@ -2258,34 +2258,17 @@ ns_client_aclmsg(const char *msg, dns_name_t *name, dns_rdataclass_t rdclass, (void)snprintf(buf, len, "%s '%s/%s'", msg, namebuf, classbuf); } -static isc_mutex_t dumpmessagemutex; - -static void dumpmessagemutex_init(void) { - (void)isc_mutex_init(&dumpmessagemutex); -} - static void ns_client_dumpmessage(ns_client_t *client, const char *reason) { - static isc_once_t once = ISC_ONCE_INIT; - char peerbuf[ISC_SOCKADDR_FORMATSIZE]; isc_buffer_t buffer; char *buf = NULL; int len = 1024; isc_result_t result; - FILE *fd = NULL; - if (ns_g_examinelog == NULL) - return; - - ns_client_name(client, peerbuf, sizeof(peerbuf)); - - isc_once_do(&once, dumpmessagemutex_init); - - LOCK(&dumpmessagemutex); - - result = isc_stdio_open(ns_g_examinelog, "a", &fd); - if (result != ISC_R_SUCCESS) - goto unlock; + /* + * Note these a multiline debug messages. We want a newline + * to appear in the log after each message. + */ do { buf = isc_mem_get(client->mctx, len); @@ -2299,13 +2282,13 @@ ns_client_dumpmessage(ns_client_t *client, const char *reason) { isc_mem_put(client->mctx, buf, len); len += 1024; } else if (result == ISC_R_SUCCESS) - fprintf(fd, "\nclient %s: %s\n%.*s\n", peerbuf, reason, - (int)isc_buffer_usedlength(&buffer), buf); + ns_client_log(client, NS_LOGCATEGORY_UNMATCHED, + NS_LOGMODULE_CLIENT, ISC_LOG_INFO, + "%s\n%.*s", reason, + (int)isc_buffer_usedlength(&buffer), + buf); } while (result == ISC_R_NOSPACE); if (buf != NULL) isc_mem_put(client->mctx, buf, len); - (void)isc_stdio_close(fd); - unlock: - UNLOCK(&dumpmessagemutex); } diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index 0c40680f50..dcc7e9d29b 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: globals.h,v 1.55 2001/05/25 07:39:48 marka Exp $ */ +/* $Id: globals.h,v 1.56 2001/05/28 05:17:01 marka Exp $ */ #ifndef NAMED_GLOBALS_H #define NAMED_GLOBALS_H 1 @@ -104,7 +104,6 @@ EXTERN const char * ns_g_defaultpidfile INIT(NS_LOCALSTATEDIR EXTERN const char * lwresd_g_defaultpidfile INIT(NS_LOCALSTATEDIR "/run/lwresd.pid"); EXTERN const char * ns_g_username INIT(NULL); -EXTERN const char * ns_g_examinelog INIT(NULL); #undef EXTERN #undef INIT diff --git a/bin/named/include/named/log.h b/bin/named/include/named/log.h index 2a867f590d..8166a25f07 100644 --- a/bin/named/include/named/log.h +++ b/bin/named/include/named/log.h @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.h,v 1.18 2001/03/27 00:44:38 bwelling Exp $ */ +/* $Id: log.h,v 1.19 2001/05/28 05:17:02 marka Exp $ */ #ifndef NAMED_LOG_H #define NAMED_LOG_H 1 @@ -32,6 +32,7 @@ #define NS_LOGCATEGORY_NETWORK (&ns_g_categories[2]) #define NS_LOGCATEGORY_UPDATE (&ns_g_categories[3]) #define NS_LOGCATEGORY_QUERIES (&ns_g_categories[4]) +#define NS_LOGCATEGORY_UNMATCHED (&ns_g_categories[5]) /* * Backwards compatibility. @@ -82,6 +83,12 @@ ns_log_setdefaultcategory(isc_logconfig_t *lcfg); * Set up "category default" to go to the right places. */ +isc_result_t +ns_log_setunmatchedcategory(isc_logconfig_t *lcfg); +/* + * Set up "category unmatched" to go to the right places. + */ + void ns_log_shutdown(void); diff --git a/bin/named/log.c b/bin/named/log.c index 8a0344a3be..e1fbcd6407 100644 --- a/bin/named/log.c +++ b/bin/named/log.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: log.c,v 1.31 2001/03/27 00:44:31 bwelling Exp $ */ +/* $Id: log.c,v 1.32 2001/05/28 05:16:55 marka Exp $ */ #include @@ -35,6 +35,7 @@ static isc_logcategory_t categories[] = { { "network", 0 }, { "update", 0 }, { "queries", 0 }, + { "unmatched", 0 }, { NULL, 0 } }; @@ -181,6 +182,15 @@ ns_log_setdefaultcategory(isc_logconfig_t *lcfg) { return (result); } +isc_result_t +ns_log_setunmatchedcategory(isc_logconfig_t *lcfg) { + isc_result_t result; + + result = isc_log_usechannel(lcfg, "null", + NS_LOGCATEGORY_UNMATCHED, NULL); + return (result); +} + void ns_log_shutdown(void) { isc_log_destroy(&ns_g_lctx); diff --git a/bin/named/logconf.c b/bin/named/logconf.c index 0198dea8a9..4fab9dda78 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: logconf.c,v 1.29 2001/04/26 02:38:08 tale Exp $ */ +/* $Id: logconf.c,v 1.30 2001/05/28 05:16:57 marka Exp $ */ #include @@ -245,6 +245,7 @@ ns_log_configure(isc_logconfig_t *logconf, cfg_obj_t *logstmt) { cfg_obj_t *categories = NULL; cfg_listelt_t *element; isc_boolean_t default_set = ISC_FALSE; + isc_boolean_t unmatched_set = ISC_FALSE; CHECK(ns_log_setdefaultchannels(logconf)); @@ -269,11 +270,19 @@ ns_log_configure(isc_logconfig_t *logconf, cfg_obj_t *logstmt) { if (strcmp(cfg_obj_asstring(catname), "default")) default_set = ISC_TRUE; } + if (!unmatched_set) { + cfg_obj_t *catname = cfg_tuple_get(category, "name"); + if (strcmp(cfg_obj_asstring(catname), "unmatched")) + unmatched_set = ISC_TRUE; + } } if (!default_set) CHECK(ns_log_setdefaultcategory(logconf)); + if (!unmatched_set) + CHECK(ns_log_setunmatchedcategory(logconf)); + return (ISC_R_SUCCESS); cleanup: diff --git a/bin/named/main.c b/bin/named/main.c index fc2698a1fb..9a0d3d42b9 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: main.c,v 1.110 2001/05/25 07:39:46 marka Exp $ */ +/* $Id: main.c,v 1.111 2001/05/28 05:16:58 marka Exp $ */ #include @@ -270,7 +270,7 @@ parse_command_line(int argc, char *argv[]) { isc_commandline_errprint = ISC_FALSE; while ((ch = isc_commandline_parse(argc, argv, - "c:C:d:e:fgi:ln:N:p:P:st:u:vx:")) != + "c:C:d:fgi:ln:N:p:P:st:u:vx:")) != -1) { switch (ch) { case 'c': @@ -290,9 +290,6 @@ parse_command_line(int argc, char *argv[]) { ns_g_debuglevel = parse_int(isc_commandline_argument, "debug level"); break; - case 'e': - ns_g_examinelog = isc_commandline_argument; - break; case 'f': ns_g_foreground = ISC_TRUE; break; diff --git a/bin/named/server.c b/bin/named/server.c index c52fcf3282..853de64cf1 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -15,7 +15,7 @@ * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: server.c,v 1.326 2001/05/14 20:44:10 bwelling Exp $ */ +/* $Id: server.c,v 1.327 2001/05/28 05:17:00 marka Exp $ */ #include @@ -1929,6 +1929,8 @@ load_configuration(const char *filename, ns_server_t *server, } else { CHECKM(ns_log_setdefaultchannels(logc), "setting up default logging channels"); + CHECKM(ns_log_setunmatchedcategory(logc), + "setting up default 'category unmatched'"); CHECKM(ns_log_setdefaultcategory(logc), "setting up default 'category default'"); } diff --git a/doc/arm/Bv9ARM-book.xml b/doc/arm/Bv9ARM-book.xml index 9da73c5ea0..bde6477f4e 100644 --- a/doc/arm/Bv9ARM-book.xml +++ b/doc/arm/Bv9ARM-book.xml @@ -2,7 +2,7 @@ - + BIND 9 Administrator Reference Manual @@ -2271,6 +2271,7 @@ as many channels and categories as are wanted. If there is no logging logging { + category "unmatched" { "null"; }; category "default" { "default_syslog"; "default_debug"; }; }; @@ -2537,6 +2538,14 @@ lookups performed on behalf of clients by a caching name server. Processing of client requests. +unmatched +Messages that named was unable to determine the +class of or for which there was no matching view. +A one line summary is also logged to the client category. +This category is best sent to a file or stderr, by default it is sent to +the null channel. + + network Network operations.