From 091d738c7257451bf68a78f8070639aea04a70e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Sur=C3=BD?= Date: Wed, 14 Aug 2024 13:25:50 +0200 Subject: [PATCH] Convert all categories and modules into static lists Remove the complicated mechanism that could be (in theory) used by external libraries to register new categories and modules with statically defined lists in . This is similar to what we have done for result codes. All the libraries are now internal to BIND 9, so we don't need to provide a mechanism to register extra categories and modules. --- bin/check/check-tool.c | 35 +- bin/check/named-checkconf.c | 1 - bin/check/named-checkzone.c | 1 - bin/delv/delv.c | 31 +- bin/dig/dighost.c | 6 +- bin/dnssec/dnssec-cds.c | 2 +- bin/dnssec/dnssec-dsfromkey.c | 2 +- bin/dnssec/dnssec-importkey.c | 2 +- bin/dnssec/dnssec-keyfromlabel.c | 2 +- bin/dnssec/dnssec-keygen.c | 2 +- bin/dnssec/dnssec-settime.c | 2 +- bin/dnssec/dnssec-signzone.c | 2 +- bin/dnssec/dnssec-verify.c | 2 +- bin/dnssec/dnssectool.c | 9 +- bin/named/dlz_dlopen_driver.c | 2 +- bin/named/fuzz.c | 3 +- bin/named/include/named/globals.h | 5 +- bin/named/include/named/log.h | 14 - bin/named/log.c | 49 +-- bin/named/logconf.c | 9 +- bin/named/main.c | 10 +- bin/named/zoneconf.c | 2 +- bin/nsupdate/nsupdate.c | 6 +- bin/plugins/filter-a.c | 2 - bin/plugins/filter-aaaa.c | 2 - bin/rndc/rndc.c | 3 +- bin/tests/system/dyndb/driver/log.c | 3 +- bin/tests/system/dyndb/driver/log.h | 3 +- bin/tests/system/hooks/driver/test-async.c | 1 - bin/tests/system/makejournal.c | 20 +- bin/tests/system/rsabigexponent/bigkey.c | 2 +- bin/tools/named-journalprint.c | 8 +- doc/dev/dev.md | 2 +- doc/misc/cfg_test.c | 6 +- lib/dns/Makefile.am | 2 - lib/dns/adb.c | 4 +- lib/dns/cache.c | 2 +- lib/dns/callbacks.c | 2 +- lib/dns/db.c | 4 +- lib/dns/diff.c | 2 +- lib/dns/dispatch.c | 2 +- lib/dns/dlz.c | 2 +- lib/dns/dnssec.c | 4 +- lib/dns/dnstap.c | 1 - lib/dns/dst_api.c | 2 +- lib/dns/dst_internal.h | 2 +- lib/dns/dst_openssl.h | 5 +- lib/dns/dst_parse.c | 2 +- lib/dns/dyndb.c | 2 +- lib/dns/geoip2.c | 8 +- lib/dns/gssapictx.c | 3 +- lib/dns/include/dns/log.h | 102 ----- lib/dns/include/dns/message.h | 7 +- lib/dns/include/dns/resolver.h | 4 +- lib/dns/include/dns/zone.h | 4 +- lib/dns/include/dst/dst.h | 11 +- lib/dns/journal.c | 3 +- lib/dns/kasp.c | 1 - lib/dns/keymgr.c | 2 +- lib/dns/log.c | 60 --- lib/dns/masterdump.c | 3 +- lib/dns/message.c | 21 +- lib/dns/nta.c | 1 - lib/dns/openssl_link.c | 3 +- lib/dns/qp.c | 2 +- lib/dns/qpcache.c | 6 +- lib/dns/qpzone.c | 2 +- lib/dns/rbt-cachedb.c | 23 +- lib/dns/rbt-zonedb.c | 2 +- lib/dns/rbt.c | 12 +- lib/dns/rbtdb.c | 2 +- lib/dns/request.c | 2 +- lib/dns/resolver.c | 11 +- lib/dns/rootns.c | 2 +- lib/dns/rpz.c | 2 +- lib/dns/rrl.c | 2 +- lib/dns/sdlz.c | 1 - lib/dns/ssu_external.c | 2 +- lib/dns/stats.c | 2 +- lib/dns/tkey.c | 2 +- lib/dns/tsig.c | 2 +- lib/dns/update.c | 1 - lib/dns/validator.c | 14 +- lib/dns/xfrin.c | 9 +- lib/dns/zone.c | 6 +- lib/dns/zoneverify.c | 1 - lib/dns/zt.c | 2 +- lib/isc/backtrace.c | 4 +- lib/isc/include/isc/backtrace.h | 3 +- lib/isc/include/isc/log.h | 264 +++++++------ lib/isc/include/isc/tls.h | 3 +- lib/isc/include/isc/types.h | 3 - lib/isc/log.c | 416 ++++++++------------- lib/isc/tls.c | 9 +- lib/isccfg/Makefile.am | 2 - lib/isccfg/aclconf.c | 2 +- lib/isccfg/check.c | 3 +- lib/isccfg/include/isccfg/log.h | 44 --- lib/isccfg/kaspconf.c | 2 +- lib/isccfg/log.c | 36 -- lib/isccfg/namedconf.c | 2 +- lib/isccfg/parser.c | 1 - lib/ns/Makefile.am | 2 - lib/ns/client.c | 10 +- lib/ns/hooks.c | 1 - lib/ns/include/ns/client.h | 8 +- lib/ns/include/ns/log.h | 61 --- lib/ns/interfacemgr.c | 2 +- lib/ns/listenlist.c | 2 +- lib/ns/log.c | 53 --- lib/ns/notify.c | 1 - lib/ns/query.c | 10 +- lib/ns/update.c | 2 +- lib/ns/xfrout.c | 2 +- tests/bench/qpmulti.c | 5 +- tests/dns/qpmulti_test.c | 5 +- tests/dns/rbt_test.c | 2 +- tests/isccfg/duration_test.c | 27 +- tests/isccfg/parser_test.c | 28 +- tests/libtest/dns.c | 2 +- tests/libtest/ns.c | 2 +- util/check-categories.sh | 7 +- 122 files changed, 518 insertions(+), 1140 deletions(-) delete mode 100644 lib/dns/include/dns/log.h delete mode 100644 lib/dns/log.c delete mode 100644 lib/isccfg/include/isccfg/log.h delete mode 100644 lib/isccfg/log.c delete mode 100644 lib/ns/include/ns/log.h delete mode 100644 lib/ns/log.c diff --git a/bin/check/check-tool.c b/bin/check/check-tool.c index 503ecb8f42..59a8fd7a2d 100644 --- a/bin/check/check-tool.c +++ b/bin/check/check-tool.c @@ -33,7 +33,6 @@ #include #include #include -#include #include #include #include @@ -43,10 +42,6 @@ #include #include -#include - -#include - #include "check-tool.h" #ifndef CHECK_SIBLING @@ -97,13 +92,6 @@ dns_zoneopt_t zone_options = DNS_ZONEOPT_CHECKNS | DNS_ZONEOPT_CHECKMX | DNS_ZONEOPT_CHECKSVCB | DNS_ZONEOPT_CHECKWILDCARD | DNS_ZONEOPT_WARNMXCNAME | DNS_ZONEOPT_WARNSRVCNAME; -/* - * This needs to match the list in bin/named/log.c. - */ -static isc_logcategory_t categories[] = { { "", 0 }, - { "unmatched", 0 }, - { NULL, 0 } }; - static isc_symtab_t *symtab = NULL; static isc_mem_t *sym_mctx; @@ -550,24 +538,17 @@ checksrv(dns_zone_t *zone, const dns_name_t *name, const dns_name_t *owner) { isc_result_t setup_logging(FILE *errout) { - isc_logdestination_t destination; - isc_logconfig_t *logconfig = NULL; - - isc_log_registercategories(categories); - dns_log_init(); - cfg_log_init(); - ns_log_init(); - - logconfig = isc_logconfig_get(); - destination.file.stream = errout; - destination.file.name = NULL; - destination.file.versions = ISC_LOG_ROLLNEVER; - destination.file.maximum_size = 0; + isc_logconfig_t *logconfig = isc_logconfig_get(); + isc_logdestination_t destination = { + .file.stream = errout, + .file.versions = ISC_LOG_ROLLNEVER, + }; isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, 0); - RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) == - ISC_R_SUCCESS); + RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", + ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL) == ISC_R_SUCCESS); return (ISC_R_SUCCESS); } diff --git a/bin/check/named-checkconf.c b/bin/check/named-checkconf.c index 3ac3c5e1d7..37a827cba6 100644 --- a/bin/check/named-checkconf.c +++ b/bin/check/named-checkconf.c @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/bin/check/named-checkzone.c b/bin/check/named-checkzone.c index 598a524730..f96930d30c 100644 --- a/bin/check/named-checkzone.c +++ b/bin/check/named-checkzone.c @@ -31,7 +31,6 @@ #include #include -#include #include #include #include diff --git a/bin/delv/delv.c b/bin/delv/delv.c index 6627dd01bb..d314970959 100644 --- a/bin/delv/delv.c +++ b/bin/delv/delv.c @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -70,7 +69,6 @@ #include -#include #include #include @@ -286,12 +284,6 @@ warn(const char *format, ...) { fprintf(stderr, "\n"); } -static isc_logcategory_t categories[] = { { "delv", 0 }, { NULL, 0 } }; -#define LOGCATEGORY_DEFAULT (&categories[0]) -#define LOGMODULE_DEFAULT (&modules[0]) - -static isc_logmodule_t modules[] = { { "delv", 0 }, { NULL, 0 } }; - static void delv_log(int level, const char *fmt, ...) ISC_FORMAT_PRINTF(2, 3); @@ -307,8 +299,8 @@ delv_log(int level, const char *fmt, ...) { va_start(ap, fmt); vsnprintf(msgbuf, sizeof(msgbuf), fmt, ap); - isc_log_write(LOGCATEGORY_DEFAULT, LOGMODULE_DEFAULT, level, "%s", - msgbuf); + isc_log_write(DELV_LOGCATEGORY_DEFAULT, DELV_LOGMODULE_DEFAULT, level, + "%s", msgbuf); va_end(ap); } @@ -317,20 +309,13 @@ static int loglevel = 0; static void setup_logging(FILE *errout) { isc_result_t result; - isc_logdestination_t destination; - isc_logconfig_t *logconfig = NULL; int packetlevel = 10; - isc_log_registercategories(categories); - isc_log_registermodules(modules); - dns_log_init(); - cfg_log_init(); - - logconfig = isc_logconfig_get(); - destination.file.stream = errout; - destination.file.name = NULL; - destination.file.versions = ISC_LOG_ROLLNEVER; - destination.file.maximum_size = 0; + isc_logconfig_t *logconfig = isc_logconfig_get(); + isc_logdestination_t destination = { + .file.stream = errout, + .file.versions = ISC_LOG_ROLLNEVER, + }; isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTPREFIX); @@ -339,7 +324,7 @@ setup_logging(FILE *errout) { isc_log_settag(logconfig, ";; "); result = isc_log_usechannel(logconfig, "stderr", - ISC_LOGCATEGORY_DEFAULT, NULL); + ISC_LOGCATEGORY_DEFAULT, ISC_LOGMODULE_ALL); if (result != ISC_R_SUCCESS) { fatal("Couldn't attach to log channel 'stderr'"); } diff --git a/bin/dig/dighost.c b/bin/dig/dighost.c index f3b5b11a6c..36bd07cc43 100644 --- a/bin/dig/dighost.c +++ b/bin/dig/dighost.c @@ -61,7 +61,6 @@ #include #include -#include #include #include #include @@ -1360,10 +1359,9 @@ setup_libs(void) { isc_managers_create(&mctx, 1, &loopmgr, &netmgr); - dns_log_init(); - logconfig = isc_logconfig_get(); - result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL); + result = isc_log_usechannel(logconfig, "default_debug", + ISC_LOGCATEGORY_ALL, ISC_LOGMODULE_ALL); check_result(result, "isc_log_usechannel"); diff --git a/bin/dnssec/dnssec-cds.c b/bin/dnssec/dnssec-cds.c index 6e22896c10..c44875252b 100644 --- a/bin/dnssec/dnssec-cds.c +++ b/bin/dnssec/dnssec-cds.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssec-dsfromkey.c b/bin/dnssec/dnssec-dsfromkey.c index 143a07e0e3..2ffd31b898 100644 --- a/bin/dnssec/dnssec-dsfromkey.c +++ b/bin/dnssec/dnssec-dsfromkey.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssec-importkey.c b/bin/dnssec/dnssec-importkey.c index 1be060d0e1..6fb11b1060 100644 --- a/bin/dnssec/dnssec-importkey.c +++ b/bin/dnssec/dnssec-importkey.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssec-keyfromlabel.c b/bin/dnssec/dnssec-keyfromlabel.c index 4ca9bfbb6b..35dacc3f31 100644 --- a/bin/dnssec/dnssec-keyfromlabel.c +++ b/bin/dnssec/dnssec-keyfromlabel.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssec-keygen.c b/bin/dnssec/dnssec-keygen.c index 75905ec108..5522662994 100644 --- a/bin/dnssec/dnssec-keygen.c +++ b/bin/dnssec/dnssec-keygen.c @@ -39,6 +39,7 @@ #include #include #include +#include #include #include #include @@ -49,7 +50,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssec-settime.c b/bin/dnssec/dnssec-settime.c index 46431f448e..6c83ee5272 100644 --- a/bin/dnssec/dnssec-settime.c +++ b/bin/dnssec/dnssec-settime.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,6 @@ #include #include -#include #include diff --git a/bin/dnssec/dnssec-signzone.c b/bin/dnssec/dnssec-signzone.c index 17382033f9..1dc09d57bc 100644 --- a/bin/dnssec/dnssec-signzone.c +++ b/bin/dnssec/dnssec-signzone.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -70,7 +71,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssec-verify.c b/bin/dnssec/dnssec-verify.c index 4c3504e34e..45c75d3531 100644 --- a/bin/dnssec/dnssec-verify.c +++ b/bin/dnssec/dnssec-verify.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/dnssec/dnssectool.c b/bin/dnssec/dnssectool.c index 5fa03d7979..a34d12685a 100644 --- a/bin/dnssec/dnssectool.c +++ b/bin/dnssec/dnssectool.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,6 @@ #include #include #include -#include #include #include #include @@ -152,8 +152,6 @@ setup_logging(void) { break; } - dns_log_init(); - logconfig = isc_logconfig_get(); isc_log_settag(logconfig, program); @@ -172,8 +170,9 @@ setup_logging(void) { &destination, ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); - RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) == - ISC_R_SUCCESS); + RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", + ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL) == ISC_R_SUCCESS); } static isc_stdtime_t diff --git a/bin/named/dlz_dlopen_driver.c b/bin/named/dlz_dlopen_driver.c index eedfceec26..21d1c30e3e 100644 --- a/bin/named/dlz_dlopen_driver.c +++ b/bin/named/dlz_dlopen_driver.c @@ -17,13 +17,13 @@ #include #include +#include #include #include #include #include #include -#include #include #include diff --git a/bin/named/fuzz.c b/bin/named/fuzz.c index b011aae095..517a696cc0 100644 --- a/bin/named/fuzz.c +++ b/bin/named/fuzz.c @@ -26,13 +26,12 @@ #include #include +#include #include #include #include #include -#include - #include #include #include diff --git a/bin/named/include/named/globals.h b/bin/named/include/named/globals.h index 5d49d0da77..6b978d1eb8 100644 --- a/bin/named/include/named/globals.h +++ b/bin/named/include/named/globals.h @@ -86,9 +86,8 @@ EXTERN named_server_t *named_g_server INIT(NULL); /* * Logging. */ -EXTERN isc_logcategory_t *named_g_categories INIT(NULL); -EXTERN isc_logmodule_t *named_g_modules INIT(NULL); -EXTERN unsigned int named_g_debuglevel INIT(0); +EXTERN bool named_g_logging INIT(false); +EXTERN unsigned int named_g_debuglevel INIT(0); /* * Current configuration information. diff --git a/bin/named/include/named/log.h b/bin/named/include/named/log.h index b6045bd979..1008dd0f2e 100644 --- a/bin/named/include/named/log.h +++ b/bin/named/include/named/log.h @@ -18,22 +18,8 @@ #include #include -#include - #include /* Required for named_g_(categories|modules). */ -/* Unused slot 0. */ -#define NAMED_LOGCATEGORY_UNMATCHED (&named_g_categories[1]) - -/* - * Backwards compatibility. - */ -#define NAMED_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL - -#define NAMED_LOGMODULE_MAIN (&named_g_modules[0]) -#define NAMED_LOGMODULE_SERVER (&named_g_modules[1]) -#define NAMED_LOGMODULE_CONTROL (&named_g_modules[2]) - isc_result_t named_log_init(bool safe); /*% diff --git a/bin/named/log.c b/bin/named/log.c index 0362953173..3023b34ee0 100644 --- a/bin/named/log.c +++ b/bin/named/log.c @@ -15,55 +15,21 @@ #include +#include #include #include -#include - -#include - -#include - #include #ifndef ISC_FACILITY #define ISC_FACILITY LOG_DAEMON #endif /* ifndef ISC_FACILITY */ -/*% - * When adding a new category, be sure to add the appropriate - * \#define to and to update the list in - * bin/check/check-tool.c. - */ -static isc_logcategory_t categories[] = { { "", 0 }, - { "unmatched", 0 }, - { NULL, 0 } }; - -/*% - * When adding a new module, be sure to add the appropriate - * \#define to . - */ -static isc_logmodule_t modules[] = { - { "main", 0 }, { "server", 0 }, { "control", 0 }, { NULL, 0 } -}; - isc_result_t named_log_init(bool safe) { isc_result_t result; isc_logconfig_t *lcfg = NULL; - named_g_categories = categories; - named_g_modules = modules; - - /* - * named-checktool.c:setup_logging() needs to be kept in sync. - */ - isc_log_registercategories(named_g_categories); - isc_log_registermodules(named_g_modules); - dns_log_init(); - cfg_log_init(); - ns_log_init(); - /* * This is not technically needed, as we are calling named_log_init() * only at the start of named process. But since the named binary is @@ -86,6 +52,8 @@ named_log_init(bool safe) { named_log_setdefaultsslkeylogfile(lcfg); rcu_read_unlock(); + named_g_logging = true; + return (ISC_R_SUCCESS); cleanup: @@ -205,7 +173,8 @@ named_log_setdefaultsslkeylogfile(isc_logconfig_t *lcfg) { isc_log_createchannel(lcfg, "default_sslkeylogfile", ISC_LOG_TOFILE, ISC_LOG_INFO, &destination, 0); result = isc_log_usechannel(lcfg, "default_sslkeylogfile", - ISC_LOGCATEGORY_SSLKEYLOG, NULL); + ISC_LOGCATEGORY_SSLKEYLOG, + ISC_LOGMODULE_ALL); RUNTIME_CHECK(result == ISC_R_SUCCESS); } @@ -214,7 +183,7 @@ named_log_setdefaultcategory(isc_logconfig_t *lcfg) { isc_result_t result = ISC_R_SUCCESS; result = isc_log_usechannel(lcfg, "default_debug", - ISC_LOGCATEGORY_DEFAULT, NULL); + ISC_LOGCATEGORY_DEFAULT, ISC_LOGMODULE_ALL); if (result != ISC_R_SUCCESS) { goto cleanup; } @@ -223,11 +192,11 @@ named_log_setdefaultcategory(isc_logconfig_t *lcfg) { if (named_g_logfile != NULL) { result = isc_log_usechannel(lcfg, "default_logfile", ISC_LOGCATEGORY_DEFAULT, - NULL); + ISC_LOGMODULE_ALL); } else if (!named_g_nosyslog) { result = isc_log_usechannel(lcfg, "default_syslog", ISC_LOGCATEGORY_DEFAULT, - NULL); + ISC_LOGMODULE_ALL); } } @@ -240,6 +209,6 @@ named_log_setunmatchedcategory(isc_logconfig_t *lcfg) { isc_result_t result; result = isc_log_usechannel(lcfg, "null", NAMED_LOGCATEGORY_UNMATCHED, - NULL); + ISC_LOGMODULE_ALL); return (result); } diff --git a/bin/named/logconf.c b/bin/named/logconf.c index 04057f56c1..530b44b481 100644 --- a/bin/named/logconf.c +++ b/bin/named/logconf.c @@ -24,7 +24,6 @@ #include #include -#include #include #include @@ -44,14 +43,14 @@ static isc_result_t category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) { isc_result_t result; const char *catname; - isc_logcategory_t *category; - isc_logmodule_t *module; + isc_logcategory_t category; + isc_logmodule_t module; const cfg_obj_t *destinations = NULL; const cfg_listelt_t *element = NULL; catname = cfg_obj_asstring(cfg_tuple_get(ccat, "name")); category = isc_log_categorybyname(catname); - if (category == NULL) { + if (category == ISC_LOGCATEGORY_INVALID) { cfg_obj_log(ccat, ISC_LOG_ERROR, "unknown logging category '%s' ignored", catname); /* @@ -64,7 +63,7 @@ category_fromconf(const cfg_obj_t *ccat, isc_logconfig_t *logconfig) { return (ISC_R_SUCCESS); } - module = NULL; + module = ISC_LOGMODULE_ALL; destinations = cfg_tuple_get(ccat, "destinations"); for (element = cfg_list_first(destinations); element != NULL; diff --git a/bin/named/main.c b/bin/named/main.c index 4588249c31..98418bfbe3 100644 --- a/bin/named/main.c +++ b/bin/named/main.c @@ -161,7 +161,7 @@ named_main_earlywarning(const char *format, ...) { va_list args; va_start(args, format); - if (named_g_categories != NULL) { + if (named_g_logging) { isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN, ISC_LOG_WARNING, format, args); } else { @@ -178,7 +178,7 @@ named_main_earlyfatal(const char *format, ...) { va_list args; va_start(args, format); - if (named_g_categories != NULL) { + if (named_g_logging) { isc_log_vwrite(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN, ISC_LOG_CRITICAL, format, args); isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN, @@ -206,7 +206,7 @@ assertion_failed(const char *file, int line, isc_assertiontype_t type, * Handle assertion failures. */ - if (named_g_categories != NULL) { + if (named_g_logging) { /* * Reset the assertion callback in case it is the log * routines causing the assertion. @@ -244,7 +244,7 @@ library_fatal_error(const char *file, int line, const char *func, * Handle isc_error_fatal() calls from our libraries. */ - if (named_g_categories != NULL) { + if (named_g_logging) { /* * Reset the error callback in case it is the log * routines causing the assertion. @@ -284,7 +284,7 @@ library_unexpected_error(const char *file, int line, const char *func, * Handle isc_error_unexpected() calls from our libraries. */ - if (named_g_categories != NULL) { + if (named_g_logging) { isc_log_write(NAMED_LOGCATEGORY_GENERAL, NAMED_LOGMODULE_MAIN, ISC_LOG_ERROR, "%s:%d:%s(): unexpected error: ", file, line, diff --git a/bin/named/zoneconf.c b/bin/named/zoneconf.c index 70d6f464d4..a78adae58a 100644 --- a/bin/named/zoneconf.c +++ b/bin/named/zoneconf.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include #include -#include #include #include #include diff --git a/bin/nsupdate/nsupdate.c b/bin/nsupdate/nsupdate.c index 61062c1730..e7162889aa 100644 --- a/bin/nsupdate/nsupdate.c +++ b/bin/nsupdate/nsupdate.c @@ -52,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -811,10 +810,9 @@ setup_system(void *arg ISC_ATTR_UNUSED) { ddebug("setup_system()"); - dns_log_init(); - logconfig = isc_logconfig_get(); - result = isc_log_usechannel(logconfig, "default_debug", NULL, NULL); + result = isc_log_usechannel(logconfig, "default_debug", + ISC_LOGCATEGORY_ALL, ISC_LOGMODULE_ALL); check_result(result, "isc_log_usechannel"); isc_log_setdebuglevel(logdebuglevel); diff --git a/bin/plugins/filter-a.c b/bin/plugins/filter-a.c index b710149e97..57e6fa7248 100644 --- a/bin/plugins/filter-a.c +++ b/bin/plugins/filter-a.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,6 @@ #include #include -#include #include #include diff --git a/bin/plugins/filter-aaaa.c b/bin/plugins/filter-aaaa.c index f39ac91e47..ab5388e686 100644 --- a/bin/plugins/filter-aaaa.c +++ b/bin/plugins/filter-aaaa.c @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -44,7 +43,6 @@ #include #include -#include #include #include diff --git a/bin/rndc/rndc.c b/bin/rndc/rndc.c index e9ddc0c279..8f9e3cbe9f 100644 --- a/bin/rndc/rndc.c +++ b/bin/rndc/rndc.c @@ -963,7 +963,8 @@ main(int argc, char **argv) { ISC_LOG_INFO, &logdest, ISC_LOG_PRINTTAG | ISC_LOG_PRINTLEVEL); DO("enabling log channel", - isc_log_usechannel(logconfig, "stderr", NULL, NULL)); + isc_log_usechannel(logconfig, "stderr", ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL)); parse_config(rndc_mctx, keyname, &pctx, &config); diff --git a/bin/tests/system/dyndb/driver/log.c b/bin/tests/system/dyndb/driver/log.c index 138158d027..a096932659 100644 --- a/bin/tests/system/dyndb/driver/log.c +++ b/bin/tests/system/dyndb/driver/log.c @@ -29,10 +29,9 @@ #include "log.h" +#include #include -#include - void log_write(int level, const char *format, ...) { va_list args; diff --git a/bin/tests/system/dyndb/driver/log.h b/bin/tests/system/dyndb/driver/log.h index 375db2b46a..30758dee48 100644 --- a/bin/tests/system/dyndb/driver/log.h +++ b/bin/tests/system/dyndb/driver/log.h @@ -30,10 +30,9 @@ #pragma once #include +#include #include -#include - #define log_error_r(fmt, ...) \ log_error(fmt ": %s", ##__VA_ARGS__, isc_result_totext(result)) diff --git a/bin/tests/system/hooks/driver/test-async.c b/bin/tests/system/hooks/driver/test-async.c index 6702a32317..c77d5f7a3a 100644 --- a/bin/tests/system/hooks/driver/test-async.c +++ b/bin/tests/system/hooks/driver/test-async.c @@ -32,7 +32,6 @@ #include #include -#include #include #include diff --git a/bin/tests/system/makejournal.c b/bin/tests/system/makejournal.c index d13a9b26a6..4ebd534f0d 100644 --- a/bin/tests/system/makejournal.c +++ b/bin/tests/system/makejournal.c @@ -25,25 +25,11 @@ #include #include #include -#include #include #include isc_mem_t *mctx = NULL; -/* - * Logging categories: this needs to match the list in bin/named/log.c. - */ -static isc_logcategory_t categories[] = { { "", 0 }, - { "client", 0 }, - { "network", 0 }, - { "update", 0 }, - { "queries", 0 }, - { "unmatched", 0 }, - { "update-security", 0 }, - { "query-errors", 0 }, - { NULL, 0 } }; - static isc_result_t loadzone(dns_db_t **db, const char *origin, const char *filename) { isc_result_t result; @@ -91,9 +77,6 @@ main(int argc, char **argv) { isc_mem_debugging |= ISC_MEM_DEBUGRECORD; isc_mem_create(&mctx); - isc_log_registercategories(categories); - dns_log_init(); - logconfig = isc_logconfig_get(); destination.file.stream = stderr; destination.file.name = NULL; @@ -102,7 +85,8 @@ main(int argc, char **argv) { isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, 0); - result = isc_log_usechannel(logconfig, "stderr", NULL, NULL); + result = isc_log_usechannel(logconfig, "stderr", ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL); if (result != ISC_R_SUCCESS) { goto cleanup; } diff --git a/bin/tests/system/rsabigexponent/bigkey.c b/bin/tests/system/rsabigexponent/bigkey.c index 8b1d77d6b0..707279a5fd 100644 --- a/bin/tests/system/rsabigexponent/bigkey.c +++ b/bin/tests/system/rsabigexponent/bigkey.c @@ -29,12 +29,12 @@ #include #include +#include #include #include #include #include -#include #include #include #include diff --git a/bin/tools/named-journalprint.c b/bin/tools/named-journalprint.c index fb2c5af524..3b6203b631 100644 --- a/bin/tools/named-journalprint.c +++ b/bin/tools/named-journalprint.c @@ -22,7 +22,6 @@ #include #include -#include #include const char *progname = NULL; @@ -41,8 +40,6 @@ setup_logging(FILE *errout) { isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; - dns_log_init(); - logconfig = isc_logconfig_get(); destination.file.stream = errout; destination.file.name = NULL; @@ -51,8 +48,9 @@ setup_logging(FILE *errout) { isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, 0); - RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", NULL, NULL) == - ISC_R_SUCCESS); + RUNTIME_CHECK(isc_log_usechannel(logconfig, "stderr", + ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL) == ISC_R_SUCCESS); } int diff --git a/doc/dev/dev.md b/doc/dev/dev.md index 358539cccb..e117ce17a8 100644 --- a/doc/dev/dev.md +++ b/doc/dev/dev.md @@ -1076,7 +1076,7 @@ the following steps need to be taken to initialize it. the DNS library, include the following: #include - #include + log.h>/log.h> 1. Initialize a logging context. A logging context needs a valid memory context in order to work, so the following code snippet shows a diff --git a/doc/misc/cfg_test.c b/doc/misc/cfg_test.c index c7cbc506ca..d54d08cfc1 100644 --- a/doc/misc/cfg_test.c +++ b/doc/misc/cfg_test.c @@ -17,12 +17,11 @@ #include #include +#include #include #include #include -#include - #include #include @@ -83,7 +82,8 @@ main(int argc, char **argv) { isc_log_createchannel(lcfg, "_default", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); - result = isc_log_usechannel(lcfg, "_default", NULL, NULL); + result = isc_log_usechannel(lcfg, "_default", ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL); check_result(result, "isc_log_usechannel()"); /* diff --git a/lib/dns/Makefile.am b/lib/dns/Makefile.am index 18c02d8f3d..d5e96faa5e 100644 --- a/lib/dns/Makefile.am +++ b/lib/dns/Makefile.am @@ -87,7 +87,6 @@ libdns_la_HEADERS = \ include/dns/keytable.h \ include/dns/keyvalues.h \ include/dns/librpz.h \ - include/dns/log.h \ include/dns/master.h \ include/dns/masterdump.h \ include/dns/message.h \ @@ -194,7 +193,6 @@ libdns_la_SOURCES = \ keymgr.c \ keystore.c \ keytable.c \ - log.c \ master.c \ masterdump.c \ message.c \ diff --git a/lib/dns/adb.c b/lib/dns/adb.c index ae6a4ef8ac..52568129f9 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -35,12 +36,9 @@ #include #include -#include #include -#include #include #include -#include #include #include diff --git a/lib/dns/cache.c b/lib/dns/cache.c index 24e2d4f205..2ddae6acc2 100644 --- a/lib/dns/cache.c +++ b/lib/dns/cache.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/callbacks.c b/lib/dns/callbacks.c index 4f144f629b..9f68b09f54 100644 --- a/lib/dns/callbacks.c +++ b/lib/dns/callbacks.c @@ -13,10 +13,10 @@ /*! \file */ +#include #include #include -#include static void stdio_error_warn_callback(dns_rdatacallbacks_t *, const char *, ...) diff --git a/lib/dns/db.c b/lib/dns/db.c index 51c4bd04c4..bc65ec3292 100644 --- a/lib/dns/db.c +++ b/lib/dns/db.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -34,10 +35,7 @@ #include #include #include -#include -#include #include -#include #include #include diff --git a/lib/dns/diff.c b/lib/dns/diff.c index 2d92cce224..2a170146a5 100644 --- a/lib/dns/diff.c +++ b/lib/dns/diff.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/dispatch.c b/lib/dns/dispatch.c index 1a4565723c..6af073d36a 100644 --- a/lib/dns/dispatch.c +++ b/lib/dns/dispatch.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/dlz.c b/lib/dns/dlz.c index f7aa071a88..d7452c9e0d 100644 --- a/lib/dns/dlz.c +++ b/lib/dns/dlz.c @@ -56,6 +56,7 @@ #include #include +#include #include #include #include @@ -68,7 +69,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/dnssec.c b/lib/dns/dnssec.c index 8b8554043a..98657d8631 100644 --- a/lib/dns/dnssec.c +++ b/lib/dns/dnssec.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -32,11 +33,8 @@ #include #include #include -#include -#include #include #include -#include #include #include #include /* for DNS_TSIG_FUDGE */ diff --git a/lib/dns/dnstap.c b/lib/dns/dnstap.c index 03298860ad..8525db584e 100644 --- a/lib/dns/dnstap.c +++ b/lib/dns/dnstap.c @@ -69,7 +69,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/dst_api.c b/lib/dns/dst_api.c index a60b7fd61a..69ec9a88ff 100644 --- a/lib/dns/dst_api.c +++ b/lib/dns/dst_api.c @@ -250,7 +250,7 @@ dst_ds_digest_supported(unsigned int digest_type) { } isc_result_t -dst_context_create(dst_key_t *key, isc_mem_t *mctx, isc_logcategory_t *category, +dst_context_create(dst_key_t *key, isc_mem_t *mctx, isc_logcategory_t category, bool useforsigning, int maxbits, dst_context_t **dctxp) { dst_context_t *dctx; isc_result_t result; diff --git a/lib/dns/dst_internal.h b/lib/dns/dst_internal.h index f8a90f3ff5..988d14cf9c 100644 --- a/lib/dns/dst_internal.h +++ b/lib/dns/dst_internal.h @@ -139,7 +139,7 @@ struct dst_context { dst_use_t use; dst_key_t *key; isc_mem_t *mctx; - isc_logcategory_t *category; + isc_logcategory_t category; union { void *generic; dst_gssapi_signverifyctx_t *gssctx; diff --git a/lib/dns/dst_openssl.h b/lib/dns/dst_openssl.h index 55e54380cb..a7c796897e 100644 --- a/lib/dns/dst_openssl.h +++ b/lib/dns/dst_openssl.h @@ -27,8 +27,9 @@ ISC_LANG_BEGINDECLS -#define dst__openssl_toresult(fallback) \ - isc__tlserr2result(NULL, NULL, NULL, fallback, __FILE__, __LINE__) +#define dst__openssl_toresult(fallback) \ + isc__tlserr2result(ISC_LOGCATEGORY_INVALID, ISC_LOGMODULE_INVALID, \ + NULL, fallback, __FILE__, __LINE__) #define dst__openssl_toresult2(funcname, fallback) \ isc__tlserr2result(DNS_LOGCATEGORY_GENERAL, DNS_LOGMODULE_CRYPTO, \ funcname, fallback, __FILE__, __LINE__) diff --git a/lib/dns/dst_parse.c b/lib/dns/dst_parse.c index 414e9aff03..e9f3832752 100644 --- a/lib/dns/dst_parse.c +++ b/lib/dns/dst_parse.c @@ -36,12 +36,12 @@ #include #include #include +#include #include #include #include #include -#include #include #include "dst_internal.h" diff --git a/lib/dns/dyndb.c b/lib/dns/dyndb.c index 43d37a0699..99939f8e0f 100644 --- a/lib/dns/dyndb.c +++ b/lib/dns/dyndb.c @@ -14,6 +14,7 @@ #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/geoip2.c b/lib/dns/geoip2.c index a3b2206bc8..6c29c19158 100644 --- a/lib/dns/geoip2.c +++ b/lib/dns/geoip2.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include -#include /* * This structure preserves state from the previous GeoIP lookup, @@ -46,9 +46,9 @@ * the lookup was answered, and a copy of the request address. * * If the next geoip ACL lookup is for the same database and from the - * same address, we can reuse the MMDB entry without repeating the lookup. - * This is for the case when a single query has to process multiple - * geoip ACLs: for example, when there are multiple views with + * same address, we can reuse the MMDB entry without repeating the + * lookup. This is for the case when a single query has to process + * multiple geoip ACLs: for example, when there are multiple views with * match-clients statements that search for different countries. * * (XXX: Currently the persistent state is stored in thread specific diff --git a/lib/dns/gssapictx.c b/lib/dns/gssapictx.c index 91b90c84f6..d4b8017bd0 100644 --- a/lib/dns/gssapictx.c +++ b/lib/dns/gssapictx.c @@ -40,6 +40,7 @@ #include #include #include +#include #include #include #include @@ -50,8 +51,6 @@ #include #include -#include -#include #include #include #include diff --git a/lib/dns/include/dns/log.h b/lib/dns/include/dns/log.h deleted file mode 100644 index 8913147330..0000000000 --- a/lib/dns/include/dns/log.h +++ /dev/null @@ -1,102 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! \file dns/log.h - */ - -#pragma once - -#include -#include - -extern isc_logcategory_t dns_categories[]; -extern isc_logmodule_t dns_modules[]; - -#define DNS_LOGCATEGORY_NOTIFY (&dns_categories[0]) -#define DNS_LOGCATEGORY_DATABASE (&dns_categories[1]) -#define DNS_LOGCATEGORY_SECURITY (&dns_categories[2]) -/* DNS_LOGCATEGORY_CONFIG superseded by CFG_LOGCATEGORY_CONFIG */ -#define DNS_LOGCATEGORY_DNSSEC (&dns_categories[4]) -#define DNS_LOGCATEGORY_RESOLVER (&dns_categories[5]) -#define DNS_LOGCATEGORY_XFER_IN (&dns_categories[6]) -#define DNS_LOGCATEGORY_XFER_OUT (&dns_categories[7]) -#define DNS_LOGCATEGORY_DISPATCH (&dns_categories[8]) -#define DNS_LOGCATEGORY_LAME_SERVERS (&dns_categories[9]) -/* #define DNS_LOGCATEGORY_DELEGATION_ONLY removed */ -#define DNS_LOGCATEGORY_EDNS_DISABLED (&dns_categories[10]) -#define DNS_LOGCATEGORY_RPZ (&dns_categories[11]) -#define DNS_LOGCATEGORY_RRL (&dns_categories[12]) -#define DNS_LOGCATEGORY_CNAME (&dns_categories[13]) -#define DNS_LOGCATEGORY_SPILL (&dns_categories[14]) -#define DNS_LOGCATEGORY_DNSTAP (&dns_categories[15]) -#define DNS_LOGCATEGORY_ZONELOAD (&dns_categories[16]) -#define DNS_LOGCATEGORY_NSID (&dns_categories[17]) -#define DNS_LOGCATEGORY_RPZ_PASSTHRU (&dns_categories[18]) - -/* Backwards compatibility. */ -#define DNS_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL - -#define DNS_LOGMODULE_DB (&dns_modules[0]) -#define DNS_LOGMODULE_RBTDB (&dns_modules[1]) -#define DNS_LOGMODULE_RBT (&dns_modules[2]) -#define DNS_LOGMODULE_RDATA (&dns_modules[3]) -#define DNS_LOGMODULE_MASTER (&dns_modules[4]) -#define DNS_LOGMODULE_MESSAGE (&dns_modules[5]) -#define DNS_LOGMODULE_CACHE (&dns_modules[6]) -#define DNS_LOGMODULE_CONFIG (&dns_modules[7]) -#define DNS_LOGMODULE_RESOLVER (&dns_modules[8]) -#define DNS_LOGMODULE_ZONE (&dns_modules[9]) -#define DNS_LOGMODULE_JOURNAL (&dns_modules[10]) -#define DNS_LOGMODULE_ADB (&dns_modules[11]) -#define DNS_LOGMODULE_XFER_IN (&dns_modules[12]) -#define DNS_LOGMODULE_XFER_OUT (&dns_modules[13]) -#define DNS_LOGMODULE_ACL (&dns_modules[14]) -#define DNS_LOGMODULE_VALIDATOR (&dns_modules[15]) -#define DNS_LOGMODULE_DISPATCH (&dns_modules[16]) -#define DNS_LOGMODULE_REQUEST (&dns_modules[17]) -#define DNS_LOGMODULE_MASTERDUMP (&dns_modules[18]) -#define DNS_LOGMODULE_TSIG (&dns_modules[19]) -#define DNS_LOGMODULE_TKEY (&dns_modules[20]) -#define DNS_LOGMODULE_SDB (&dns_modules[21]) -#define DNS_LOGMODULE_DIFF (&dns_modules[22]) -#define DNS_LOGMODULE_HINTS (&dns_modules[23]) -#define DNS_LOGMODULE_UNUSED1 (&dns_modules[24]) -#define DNS_LOGMODULE_DLZ (&dns_modules[25]) -#define DNS_LOGMODULE_DNSSEC (&dns_modules[26]) -#define DNS_LOGMODULE_CRYPTO (&dns_modules[27]) -#define DNS_LOGMODULE_PACKETS (&dns_modules[28]) -#define DNS_LOGMODULE_NTA (&dns_modules[29]) -#define DNS_LOGMODULE_DYNDB (&dns_modules[30]) -#define DNS_LOGMODULE_DNSTAP (&dns_modules[31]) -#define DNS_LOGMODULE_SSU (&dns_modules[32]) -#define DNS_LOGMODULE_QP (&dns_modules[33]) - -ISC_LANG_BEGINDECLS - -void -dns_log_init(void); -/*% - * Make the libdns categories and modules available for use with the - * ISC logging library. - * - * Requires: - *\li lctx is a valid logging context. - * - *\li dns_log_init() is called only once. - * - * Ensures: - * \li The categories and modules defined above are available for - * use by isc_log_usechannnel() and isc_log_write(). - */ - -ISC_LANG_ENDDECLS diff --git a/lib/dns/include/dns/message.h b/lib/dns/include/dns/message.h index 81c641dd84..5970f61160 100644 --- a/lib/dns/include/dns/message.h +++ b/lib/dns/include/dns/message.h @@ -1413,14 +1413,13 @@ dns_message_gettimeadjust(dns_message_t *msg); void dns_message_logpacket(dns_message_t *message, const char *description, - const isc_sockaddr_t *address, - isc_logcategory_t *category, isc_logmodule_t *module, - int level, isc_mem_t *mctx); + const isc_sockaddr_t *address, isc_logcategory_t category, + isc_logmodule_t module, int level, isc_mem_t *mctx); void dns_message_logfmtpacket(dns_message_t *message, const char *description, const isc_sockaddr_t *address, - isc_logcategory_t *category, isc_logmodule_t *module, + isc_logcategory_t category, isc_logmodule_t module, const dns_master_style_t *style, int level, isc_mem_t *mctx); /*%< diff --git a/lib/dns/include/dns/resolver.h b/lib/dns/include/dns/resolver.h index cf1c1e9ba4..75f92b63f7 100644 --- a/lib/dns/include/dns/resolver.h +++ b/lib/dns/include/dns/resolver.h @@ -365,8 +365,8 @@ dns_resolver_destroyfetch(dns_fetch_t **fetchp); */ void -dns_resolver_logfetch(dns_fetch_t *fetch, isc_logcategory_t *category, - isc_logmodule_t *module, int level, bool duplicateok); +dns_resolver_logfetch(dns_fetch_t *fetch, isc_logcategory_t category, + isc_logmodule_t module, int level, bool duplicateok); /*%< * Dump a log message on internal state at the completion of given 'fetch'. * 'lctx', 'category', 'module', and 'level' are used to write the log message. diff --git a/lib/dns/include/dns/zone.h b/lib/dns/include/dns/zone.h index a394ddd72e..5bbcaaa552 100644 --- a/lib/dns/include/dns/zone.h +++ b/lib/dns/include/dns/zone.h @@ -2108,7 +2108,7 @@ dns_zone_setdialup(dns_zone_t *zone, dns_dialuptype_t dialup); */ void -dns_zone_logv(dns_zone_t *zone, isc_logcategory_t *category, int level, +dns_zone_logv(dns_zone_t *zone, isc_logcategory_t category, int level, const char *prefix, const char *msg, va_list ap); /*%< * Log the message 'msg...' at 'level' using log category 'category', including @@ -2125,7 +2125,7 @@ dns_zone_log(dns_zone_t *zone, int level, const char *msg, ...) */ void -dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category, int level, +dns_zone_logc(dns_zone_t *zone, isc_logcategory_t category, int level, const char *msg, ...) ISC_FORMAT_PRINTF(4, 5); /*%< * Log the message 'msg...' at 'level', including text that identifies diff --git a/lib/dns/include/dst/dst.h b/lib/dns/include/dst/dst.h index 85f99ad63e..c63a743f81 100644 --- a/lib/dns/include/dst/dst.h +++ b/lib/dns/include/dst/dst.h @@ -19,11 +19,11 @@ #include #include +#include #include #include #include -#include #include #include #include @@ -37,9 +37,10 @@ ISC_LANG_BEGINDECLS ***/ /*% - * The dst_key structure is opaque. Applications should use the accessor - * functions provided to retrieve key attributes. If an application needs - * to set attributes, new accessor functions will be written. + * The dst_key structure is opaque. Applications should use the + * accessor functions provided to retrieve key attributes. If an + * application needs to set attributes, new accessor functions will be + * written. */ typedef struct dst_key dst_key_t; @@ -219,7 +220,7 @@ dst_ds_digest_supported(unsigned int digest_type); */ isc_result_t -dst_context_create(dst_key_t *key, isc_mem_t *mctx, isc_logcategory_t *category, +dst_context_create(dst_key_t *key, isc_mem_t *mctx, isc_logcategory_t category, bool useforsigning, int maxbits, dst_context_t **dctxp); /*%< * Creates a context to be used for a sign or verify operation. diff --git a/lib/dns/journal.c b/lib/dns/journal.c index e41df8d8e2..5a27cf7df2 100644 --- a/lib/dns/journal.c +++ b/lib/dns/journal.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -30,10 +31,8 @@ #include #include #include -#include #include #include -#include #include #include #include diff --git a/lib/dns/kasp.c b/lib/dns/kasp.c index d31af74574..4a85a0170e 100644 --- a/lib/dns/kasp.c +++ b/lib/dns/kasp.c @@ -25,7 +25,6 @@ #include #include -#include #include diff --git a/lib/dns/keymgr.c b/lib/dns/keymgr.c index baabe2dbba..35e3a83565 100644 --- a/lib/dns/keymgr.c +++ b/lib/dns/keymgr.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -30,7 +31,6 @@ #include #include #include -#include #include diff --git a/lib/dns/log.c b/lib/dns/log.c deleted file mode 100644 index 3e31ab195c..0000000000 --- a/lib/dns/log.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! \file */ - -#include - -#include - -/*% - * When adding a new category, be sure to add the appropriate - * \#define to . - */ -isc_logcategory_t dns_categories[] = { - { "notify", 0 }, { "database", 0 }, - { "security", 0 }, { "_placeholder", 0 }, - { "dnssec", 0 }, { "resolver", 0 }, - { "xfer-in", 0 }, { "xfer-out", 0 }, - { "dispatch", 0 }, { "lame-servers", 0 }, - { "edns-disabled", 0 }, { "rpz", 0 }, - { "rate-limit", 0 }, { "cname", 0 }, - { "spill", 0 }, { "dnstap", 0 }, - { "zoneload", 0 }, { "nsid", 0 }, - { "rpz-passthru", 0 }, { NULL, 0 } -}; - -/*% - * When adding a new module, be sure to add the appropriate - * \#define to . - */ -isc_logmodule_t dns_modules[] = { - { "dns/db", 0 }, { "dns/rbtdb", 0 }, { "dns/rbt", 0 }, - { "dns/rdata", 0 }, { "dns/master", 0 }, { "dns/message", 0 }, - { "dns/cache", 0 }, { "dns/config", 0 }, { "dns/resolver", 0 }, - { "dns/zone", 0 }, { "dns/journal", 0 }, { "dns/adb", 0 }, - { "dns/xfrin", 0 }, { "dns/xfrout", 0 }, { "dns/acl", 0 }, - { "dns/validator", 0 }, { "dns/dispatch", 0 }, { "dns/request", 0 }, - { "dns/masterdump", 0 }, { "dns/tsig", 0 }, { "dns/tkey", 0 }, - { "dns/sdb", 0 }, { "dns/diff", 0 }, { "dns/hints", 0 }, - { "dns/unused1", 0 }, { "dns/dlz", 0 }, { "dns/dnssec", 0 }, - { "dns/crypto", 0 }, { "dns/packets", 0 }, { "dns/nta", 0 }, - { "dns/dyndb", 0 }, { "dns/dnstap", 0 }, { "dns/ssu", 0 }, - { "dns/qp", 0 }, { NULL, 0 }, -}; - -void -dns_log_init(void) { - isc_log_registercategories(dns_categories); - isc_log_registermodules(dns_modules); -} diff --git a/lib/dns/masterdump.c b/lib/dns/masterdump.c index aff2290db6..7f035b1699 100644 --- a/lib/dns/masterdump.c +++ b/lib/dns/masterdump.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -36,13 +37,11 @@ #include #include #include -#include #include #include #include #include #include -#include #include #include #include diff --git a/lib/dns/message.c b/lib/dns/message.c index 222db0f7ca..6f1938a337 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include -#include #include #include #include @@ -213,9 +213,9 @@ msgblock_free(isc_mem_t *, dns_msgblock_t *, unsigned int); static void logfmtpacket(dns_message_t *message, const char *description, - const isc_sockaddr_t *address, isc_logcategory_t *category, - isc_logmodule_t *module, const dns_master_style_t *style, - int level, isc_mem_t *mctx); + const isc_sockaddr_t *address, isc_logcategory_t category, + isc_logmodule_t module, const dns_master_style_t *style, int level, + isc_mem_t *mctx); /* * Allocate a new dns_msgblock_t, and return a pointer to it. If no memory @@ -4661,9 +4661,8 @@ dns_opcode_totext(dns_opcode_t opcode, isc_buffer_t *target) { void dns_message_logpacket(dns_message_t *message, const char *description, - const isc_sockaddr_t *address, - isc_logcategory_t *category, isc_logmodule_t *module, - int level, isc_mem_t *mctx) { + const isc_sockaddr_t *address, isc_logcategory_t category, + isc_logmodule_t module, int level, isc_mem_t *mctx) { REQUIRE(address != NULL); logfmtpacket(message, description, address, category, module, @@ -4673,7 +4672,7 @@ dns_message_logpacket(dns_message_t *message, const char *description, void dns_message_logfmtpacket(dns_message_t *message, const char *description, const isc_sockaddr_t *address, - isc_logcategory_t *category, isc_logmodule_t *module, + isc_logcategory_t category, isc_logmodule_t module, const dns_master_style_t *style, int level, isc_mem_t *mctx) { REQUIRE(address != NULL); @@ -4684,9 +4683,9 @@ dns_message_logfmtpacket(dns_message_t *message, const char *description, static void logfmtpacket(dns_message_t *message, const char *description, - const isc_sockaddr_t *address, isc_logcategory_t *category, - isc_logmodule_t *module, const dns_master_style_t *style, - int level, isc_mem_t *mctx) { + const isc_sockaddr_t *address, isc_logcategory_t category, + isc_logmodule_t module, const dns_master_style_t *style, int level, + isc_mem_t *mctx) { char addrbuf[ISC_SOCKADDR_FORMATSIZE] = { 0 }; const char *newline = "\n"; const char *space = " "; diff --git a/lib/dns/nta.c b/lib/dns/nta.c index e977146a54..91f322f341 100644 --- a/lib/dns/nta.c +++ b/lib/dns/nta.c @@ -30,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/openssl_link.c b/lib/dns/openssl_link.c index 6ae723646f..c94c8fb0a3 100644 --- a/lib/dns/openssl_link.c +++ b/lib/dns/openssl_link.c @@ -27,6 +27,7 @@ * IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +#include #include #include #include @@ -36,8 +37,6 @@ #include #include -#include - #include "dst_internal.h" #include "dst_openssl.h" diff --git a/lib/dns/qp.c b/lib/dns/qp.c index 3c454868b0..bab8db89b7 100644 --- a/lib/dns/qp.c +++ b/lib/dns/qp.c @@ -28,6 +28,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/qpcache.c b/lib/dns/qpcache.c index d7b23800cd..11fcff3f6d 100644 --- a/lib/dns/qpcache.c +++ b/lib/dns/qpcache.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -159,8 +159,8 @@ #define DNS_QPDB_EXPIRE_TTL_COUNT 10 /*% - * This is the structure that is used for each node in the qp trie of trees. - * For now it is a copy of the dns_rbtnode structure. + * This is the structure that is used for each node in the qp trie of + * trees. For now it is a copy of the dns_rbtnode structure. */ typedef struct qpcnode qpcnode_t; struct qpcnode { diff --git a/lib/dns/qpzone.c b/lib/dns/qpzone.c index 2bf4ab2a2d..0e6d0eb23d 100644 --- a/lib/dns/qpzone.c +++ b/lib/dns/qpzone.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -42,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/rbt-cachedb.c b/lib/dns/rbt-cachedb.c index 4e9f2e0408..d5e571d1e0 100644 --- a/lib/dns/rbt-cachedb.c +++ b/lib/dns/rbt-cachedb.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include @@ -123,16 +123,17 @@ /*% * See if a given cache entry that is being reused needs to be updated - * in the LRU-list. From the LRU management point of view, this function is - * expected to return true for almost all cases. When used with threads, - * however, this may cause a non-negligible performance penalty because a - * writer lock will have to be acquired before updating the list. - * If DNS_RBTDB_LIMITLRUUPDATE is defined to be non 0 at compilation time, this - * function returns true if the entry has not been updated for some period of - * time. We differentiate the NS or glue address case and the others since - * experiments have shown that the former tends to be accessed relatively - * infrequently and the cost of cache miss is higher (e.g., a missing NS records - * may cause external queries at a higher level zone, involving more + * in the LRU-list. From the LRU management point of view, this + * function is expected to return true for almost all cases. When used + * with threads, however, this may cause a non-negligible performance + * penalty because a writer lock will have to be acquired before + * updating the list. If DNS_RBTDB_LIMITLRUUPDATE is defined to be non 0 + * at compilation time, this function returns true if the entry has not + * been updated for some period of time. We differentiate the NS or + * glue address case and the others since experiments have shown that + * the former tends to be accessed relatively infrequently and the cost + * of cache miss is higher (e.g., a missing NS records may cause + * external queries at a higher level zone, involving more * transactions). * * Caller must hold the node (read or write) lock. diff --git a/lib/dns/rbt-zonedb.c b/lib/dns/rbt-zonedb.c index 67e23aaf1a..16636375a2 100644 --- a/lib/dns/rbt-zonedb.c +++ b/lib/dns/rbt-zonedb.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/rbt.c b/lib/dns/rbt.c index bbda64eb5c..1c7cddc685 100644 --- a/lib/dns/rbt.c +++ b/lib/dns/rbt.c @@ -16,28 +16,22 @@ #include #include #include +#include #include #include #include +#include #include #include #include +#include #include #include #include -/*% - * This define is so dns/name.h (included by dns/fixedname.h) uses more - * efficient macro calls instead of functions for a few operations. - */ -#include - -#include - #include #include -#include #include #define CHECK(x) \ diff --git a/lib/dns/rbtdb.c b/lib/dns/rbtdb.c index 5b971178b4..a9832ffb9a 100644 --- a/lib/dns/rbtdb.c +++ b/lib/dns/rbtdb.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/request.c b/lib/dns/request.c index 352df5b0e6..e4db0e6290 100644 --- a/lib/dns/request.c +++ b/lib/dns/request.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index 9e052799e5..ee0ca2ee2d 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -226,8 +225,10 @@ #define NS_PROCESSING_LIMIT 20 STATIC_ASSERT(NS_PROCESSING_LIMIT > NS_RR_LIMIT, - "The maximum number of NS RRs processed for each delegation " - "(NS_PROCESSING_LIMIT) must be larger than the large delegation " + "The maximum number of NS RRs processed for each " + "delegation " + "(NS_PROCESSING_LIMIT) must be larger than the large " + "delegation " "threshold (NS_RR_LIMIT)."); /* Hash table for zone counters */ @@ -10611,8 +10612,8 @@ dns_resolver_destroyfetch(dns_fetch_t **fetchp) { } void -dns_resolver_logfetch(dns_fetch_t *fetch, isc_logcategory_t *category, - isc_logmodule_t *module, int level, bool duplicateok) { +dns_resolver_logfetch(dns_fetch_t *fetch, isc_logcategory_t category, + isc_logmodule_t module, int level, bool duplicateok) { fetchctx_t *fctx = NULL; REQUIRE(DNS_FETCH_VALID(fetch)); diff --git a/lib/dns/rootns.c b/lib/dns/rootns.c index 0ff172133f..b8fedf22bf 100644 --- a/lib/dns/rootns.c +++ b/lib/dns/rootns.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -24,7 +25,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/rpz.c b/lib/dns/rpz.c index c25c9588e6..9eda7378ea 100644 --- a/lib/dns/rpz.c +++ b/lib/dns/rpz.c @@ -20,6 +20,7 @@ #include #include +#include #include #include #include @@ -36,7 +37,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/rrl.c b/lib/dns/rrl.c index fae2fe6cbb..ca70a635be 100644 --- a/lib/dns/rrl.c +++ b/lib/dns/rrl.c @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/sdlz.c b/lib/dns/sdlz.c index 3442060773..653ef48d34 100644 --- a/lib/dns/sdlz.c +++ b/lib/dns/sdlz.c @@ -70,7 +70,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/ssu_external.c b/lib/dns/ssu_external.c index c2c05e9bed..9a4a9e980a 100644 --- a/lib/dns/ssu_external.c +++ b/lib/dns/ssu_external.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/stats.c b/lib/dns/stats.c index 4c430467ec..26829a5906 100644 --- a/lib/dns/stats.c +++ b/lib/dns/stats.c @@ -16,13 +16,13 @@ #include #include +#include #include #include #include #include #include -#include #include #include #include diff --git a/lib/dns/tkey.c b/lib/dns/tkey.c index 3c3c35581a..2f7a0192a8 100644 --- a/lib/dns/tkey.c +++ b/lib/dns/tkey.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include @@ -35,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/tsig.c b/lib/dns/tsig.c index eb579d1055..d4a4837bc7 100644 --- a/lib/dns/tsig.c +++ b/lib/dns/tsig.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include -#include #include #include #include diff --git a/lib/dns/update.c b/lib/dns/update.c index cc0f545f3e..659c199378 100644 --- a/lib/dns/update.c +++ b/lib/dns/update.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/validator.c b/lib/dns/validator.c index 5bd046c168..62f60c7c42 100644 --- a/lib/dns/validator.c +++ b/lib/dns/validator.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include #include @@ -75,7 +75,8 @@ enum valattr { VALATTR_COMPLETE = 1 << 3, /*%< Completion event sent. */ VALATTR_INSECURITY = 1 << 4, /*%< Attempting proveunsecure. */ VALATTR_MAXVALIDATIONS = 1 << 5, /*%< Max validations quota */ - VALATTR_MAXVALIDATIONFAILS = 1 << 6, /*%< Max validation fails quota */ + VALATTR_MAXVALIDATIONFAILS = 1 << 6, /*%< Max validation fails + quota */ /*! * NSEC proofs to be looked for. @@ -139,8 +140,8 @@ static isc_result_t proveunsecure(dns_validator_t *val, bool have_ds, bool resume); static void -validator_logv(dns_validator_t *val, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *fmt, va_list ap) +validator_logv(dns_validator_t *val, isc_logcategory_t category, + isc_logmodule_t module, int level, const char *fmt, va_list ap) ISC_FORMAT_PRINTF(5, 0); static void @@ -3502,9 +3503,8 @@ dns_validator_shutdown(dns_validator_t *val) { } static void -validator_logv(dns_validator_t *val, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *fmt, - va_list ap) { +validator_logv(dns_validator_t *val, isc_logcategory_t category, + isc_logmodule_t module, int level, const char *fmt, va_list ap) { char msgbuf[2048]; static const char spaces[] = " *"; int depth = val->depth * 2; diff --git a/lib/dns/xfrin.c b/lib/dns/xfrin.c index 6b81048243..66a96a7fc0 100644 --- a/lib/dns/xfrin.c +++ b/lib/dns/xfrin.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -31,7 +32,6 @@ #include #include #include -#include #include #include #include @@ -64,9 +64,10 @@ /*% * The states of the *XFR state machine. We handle both IXFR and AXFR - * with a single integrated state machine because they cannot be distinguished - * immediately - an AXFR response to an IXFR request can only be detected - * when the first two (2) response RRs have already been received. + * with a single integrated state machine because they cannot be + * distinguished immediately - an AXFR response to an IXFR request can + * only be detected when the first two (2) response RRs have already + * been received. */ typedef enum { XFRST_SOAQUERY, diff --git a/lib/dns/zone.c b/lib/dns/zone.c index 050ad77c19..b68383eb22 100644 --- a/lib/dns/zone.c +++ b/lib/dns/zone.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -57,7 +58,6 @@ #include #include #include -#include #include #include #include @@ -15733,7 +15733,7 @@ dns_zone_nameonly(dns_zone_t *zone, char *buf, size_t length) { } void -dns_zone_logv(dns_zone_t *zone, isc_logcategory_t *category, int level, +dns_zone_logv(dns_zone_t *zone, isc_logcategory_t category, int level, const char *prefix, const char *fmt, va_list ap) { char message[4096]; const char *zstr; @@ -15773,7 +15773,7 @@ notify_log(dns_zone_t *zone, int level, const char *fmt, ...) { } void -dns_zone_logc(dns_zone_t *zone, isc_logcategory_t *category, int level, +dns_zone_logc(dns_zone_t *zone, isc_logcategory_t category, int level, const char *fmt, ...) { va_list ap; diff --git a/lib/dns/zoneverify.c b/lib/dns/zoneverify.c index 3419ef1f91..b52f651d8b 100644 --- a/lib/dns/zoneverify.c +++ b/lib/dns/zoneverify.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/dns/zt.c b/lib/dns/zt.c index 3d0b48176a..b8001f68ee 100644 --- a/lib/dns/zt.c +++ b/lib/dns/zt.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -25,7 +26,6 @@ #include #include -#include #include #include #include diff --git a/lib/isc/backtrace.c b/lib/isc/backtrace.c index 0fa27edd89..aace374f6c 100644 --- a/lib/isc/backtrace.c +++ b/lib/isc/backtrace.c @@ -62,7 +62,7 @@ isc_backtrace_symbols_fd(void *const *buffer, int size, int fd) { } void -isc_backtrace_log(isc_logcategory_t *category, isc_logmodule_t *module, +isc_backtrace_log(isc_logcategory_t category, isc_logmodule_t module, int level) { void *tracebuf[ISC_BACKTRACE_MAXFRAME]; int nframes; @@ -107,7 +107,7 @@ isc_backtrace_symbols_fd(void *const *buffer, int size, int fd) { } void -isc_backtrace_log(isc_logcategory_t *category, isc_logmodule_t *module, +isc_backtrace_log(isc_logcategory_t category, isc_logmodule_t module, int level) { UNUSED(category); UNUSED(module); diff --git a/lib/isc/include/isc/backtrace.h b/lib/isc/include/isc/backtrace.h index bfe887ce82..2198f2a408 100644 --- a/lib/isc/include/isc/backtrace.h +++ b/lib/isc/include/isc/backtrace.h @@ -32,6 +32,7 @@ /*** *** Imports ***/ +#include #include /* @@ -105,7 +106,7 @@ isc_backtrace_symbols_fd(void *const *buffer, int size, int fd); */ void -isc_backtrace_log(isc_logcategory_t *category, isc_logmodule_t *module, +isc_backtrace_log(isc_logcategory_t category, isc_logmodule_t module, int level); /* * Write a backtrace to the log. diff --git a/lib/isc/include/isc/log.h b/lib/isc/include/isc/log.h index 6b67e0a3dc..0143bfa15f 100644 --- a/lib/isc/include/isc/log.h +++ b/lib/isc/include/isc/log.h @@ -15,6 +15,7 @@ /*! \file isc/log.h */ +#include #include #include #include @@ -24,6 +25,8 @@ #include #include +typedef struct isc_logconfig isc_logconfig_t; /*%< Log Configuration */ + /*@{*/ /*! * \brief Severity levels, patterned after Unix's syslog levels. @@ -100,17 +103,131 @@ typedef enum { * structures names each category, and the id value is initialized by calling * isc_log_registercategories. */ -struct isc_logcategory { - const char *name; - unsigned int id; +typedef enum isc_logcategory isc_logcategory_t; /*%< Log Category */ +enum isc_logcategory { + /*% + * Do not log directly to DEFAULT. Use another category. + * When in doubt, use GENERAL. + */ + ISC_LOGCATEGORY_ALL = -2, + ISC_LOGCATEGORY_INVALID = -1, + /* isc categories */ + ISC_LOGCATEGORY_DEFAULT = 0, + ISC_LOGCATEGORY_GENERAL, + DNS_LOGCATEGORY_GENERAL = ISC_LOGCATEGORY_GENERAL, + NS_LOGCATEGORY_GENERAL = ISC_LOGCATEGORY_GENERAL, + NAMED_LOGCATEGORY_GENERAL = ISC_LOGCATEGORY_GENERAL, + ISC_LOGCATEGORY_SSLKEYLOG, + /* dns categories */ + DNS_LOGCATEGORY_NOTIFY, + DNS_LOGCATEGORY_DATABASE, + DNS_LOGCATEGORY_SECURITY, + DNS_LOGCATEGORY_DNSSEC, + DNS_LOGCATEGORY_RESOLVER, + DNS_LOGCATEGORY_XFER_IN, + DNS_LOGCATEGORY_XFER_OUT, + DNS_LOGCATEGORY_DISPATCH, + DNS_LOGCATEGORY_LAME_SERVERS, + DNS_LOGCATEGORY_EDNS_DISABLED, + DNS_LOGCATEGORY_RPZ, + DNS_LOGCATEGORY_RRL, + DNS_LOGCATEGORY_CNAME, + DNS_LOGCATEGORY_SPILL, + DNS_LOGCATEGORY_DNSTAP, + DNS_LOGCATEGORY_ZONELOAD, + DNS_LOGCATEGORY_NSID, + DNS_LOGCATEGORY_RPZ_PASSTHRU, + /* ns categories */ + NS_LOGCATEGORY_CLIENT, + NS_LOGCATEGORY_NETWORK, + NS_LOGCATEGORY_UPDATE, + NS_LOGCATEGORY_QUERIES, + NS_LOGCATEGORY_UPDATE_SECURITY, + NS_LOGCATEGORY_QUERY_ERRORS, + NS_LOGCATEGORY_TAT, + NS_LOGCATEGORY_SERVE_STALE, + /* cfg categories */ + CFG_LOGCATEGORY_CONFIG, + /* named categories */ + NAMED_LOGCATEGORY_UNMATCHED, + /* delv categories */ + DELV_LOGCATEGORY_DEFAULT, + + ISC_LOGCATEGORY_MAX, /*% The number of categories */ + ISC_LOGCATEGORY_MAKE_ENUM_32BIT = INT32_MAX, }; /*% * Similar to isc_logcategory, but for all the modules a library defines. */ -struct isc_logmodule { - const char *name; - unsigned int id; +typedef enum isc_logmodule isc_logmodule_t; /*%< Log Module */ +enum isc_logmodule { + ISC_LOGMODULE_ALL = -2, + ISC_LOGMODULE_INVALID = -1, + /* isc modules */ + ISC_LOGMODULE_NONE = 0, + ISC_LOGMODULE_SOCKET, + ISC_LOGMODULE_TIME, + ISC_LOGMODULE_INTERFACE, + ISC_LOGMODULE_TIMER, + ISC_LOGMODULE_FILE, + ISC_LOGMODULE_NETMGR, + ISC_LOGMODULE_OTHER, + /* dns modules */ + DNS_LOGMODULE_DB, + DNS_LOGMODULE_RBTDB, + DNS_LOGMODULE_RBT, + DNS_LOGMODULE_RDATA, + DNS_LOGMODULE_MASTER, + DNS_LOGMODULE_MESSAGE, + DNS_LOGMODULE_CACHE, + DNS_LOGMODULE_CONFIG, + DNS_LOGMODULE_RESOLVER, + DNS_LOGMODULE_ZONE, + DNS_LOGMODULE_JOURNAL, + DNS_LOGMODULE_ADB, + DNS_LOGMODULE_XFER_IN, + DNS_LOGMODULE_XFER_OUT, + DNS_LOGMODULE_ACL, + DNS_LOGMODULE_VALIDATOR, + DNS_LOGMODULE_DISPATCH, + DNS_LOGMODULE_REQUEST, + DNS_LOGMODULE_MASTERDUMP, + DNS_LOGMODULE_TSIG, + DNS_LOGMODULE_TKEY, + DNS_LOGMODULE_SDB, + DNS_LOGMODULE_DIFF, + DNS_LOGMODULE_HINTS, + DNS_LOGMODULE_UNUSED1, + DNS_LOGMODULE_DLZ, + DNS_LOGMODULE_DNSSEC, + DNS_LOGMODULE_CRYPTO, + DNS_LOGMODULE_PACKETS, + DNS_LOGMODULE_NTA, + DNS_LOGMODULE_DYNDB, + DNS_LOGMODULE_DNSTAP, + DNS_LOGMODULE_SSU, + DNS_LOGMODULE_QP, + /* ns modules */ + NS_LOGMODULE_CLIENT, + NS_LOGMODULE_QUERY, + NS_LOGMODULE_INTERFACEMGR, + NS_LOGMODULE_UPDATE, + NS_LOGMODULE_XFER_IN, + NS_LOGMODULE_XFER_OUT, + NS_LOGMODULE_NOTIFY, + NS_LOGMODULE_HOOKS, + /* cfg modules */ + CFG_LOGMODULE_PARSER, + /* named modules */ + NAMED_LOGMODULE_MAIN, + NAMED_LOGMODULE_SERVER, + NAMED_LOGMODULE_CONTROL, + /* delv modules */ + DELV_LOGMODULE_DEFAULT, + + ISC_LOGMODULE_MAX, /*% The number of modules */ + ISC_LOGMODULE_MAKE_ENUM_32BIT = INT32_MAX, }; /*% @@ -148,9 +265,20 @@ typedef struct isc_logfile { */ typedef union isc_logdestination { isc_logfile_t file; - int facility; /* XXXDCL NT */ + int facility; } isc_logdestination_t; +#define ISC_LOGDESTINATION_STDERR \ + (&(isc_logdestination_t){ \ + .file = { \ + .stream = stderr, \ + .versions = ISC_LOG_ROLLNEVER, \ + .suffix = isc_log_rollsuffix_increment, \ + } }) + +#define ISC_LOGDESTINATION_SYSLOG(f) \ + (&(isc_logdestination_t){ .facility = (f) }) + /*@{*/ /*% * The built-in categories of libisc. @@ -163,24 +291,6 @@ extern isc_logcategory_t isc_categories[]; extern isc_logmodule_t isc_modules[]; /*@}*/ -/*@{*/ -/*% - * Do not log directly to DEFAULT. Use another category. When in doubt, - * use GENERAL. - */ -#define ISC_LOGCATEGORY_DEFAULT (&isc_categories[0]) -#define ISC_LOGCATEGORY_GENERAL (&isc_categories[1]) -#define ISC_LOGCATEGORY_SSLKEYLOG (&isc_categories[2]) -/*@}*/ - -#define ISC_LOGMODULE_SOCKET (&isc_modules[0]) -#define ISC_LOGMODULE_TIME (&isc_modules[1]) -#define ISC_LOGMODULE_INTERFACE (&isc_modules[2]) -#define ISC_LOGMODULE_TIMER (&isc_modules[3]) -#define ISC_LOGMODULE_FILE (&isc_modules[4]) -#define ISC_LOGMODULE_NETMGR (&isc_modules[5]) -#define ISC_LOGMODULE_OTHER (&isc_modules[6]) - ISC_LANG_BEGINDECLS void @@ -262,82 +372,6 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp); *\li The configuration is marked as invalid. */ -void -isc_log_registercategories(isc_logcategory_t categories[]); -/*%< - * Identify logging categories a library will use. - * - * Notes: - *\li A category should only be registered once, but no mechanism enforces - * this rule. - * - *\li The end of the categories array is identified by a NULL name. - * - *\li Because the name is used by #ISC_LOG_PRINTCATEGORY, it should not - * be altered or destroyed after isc_log_registercategories(). - * - *\li Because each element of the categories array is used by - * isc_log_categorybyname, it should not be altered or destroyed - * after registration. - * - *\li The value of the id integer in each structure is overwritten - * by this function, and so id need not be initialized to any particular - * value prior to the function call. - * - *\li A subsequent call to isc_log_registercategories with the same - * logging context (but new categories) will cause the last - * element of the categories array from the prior call to have - * its "name" member changed from NULL to point to the new - * categories array, and its "id" member set to UINT_MAX. - * - * Requires: - *\li lctx is a valid logging context. - *\li categories != NULL. - *\li categories[0].name != NULL. - * - * Ensures: - * \li There are references to each category in the logging context, - * so they can be used with isc_log_usechannel() and isc_log_write(). - */ - -void -isc_log_registermodules(isc_logmodule_t modules[]); -/*%< - * Identify logging categories a library will use. - * - * Notes: - *\li A module should only be registered once, but no mechanism enforces - * this rule. - * - *\li The end of the modules array is identified by a NULL name. - * - *\li Because the name is used by #ISC_LOG_PRINTMODULE, it should not - * be altered or destroyed after isc_log_registermodules(). - * - *\li Because each element of the modules array is used by - * isc_log_modulebyname, it should not be altered or destroyed - * after registration. - * - *\li The value of the id integer in each structure is overwritten - * by this function, and so id need not be initialized to any particular - * value prior to the function call. - * - *\li A subsequent call to isc_log_registermodules with the same - * logging context (but new modules) will cause the last - * element of the modules array from the prior call to have - * its "name" member changed from NULL to point to the new - * modules array, and its "id" member set to UINT_MAX. - * - * Requires: - *\li lctx is a valid logging context. - *\li modules != NULL. - *\li modules[0].name != NULL; - * - * Ensures: - *\li Each module has a reference in the logging context, so they can be - * used with isc_log_usechannel() and isc_log_write(). - */ - void isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, unsigned int type, int level, @@ -403,8 +437,8 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, isc_result_t isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, - const isc_logcategory_t *category, - const isc_logmodule_t *module); + const isc_logcategory_t category, + const isc_logmodule_t module); /*%< * Associate a named logging channel with a category and module that * will use it. @@ -499,7 +533,7 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, * meaningful error. */ void -isc_log_write(isc_logcategory_t *category, isc_logmodule_t *module, int level, +isc_log_write(isc_logcategory_t category, isc_logmodule_t module, int level, const char *format, ...) ISC_FORMAT_PRINTF(4, 5); @@ -537,7 +571,7 @@ isc_log_write(isc_logcategory_t *category, isc_logmodule_t *module, int level, * meaningful error. */ void -isc_log_vwrite(isc_logcategory_t *category, isc_logmodule_t *module, int level, +isc_log_vwrite(isc_logcategory_t category, isc_logmodule_t module, int level, const char *format, va_list args) ISC_FORMAT_PRINTF(4, 0); @@ -693,7 +727,7 @@ isc_log_closefilelogs(void); * next needed. */ -isc_logcategory_t * +isc_logcategory_t isc_log_categorybyname(const char *name); /*%< * Find a category by its name. @@ -711,24 +745,6 @@ isc_log_categorybyname(const char *name); *\li NULL if no category exists by that name. */ -isc_logmodule_t * -isc_log_modulebyname(const char *name); -/*%< - * Find a module by its name. - * - * Notes: - *\li The string name of a module is not required to be unique. - * - * Requires: - *\li lctx is a valid context. - *\li name is not NULL. - * - * Returns: - *\li A pointer to the _first_ isc_logmodule_t structure used by "name". - * - *\li NULL if no module exists by that name. - */ - isc_result_t isc_logfile_roll(isc_logfile_t *file); /*%< diff --git a/lib/isc/include/isc/tls.h b/lib/isc/include/isc/tls.h index 7d96dda4f0..e3bc16eb60 100644 --- a/lib/isc/include/isc/tls.h +++ b/lib/isc/include/isc/tls.h @@ -13,6 +13,7 @@ #pragma once +#include #include #include #include @@ -620,6 +621,6 @@ isc__tls_setdestroycheck(bool check); isc__tlserr2result(category, module, funcname, fallback, __FILE__, \ __LINE__) isc_result_t -isc__tlserr2result(isc_logcategory_t *category, isc_logmodule_t *module, +isc__tlserr2result(isc_logcategory_t category, isc_logmodule_t module, const char *funcname, isc_result_t fallback, const char *file, int line); diff --git a/lib/isc/include/isc/types.h b/lib/isc/include/isc/types.h index 8ff4117853..21549e51d5 100644 --- a/lib/isc/include/isc/types.h +++ b/lib/isc/include/isc/types.h @@ -49,9 +49,6 @@ typedef void(isc_httpdondestroy_t)(void *); /*%< Callback on destroying httpd */ typedef struct isc_interface isc_interface_t; /*%< Interface */ typedef struct isc_interfaceiter isc_interfaceiter_t; /*%< Interface Iterator */ typedef struct isc_lex isc_lex_t; /*%< Lex */ -typedef struct isc_logcategory isc_logcategory_t; /*%< Log Category */ -typedef struct isc_logconfig isc_logconfig_t; /*%< Log Configuration */ -typedef struct isc_logmodule isc_logmodule_t; /*%< Log Module */ typedef struct isc_loop isc_loop_t; /*%< Event loop */ typedef struct isc_loopmgr isc_loopmgr_t; /*%< Event loop manager */ typedef struct isc_mem isc_mem_t; /*%< Memory */ diff --git a/lib/isc/log.c b/lib/isc/log.c index badb37e79f..eb9c4d0d7a 100644 --- a/lib/isc/log.c +++ b/lib/isc/log.c @@ -86,7 +86,7 @@ struct isc_logchannel { typedef struct isc_logchannellist isc_logchannellist_t; struct isc_logchannellist { - const isc_logmodule_t *module; + isc_logmodule_t module; isc_logchannel_t *channel; ISC_LINK(isc_logchannellist_t) link; }; @@ -114,8 +114,7 @@ struct isc_logconfig { unsigned int magic; isc_log_t *lctx; ISC_LIST(isc_logchannel_t) channels; - ISC_LIST(isc_logchannellist_t) * channellists; - unsigned int channellist_count; + ISC_LIST(isc_logchannellist_t) channellists[ISC_LOGCATEGORY_MAX]; int_fast32_t highest_level; char *tag; bool dynamic; @@ -134,10 +133,6 @@ struct isc_log { /* Not locked. */ unsigned int magic; isc_mem_t *mctx; - isc_logcategory_t *categories; - unsigned int category_count; - isc_logmodule_t *modules; - unsigned int module_count; atomic_int_fast32_t debug_level; /* RCU-protected pointer */ isc_logconfig_t *logconfig; @@ -169,20 +164,113 @@ static const int syslog_map[] = { LOG_DEBUG, LOG_INFO, LOG_NOTICE, * be overridden. Since the default is always looked up as the first * channellist in the log context, it must come first in isc_categories[]. */ -isc_logcategory_t isc_categories[] = { { "default", 0 }, /* "default - must come - first. */ - { "general", 0 }, - { "sslkeylog", 0 }, - { NULL, 0 } }; +static const char *categories_description[] = { + /* libisc categories */ + [ISC_LOGCATEGORY_DEFAULT] = "default", + [ISC_LOGCATEGORY_GENERAL] = "general", + [ISC_LOGCATEGORY_SSLKEYLOG] = "sslkeylog", + /* dns categories */ + [DNS_LOGCATEGORY_NOTIFY] = "notify", + [DNS_LOGCATEGORY_DATABASE] = "database", + [DNS_LOGCATEGORY_SECURITY] = "security", + [DNS_LOGCATEGORY_DNSSEC] = "dnssec", + [DNS_LOGCATEGORY_RESOLVER] = "resolver", + [DNS_LOGCATEGORY_XFER_IN] = "xfer-in", + [DNS_LOGCATEGORY_XFER_OUT] = "xfer-out", + [DNS_LOGCATEGORY_DISPATCH] = "dispatch", + [DNS_LOGCATEGORY_LAME_SERVERS] = "lame-servers", + [DNS_LOGCATEGORY_EDNS_DISABLED] = "edns-disabled", + [DNS_LOGCATEGORY_RPZ] = "rpz", + [DNS_LOGCATEGORY_RRL] = "rate-limit", + [DNS_LOGCATEGORY_CNAME] = "cname", + [DNS_LOGCATEGORY_SPILL] = "spill", + [DNS_LOGCATEGORY_DNSTAP] = "dnstap", + [DNS_LOGCATEGORY_ZONELOAD] = "zoneload", + [DNS_LOGCATEGORY_NSID] = "nsid", + [DNS_LOGCATEGORY_RPZ_PASSTHRU] = "rpz-passthru", + /* ns categories */ + [NS_LOGCATEGORY_CLIENT] = "client", + [NS_LOGCATEGORY_NETWORK] = "network", + [NS_LOGCATEGORY_UPDATE] = "update", + [NS_LOGCATEGORY_QUERIES] = "queries", + [NS_LOGCATEGORY_UPDATE_SECURITY] = "update-security", + [NS_LOGCATEGORY_QUERY_ERRORS] = "query-errors", + [NS_LOGCATEGORY_TAT] = "trust-anchor-telemetry", + [NS_LOGCATEGORY_SERVE_STALE] = "serve-stale", + /* cfg categories */ + [CFG_LOGCATEGORY_CONFIG] = "config", + /* named categories */ + [NAMED_LOGCATEGORY_UNMATCHED] = "unmatched", + /* delv categories */ + [DELV_LOGCATEGORY_DEFAULT] = "delv", +}; /*! * See above comment for categories, and apply it to modules. */ -isc_logmodule_t isc_modules[] = { { "socket", 0 }, { "time", 0 }, - { "interface", 0 }, { "timer", 0 }, - { "file", 0 }, { "netmgr", 0 }, - { "other", 0 }, { NULL, 0 } }; +static const char *modules_description[] = { + /* isc modules */ + [ISC_LOGMODULE_NONE] = "no_module", + [ISC_LOGMODULE_SOCKET] = "socket", + [ISC_LOGMODULE_TIME] = "time", + [ISC_LOGMODULE_INTERFACE] = "interface", + [ISC_LOGMODULE_TIMER] = "timer", + [ISC_LOGMODULE_FILE] = "file", + [ISC_LOGMODULE_NETMGR] = "netmgr", + [ISC_LOGMODULE_OTHER] = "other", + /* dns modules */ + [DNS_LOGMODULE_DB] = "dns/db", + [DNS_LOGMODULE_RBTDB] = "dns/rbtdb", + [DNS_LOGMODULE_RBT] = "dns/rbt", + [DNS_LOGMODULE_RDATA] = "dns/rdata", + [DNS_LOGMODULE_MASTER] = "dns/master", + [DNS_LOGMODULE_MESSAGE] = "dns/message", + [DNS_LOGMODULE_CACHE] = "dns/cache", + [DNS_LOGMODULE_CONFIG] = "dns/config", + [DNS_LOGMODULE_RESOLVER] = "dns/resolver", + [DNS_LOGMODULE_ZONE] = "dns/zone", + [DNS_LOGMODULE_JOURNAL] = "dns/journal", + [DNS_LOGMODULE_ADB] = "dns/adb", + [DNS_LOGMODULE_XFER_IN] = "dns/xfrin", + [DNS_LOGMODULE_XFER_OUT] = "dns/xfrout", + [DNS_LOGMODULE_ACL] = "dns/acl", + [DNS_LOGMODULE_VALIDATOR] = "dns/validator", + [DNS_LOGMODULE_DISPATCH] = "dns/dispatch", + [DNS_LOGMODULE_REQUEST] = "dns/request", + [DNS_LOGMODULE_MASTERDUMP] = "dns/masterdump", + [DNS_LOGMODULE_TSIG] = "dns/tsig", + [DNS_LOGMODULE_TKEY] = "dns/tkey", + [DNS_LOGMODULE_SDB] = "dns/sdb", + [DNS_LOGMODULE_DIFF] = "dns/diff", + [DNS_LOGMODULE_HINTS] = "dns/hints", + [DNS_LOGMODULE_UNUSED1] = "dns/unused1", + [DNS_LOGMODULE_DLZ] = "dns/dlz", + [DNS_LOGMODULE_DNSSEC] = "dns/dnssec", + [DNS_LOGMODULE_CRYPTO] = "dns/crypto", + [DNS_LOGMODULE_PACKETS] = "dns/packets", + [DNS_LOGMODULE_NTA] = "dns/nta", + [DNS_LOGMODULE_DYNDB] = "dns/dyndb", + [DNS_LOGMODULE_DNSTAP] = "dns/dnstap", + [DNS_LOGMODULE_SSU] = "dns/ssu", + [DNS_LOGMODULE_QP] = "dns/qp", + /* ns modules */ + [NS_LOGMODULE_CLIENT] = "ns/client", + [NS_LOGMODULE_QUERY] = "ns/query", + [NS_LOGMODULE_INTERFACEMGR] = "ns/interfacemgr", + [NS_LOGMODULE_UPDATE] = "ns/update", + [NS_LOGMODULE_XFER_IN] = "ns/xfer-in", + [NS_LOGMODULE_XFER_OUT] = "ns/xfer-out", + [NS_LOGMODULE_NOTIFY] = "ns/notify", + [NS_LOGMODULE_HOOKS] = "ns/hooks", + /* cfg modules */ + [CFG_LOGMODULE_PARSER] = "isccfg/parser", + /* named modules */ + [NAMED_LOGMODULE_MAIN] = "main", + [NAMED_LOGMODULE_SERVER] = "server", + [NAMED_LOGMODULE_CONTROL] = "control", + /* delv modules */ + [DELV_LOGMODULE_DEFAULT] = "delv", +}; /*! * This essentially constant structure must be filled in at run time, @@ -200,11 +288,8 @@ static isc_log_t *isc__lctx = NULL; * Forward declarations. */ static void -assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, - const isc_logmodule_t *module, isc_logchannel_t *channel); - -static void -sync_channellist(isc_logconfig_t *lcfg); +assignchannel(isc_logconfig_t *lcfg, const isc_logcategory_t category, + const isc_logmodule_t module, isc_logchannel_t *channel); static void sync_highest_level(isc_logconfig_t *lcfg); @@ -213,7 +298,7 @@ static isc_result_t greatest_version(isc_logfile_t *file, int versions, int *greatest); static void -isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, +isc_log_doit(isc_logcategory_t category, isc_logmodule_t module, int level, const char *format, va_list args) ISC_FORMAT_PRINTF(4, 0); /*@{*/ @@ -239,7 +324,6 @@ isc_logconfig_create(isc_logconfig_t **lcfgp) { REQUIRE(lcfgp != NULL && *lcfgp == NULL); REQUIRE(VALID_CONTEXT(isc__lctx)); - isc_logdestination_t destination; int level = ISC_LOG_INFO; isc_logconfig_t *lcfg = isc_mem_get(isc__lctx->mctx, sizeof(*lcfg)); @@ -255,17 +339,11 @@ isc_logconfig_create(isc_logconfig_t **lcfgp) { * Create the default channels: * default_syslog, default_stderr, default_debug and null. */ - destination.facility = LOG_DAEMON; isc_log_createchannel(lcfg, "default_syslog", ISC_LOG_TOSYSLOG, level, - &destination, 0); + ISC_LOGDESTINATION_SYSLOG(LOG_DAEMON), 0); - destination.file = (isc_logfile_t){ - .stream = stderr, - .versions = ISC_LOG_ROLLNEVER, - .suffix = isc_log_rollsuffix_increment, - }; isc_log_createchannel(lcfg, "default_stderr", ISC_LOG_TOFILEDESC, level, - &destination, ISC_LOG_PRINTTIME); + ISC_LOGDESTINATION_STDERR, ISC_LOG_PRINTTIME); /* * Set the default category's channel to default_stderr, @@ -274,13 +352,9 @@ isc_logconfig_create(isc_logconfig_t **lcfgp) { */ default_channel.channel = ISC_LIST_HEAD(lcfg->channels); - destination.file = (isc_logfile_t){ - .stream = stderr, - .versions = ISC_LOG_ROLLNEVER, - .suffix = isc_log_rollsuffix_increment, - }; isc_log_createchannel(lcfg, "default_debug", ISC_LOG_TOFILEDESC, - ISC_LOG_DYNAMIC, &destination, ISC_LOG_PRINTTIME); + ISC_LOG_DYNAMIC, ISC_LOGDESTINATION_STDERR, + ISC_LOG_PRINTTIME); isc_log_createchannel(lcfg, "null", ISC_LOG_TONULL, ISC_LOG_DYNAMIC, NULL, 0); @@ -301,13 +375,6 @@ isc_logconfig_set(isc_logconfig_t *lcfg) { REQUIRE(VALID_CONFIG(lcfg)); REQUIRE(lcfg->lctx == isc__lctx); - /* - * Ensure that lcfg->channellist_count == lctx->category_count. - * They won't be equal if isc_log_usechannel has not been called - * since any call to isc_log_registercategories. - */ - sync_channellist(lcfg); - isc_logconfig_t *old_cfg = rcu_xchg_pointer(&isc__lctx->logconfig, lcfg); sync_highest_level(lcfg); @@ -324,7 +391,6 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) { isc_mem_t *mctx; isc_logchannel_t *channel; char *filename; - unsigned int i; REQUIRE(lcfgp != NULL && VALID_CONFIG(*lcfgp)); @@ -365,19 +431,15 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) { isc_mem_put(mctx, channel, sizeof(*channel)); } - for (i = 0; i < lcfg->channellist_count; i++) { - isc_logchannellist_t *item; - while ((item = ISC_LIST_HEAD(lcfg->channellists[i])) != NULL) { + for (size_t i = 0; i < ARRAY_SIZE(lcfg->channellists); i++) { + isc_logchannellist_t *item = NULL, *next = NULL; + ISC_LIST_FOREACH_SAFE (lcfg->channellists[i], item, link, next) + { ISC_LIST_UNLINK(lcfg->channellists[i], item, link); isc_mem_put(mctx, item, sizeof(*item)); } } - if (lcfg->channellist_count > 0) { - isc_mem_cput(mctx, lcfg->channellists, lcfg->channellist_count, - sizeof(ISC_LIST(isc_logchannellist_t))); - } - lcfg->dynamic = false; if (lcfg->tag != NULL) { isc_mem_free(lcfg->lctx->mctx, lcfg->tag); @@ -389,144 +451,20 @@ isc_logconfig_destroy(isc_logconfig_t **lcfgp) { isc_mem_put(mctx, lcfg, sizeof(*lcfg)); } -void -isc_log_registercategories(isc_logcategory_t categories[]) { - REQUIRE(VALID_CONTEXT(isc__lctx)); - REQUIRE(categories != NULL && categories[0].name != NULL); - - /* - * XXXDCL This somewhat sleazy situation of using the last pointer - * in one category array to point to the next array exists because - * this registration function returns void and I didn't want to have - * change everything that used it by making it return an isc_result_t. - * It would need to do that if it had to allocate memory to store - * pointers to each array passed in. - */ - if (isc__lctx->categories == NULL) { - isc__lctx->categories = categories; - } else { - /* - * Adjust the last (NULL) pointer of the already registered - * categories to point to the incoming array. - */ - isc_logcategory_t *catp = NULL; - for (catp = isc__lctx->categories; catp->name != NULL;) { - if (catp->id == UINT_MAX) { - /* - * The name pointer points to the next array. - * Ick. - */ - catp = UNCONST(catp->name); - } else { - catp++; - } - } - - catp->name = (void *)categories; - catp->id = UINT_MAX; - } - - /* - * Update the id number of the category with its new global id. - */ - for (isc_logcategory_t *catp = categories; catp->name != NULL; catp++) { - catp->id = isc__lctx->category_count++; - } -} - -isc_logcategory_t * +isc_logcategory_t isc_log_categorybyname(const char *name) { - isc_logcategory_t *catp; - REQUIRE(VALID_CONTEXT(isc__lctx)); REQUIRE(name != NULL); - for (catp = isc__lctx->categories; catp->name != NULL;) { - if (catp->id == UINT_MAX) { - /* - * catp is neither modified nor returned to the - * caller, so removing its const qualifier is ok. - */ - catp = UNCONST(catp->name); - } else { - if (strcmp(catp->name, name) == 0) { - return (catp); - } - catp++; + for (isc_logcategory_t category = 0; category < ISC_LOGCATEGORY_MAX; + category++) + { + if (strcmp(categories_description[category], name) == 0) { + return (category); } } - return (NULL); -} - -void -isc_log_registermodules(isc_logmodule_t modules[]) { - REQUIRE(VALID_CONTEXT(isc__lctx)); - REQUIRE(modules != NULL && modules[0].name != NULL); - - /* - * XXXDCL This somewhat sleazy situation of using the last pointer - * in one category array to point to the next array exists because - * this registration function returns void and I didn't want to have - * change everything that used it by making it return an isc_result_t. - * It would need to do that if it had to allocate memory to store - * pointers to each array passed in. - */ - if (isc__lctx->modules == NULL) { - isc__lctx->modules = modules; - } else { - /* - * Adjust the last (NULL) pointer of the already registered - * modules to point to the incoming array. - */ - isc_logmodule_t *modp = NULL; - for (modp = isc__lctx->modules; modp->name != NULL;) { - if (modp->id == UINT_MAX) { - /* - * The name pointer points to the next array. - * Ick. - */ - modp = UNCONST(modp->name); - } else { - modp++; - } - } - - modp->name = (void *)modules; - modp->id = UINT_MAX; - } - - /* - * Update the id number of the module with its new global id. - */ - for (isc_logmodule_t *modp = modules; modp->name != NULL; modp++) { - modp->id = isc__lctx->module_count++; - } -} - -isc_logmodule_t * -isc_log_modulebyname(const char *name) { - isc_logmodule_t *modp; - - REQUIRE(VALID_CONTEXT(isc__lctx)); - REQUIRE(name != NULL); - - for (modp = isc__lctx->modules; modp->name != NULL;) { - if (modp->id == UINT_MAX) { - /* - * modp is neither modified nor returned to the - * caller, so removing its const qualifier is ok. - */ - modp = UNCONST(modp->name); - } else { - if (strcmp(modp->name, name) == 0) { - return (modp); - } - modp++; - } - } - - return (NULL); + return (ISC_LOGCATEGORY_INVALID); } void @@ -610,15 +548,14 @@ isc_log_createchannel(isc_logconfig_t *lcfg, const char *name, isc_result_t isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, - const isc_logcategory_t *category, - const isc_logmodule_t *module) { + const isc_logcategory_t category, + const isc_logmodule_t module) { REQUIRE(VALID_CONFIG(lcfg)); REQUIRE(name != NULL); - - isc_log_t *lctx = lcfg->lctx; - - REQUIRE(category == NULL || category->id < lctx->category_count); - REQUIRE(module == NULL || module->id < lctx->module_count); + REQUIRE(category == ISC_LOGCATEGORY_ALL || + (category >= 0 && category < ISC_LOGCATEGORY_MAX)); + REQUIRE(module == ISC_LOGMODULE_ALL || + (module >= 0 && module < ISC_LOGMODULE_MAX)); isc_logchannel_t *channel; for (channel = ISC_LIST_HEAD(lcfg->channels); channel != NULL; @@ -633,14 +570,14 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, return (ISC_R_NOTFOUND); } - if (category != NULL) { - assignchannel(lcfg, category->id, module, channel); + if (category != ISC_LOGCATEGORY_ALL) { + assignchannel(lcfg, category, module, channel); } else { /* * Assign to all categories. Note that this includes * the default channel. */ - for (size_t i = 0; i < lctx->category_count; i++) { + for (size_t i = 0; i < ISC_LOGCATEGORY_MAX; i++) { assignchannel(lcfg, i, module, channel); } } @@ -658,7 +595,7 @@ isc_log_usechannel(isc_logconfig_t *lcfg, const char *name, } void -isc_log_write(isc_logcategory_t *category, isc_logmodule_t *module, int level, +isc_log_write(isc_logcategory_t category, isc_logmodule_t module, int level, const char *format, ...) { va_list args; @@ -672,7 +609,7 @@ isc_log_write(isc_logcategory_t *category, isc_logmodule_t *module, int level, } void -isc_log_vwrite(isc_logcategory_t *category, isc_logmodule_t *module, int level, +isc_log_vwrite(isc_logcategory_t category, isc_logmodule_t module, int level, const char *format, va_list args) { /* * Contract checking is done in isc_log_doit(). @@ -777,28 +714,24 @@ isc_log_closefilelogs(void) { ****/ static void -assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, - const isc_logmodule_t *module, isc_logchannel_t *channel) { +assignchannel(isc_logconfig_t *lcfg, const isc_logcategory_t category, + const isc_logmodule_t module, isc_logchannel_t *channel) { REQUIRE(VALID_CONFIG(lcfg)); REQUIRE(channel != NULL); isc_log_t *lctx = lcfg->lctx; - REQUIRE(category_id < lctx->category_count); - REQUIRE(module == NULL || module->id < lctx->module_count); - - /* - * Ensure lcfg->channellist_count == lctx->category_count. - */ - sync_channellist(lcfg); + REQUIRE(category > ISC_LOGCATEGORY_INVALID && + category < ISC_LOGCATEGORY_MAX); + REQUIRE(module == ISC_LOGMODULE_ALL || + (module > ISC_LOGMODULE_INVALID && module < ISC_LOGMODULE_MAX)); isc_logchannellist_t *new_item = isc_mem_get(lctx->mctx, sizeof(*new_item)); new_item->channel = channel; new_item->module = module; - ISC_LIST_INITANDPREPEND(lcfg->channellists[category_id], new_item, - link); + ISC_LIST_INITANDPREPEND(lcfg->channellists[category], new_item, link); /* * Remember the highest logging level set by any channel in the @@ -815,29 +748,6 @@ assignchannel(isc_logconfig_t *lcfg, unsigned int category_id, } } -/* - * This would ideally be part of isc_log_registercategories(), except then - * that function would have to return isc_result_t instead of void. - */ -static void -sync_channellist(isc_logconfig_t *lcfg) { - REQUIRE(VALID_CONFIG(lcfg)); - - isc_log_t *lctx = lcfg->lctx; - - REQUIRE(lctx->category_count != 0); - - if (lctx->category_count == lcfg->channellist_count) { - return; - } - - lcfg->channellists = isc_mem_creget( - lctx->mctx, lcfg->channellists, lcfg->channellist_count, - lctx->category_count, sizeof(ISC_LIST(isc_logchannellist_t))); - - lcfg->channellist_count = lctx->category_count; -} - static void sync_highest_level(isc_logconfig_t *lcfg) { atomic_store(&isc__lctx->highest_level, lcfg->highest_level); @@ -1329,7 +1239,7 @@ isc_log_wouldlog(int level) { } static void -isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, +isc_log_doit(isc_logcategory_t category, isc_logmodule_t module, int level, const char *format, va_list args) { int syslog_level; const char *time_string; @@ -1347,23 +1257,11 @@ isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, isc_result_t result; REQUIRE(isc__lctx == NULL || VALID_CONTEXT(isc__lctx)); - REQUIRE(category != NULL); - REQUIRE(module != NULL); + REQUIRE(category >= 0 && category < ISC_LOGCATEGORY_MAX); + REQUIRE(module >= 0 && module < ISC_LOGMODULE_MAX); REQUIRE(level != ISC_LOG_DYNAMIC); REQUIRE(format != NULL); - /* - * Programs can use libraries that use this logging code without - * wanting to do any logging, thus the log context is allowed to - * be non-existent. - */ - if (isc__lctx == NULL) { - return; - } - - REQUIRE(category->id < isc__lctx->category_count); - REQUIRE(module->id < isc__lctx->module_count); - if (!isc_log_wouldlog(level)) { return; } @@ -1382,12 +1280,8 @@ isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, goto unlock; } - category_channels = ISC_LIST_HEAD(lcfg->channellists[category->id]); + category_channels = ISC_LIST_HEAD(lcfg->channellists[category]); - /* - * XXXDCL add duplicate filtering? (To not write multiple times - * to the same source via various channels). - */ do { /* * If the channel list end was reached and a match was @@ -1417,7 +1311,7 @@ isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, category_channels = &default_channel; } - if (category_channels->module != NULL && + if (category_channels->module != ISC_LOGMODULE_ALL && category_channels->module != module) { category_channels = ISC_LIST_NEXT(category_channels, @@ -1572,11 +1466,10 @@ isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, printtime ? time_string : "", printtime ? " " : "", printtag ? lcfg->tag : "", printcolon ? ": " : "", - printcategory ? category->name : "", + printcategory ? categories_description[category] + : "", printcategory ? ": " : "", - printmodule ? (module != NULL ? module->name - : "no_module") - : "", + printmodule ? modules_description[module] : "", printmodule ? ": " : "", printlevel ? level_string : "", isc__lctx->buffer); @@ -1620,11 +1513,10 @@ isc_log_doit(isc_logcategory_t *category, isc_logmodule_t *module, int level, printtime ? time_string : "", printtime ? " " : "", printtag ? lcfg->tag : "", printcolon ? ": " : "", - printcategory ? category->name : "", + printcategory ? categories_description[category] + : "", printcategory ? ": " : "", - printmodule ? (module != NULL ? module->name - : "no_module") - : "", + printmodule ? modules_description[module] : "", printmodule ? ": " : "", printlevel ? level_string : "", isc__lctx->buffer); @@ -1660,13 +1552,9 @@ isc__log_initialize(void) { isc_mutex_init(&isc__lctx->lock); - isc_log_registercategories(isc_categories); - isc_log_registermodules(isc_modules); - /* Create default logging configuration */ isc_logconfig_t *lcfg = NULL; isc_logconfig_create(&lcfg); - sync_channellist(lcfg); atomic_init(&isc__lctx->highest_level, lcfg->highest_level); atomic_init(&isc__lctx->dynamic, lcfg->dynamic); diff --git a/lib/isc/tls.c b/lib/isc/tls.c index 825cce13b5..cab00f402f 100644 --- a/lib/isc/tls.c +++ b/lib/isc/tls.c @@ -1687,12 +1687,17 @@ isc__tls_toresult(isc_result_t fallback) { } isc_result_t -isc__tlserr2result(isc_logcategory_t *category, isc_logmodule_t *module, +isc__tlserr2result(isc_logcategory_t category, isc_logmodule_t module, const char *funcname, isc_result_t fallback, const char *file, int line) { isc_result_t result = isc__tls_toresult(fallback); - if (category == NULL) { + /* + * This is an exception - normally, we don't allow this, but the + * compatibility shims in dst_openssl.h needs a call that just + * translates the error code and don't do any logging. + */ + if (category == ISC_LOGCATEGORY_INVALID) { goto done; } diff --git a/lib/isccfg/Makefile.am b/lib/isccfg/Makefile.am index 2b1f27e3dd..cabf5805f1 100644 --- a/lib/isccfg/Makefile.am +++ b/lib/isccfg/Makefile.am @@ -10,7 +10,6 @@ libisccfg_la_HEADERS = \ include/isccfg/duration.h \ include/isccfg/grammar.h \ include/isccfg/kaspconf.h \ - include/isccfg/log.h \ include/isccfg/namedconf.h libisccfg_la_SOURCES = \ @@ -20,7 +19,6 @@ libisccfg_la_SOURCES = \ dnsconf.c \ duration.c \ kaspconf.c \ - log.c \ namedconf.c \ parser.c diff --git a/lib/isccfg/aclconf.c b/lib/isccfg/aclconf.c index ebe18b6dbe..daf012d0ed 100644 --- a/lib/isccfg/aclconf.c +++ b/lib/isccfg/aclconf.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/lib/isccfg/check.c b/lib/isccfg/check.c index f5fa78e14a..87c85921db 100644 --- a/lib/isccfg/check.c +++ b/lib/isccfg/check.c @@ -5888,7 +5888,8 @@ check_logging(const cfg_obj_t *config, isc_mem_t *mctx) { { category = cfg_listelt_value(element); catname = cfg_obj_asstring(cfg_tuple_get(category, "name")); - if (isc_log_categorybyname(catname) == NULL) { + if (isc_log_categorybyname(catname) == ISC_LOGCATEGORY_INVALID) + { cfg_obj_log(category, ISC_LOG_ERROR, "undefined category: '%s'", catname); result = ISC_R_FAILURE; diff --git a/lib/isccfg/include/isccfg/log.h b/lib/isccfg/include/isccfg/log.h deleted file mode 100644 index 53bc2a48a1..0000000000 --- a/lib/isccfg/include/isccfg/log.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/*! \file isccfg/log.h */ - -#include -#include - -extern isc_logcategory_t cfg_categories[]; -extern isc_logmodule_t cfg_modules[]; - -#define CFG_LOGCATEGORY_CONFIG (&cfg_categories[0]) - -#define CFG_LOGMODULE_PARSER (&cfg_modules[0]) - -ISC_LANG_BEGINDECLS - -void -cfg_log_init(void); -/*%< - * Make the libisccfg categories and modules available for use with the - * ISC logging library. - * - * Requires: - *\li cfg_log_init() is called only once. - * - * Ensures: - * \li The categories and modules defined above are available for - * use by isc_log_usechannnel() and isc_log_write(). - */ - -ISC_LANG_ENDDECLS diff --git a/lib/isccfg/kaspconf.c b/lib/isccfg/kaspconf.c index 7dad436449..98a49f7004 100644 --- a/lib/isccfg/kaspconf.c +++ b/lib/isccfg/kaspconf.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include #include diff --git a/lib/isccfg/log.c b/lib/isccfg/log.c deleted file mode 100644 index 54ec3ad6b0..0000000000 --- a/lib/isccfg/log.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! \file */ - -#include - -#include - -/*% - * When adding a new category, be sure to add the appropriate - * \#define to . - */ -isc_logcategory_t cfg_categories[] = { { "config", 0 }, { NULL, 0 } }; - -/*% - * When adding a new module, be sure to add the appropriate - * \#define to . - */ -isc_logmodule_t cfg_modules[] = { { "isccfg/parser", 0 }, { NULL, 0 } }; - -void -cfg_log_init(void) { - isc_log_registercategories(cfg_categories); - isc_log_registermodules(cfg_modules); -} diff --git a/lib/isccfg/namedconf.c b/lib/isccfg/namedconf.c index a1b9dc3d1f..21496e0bc7 100644 --- a/lib/isccfg/namedconf.c +++ b/lib/isccfg/namedconf.c @@ -19,6 +19,7 @@ #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #include #include -#include #include #define TOKEN_STRING(pctx) (pctx->token.value.as_textregion.base) diff --git a/lib/isccfg/parser.c b/lib/isccfg/parser.c index 3cd8308dec..e882eb9b8f 100644 --- a/lib/isccfg/parser.c +++ b/lib/isccfg/parser.c @@ -67,7 +67,6 @@ #include #include -#include /* Shorthand */ #define CAT CFG_LOGCATEGORY_CONFIG diff --git a/lib/ns/Makefile.am b/lib/ns/Makefile.am index 39b64a76b3..a1533c9db2 100644 --- a/lib/ns/Makefile.am +++ b/lib/ns/Makefile.am @@ -12,7 +12,6 @@ libns_la_HEADERS = \ include/ns/hooks.h \ include/ns/interfacemgr.h \ include/ns/listenlist.h \ - include/ns/log.h \ include/ns/notify.h \ include/ns/query.h \ include/ns/server.h \ @@ -28,7 +27,6 @@ libns_la_SOURCES = \ hooks.c \ interfacemgr.c \ listenlist.c \ - log.c \ notify.c \ probes.d \ query.c \ diff --git a/lib/ns/client.c b/lib/ns/client.c index 7bbe6fa786..cc76632f0b 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -58,7 +58,6 @@ #include #include -#include #include #include #include @@ -2749,9 +2748,8 @@ ns_client_name(ns_client_t *client, char *peerbuf, size_t len) { } void -ns_client_logv(ns_client_t *client, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *fmt, - va_list ap) { +ns_client_logv(ns_client_t *client, isc_logcategory_t category, + isc_logmodule_t module, int level, const char *fmt, va_list ap) { char msgbuf[4096]; char signerbuf[DNS_NAME_FORMATSIZE], qnamebuf[DNS_NAME_FORMATSIZE]; char peerbuf[ISC_SOCKADDR_FORMATSIZE]; @@ -2799,8 +2797,8 @@ ns_client_logv(ns_client_t *client, isc_logcategory_t *category, } void -ns_client_log(ns_client_t *client, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *fmt, ...) { +ns_client_log(ns_client_t *client, isc_logcategory_t category, + isc_logmodule_t module, int level, const char *fmt, ...) { va_list ap; if (!isc_log_wouldlog(level)) { diff --git a/lib/ns/hooks.c b/lib/ns/hooks.c index a14cda0071..aaf9d07dd8 100644 --- a/lib/ns/hooks.c +++ b/lib/ns/hooks.c @@ -30,7 +30,6 @@ #include #include -#include #include #define CHECK(op) \ diff --git a/lib/ns/include/ns/client.h b/lib/ns/include/ns/client.h index 89ee79a67c..bfb4f3a76d 100644 --- a/lib/ns/include/ns/client.h +++ b/lib/ns/include/ns/client.h @@ -405,13 +405,13 @@ ns_client_checkacl(ns_client_t *client, isc_sockaddr_t *sockaddr, */ void -ns_client_log(ns_client_t *client, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *fmt, ...) +ns_client_log(ns_client_t *client, isc_logcategory_t category, + isc_logmodule_t module, int level, const char *fmt, ...) ISC_FORMAT_PRINTF(5, 6); void -ns_client_logv(ns_client_t *client, isc_logcategory_t *category, - isc_logmodule_t *module, int level, const char *fmt, va_list ap) +ns_client_logv(ns_client_t *client, isc_logcategory_t category, + isc_logmodule_t module, int level, const char *fmt, va_list ap) ISC_FORMAT_PRINTF(5, 0); void diff --git a/lib/ns/include/ns/log.h b/lib/ns/include/ns/log.h deleted file mode 100644 index 884a0458c9..0000000000 --- a/lib/ns/include/ns/log.h +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -#pragma once - -/*! \file */ - -#include -#include - -extern isc_logcategory_t ns_categories[]; -extern isc_logmodule_t ns_modules[]; - -#define NS_LOGCATEGORY_CLIENT (&ns_categories[0]) -#define NS_LOGCATEGORY_NETWORK (&ns_categories[1]) -#define NS_LOGCATEGORY_UPDATE (&ns_categories[2]) -#define NS_LOGCATEGORY_QUERIES (&ns_categories[3]) -#define NS_LOGCATEGORY_UPDATE_SECURITY (&ns_categories[4]) -#define NS_LOGCATEGORY_QUERY_ERRORS (&ns_categories[5]) -#define NS_LOGCATEGORY_TAT (&ns_categories[6]) -#define NS_LOGCATEGORY_SERVE_STALE (&ns_categories[7]) - -/* - * Backwards compatibility. - */ -#define NS_LOGCATEGORY_GENERAL ISC_LOGCATEGORY_GENERAL - -#define NS_LOGMODULE_CLIENT (&ns_modules[0]) -#define NS_LOGMODULE_QUERY (&ns_modules[1]) -#define NS_LOGMODULE_INTERFACEMGR (&ns_modules[2]) -#define NS_LOGMODULE_UPDATE (&ns_modules[3]) -#define NS_LOGMODULE_XFER_IN (&ns_modules[4]) -#define NS_LOGMODULE_XFER_OUT (&ns_modules[5]) -#define NS_LOGMODULE_NOTIFY (&ns_modules[6]) -#define NS_LOGMODULE_HOOKS (&ns_modules[7]) - -void -ns_log_init(void); -/*%< - * Make the libns categories and modules available for use with the - * ISC logging library. - * - * Requires: - *\li lctx is a valid logging context. - * - *\li ns_log_init() is called only once. - * - * Ensures: - *\li The categories and modules defined above are available for - * use by isc_log_usechannnel() and isc_log_write(). - */ diff --git a/lib/ns/interfacemgr.c b/lib/ns/interfacemgr.c index 9c952ee928..6f227143d6 100644 --- a/lib/ns/interfacemgr.c +++ b/lib/ns/interfacemgr.c @@ -16,6 +16,7 @@ #include #include +#include #include #include #include @@ -29,7 +30,6 @@ #include #include -#include #include #include diff --git a/lib/ns/listenlist.c b/lib/ns/listenlist.c index acaaece2d1..8e04c4f2ac 100644 --- a/lib/ns/listenlist.c +++ b/lib/ns/listenlist.c @@ -15,6 +15,7 @@ #include +#include #include #include #include @@ -22,7 +23,6 @@ #include #include -#include static void destroy(ns_listenlist_t *list); diff --git a/lib/ns/log.c b/lib/ns/log.c deleted file mode 100644 index 6083085f2f..0000000000 --- a/lib/ns/log.c +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) Internet Systems Consortium, Inc. ("ISC") - * - * SPDX-License-Identifier: MPL-2.0 - * - * This Source Code Form is subject to the terms of the Mozilla Public - * License, v. 2.0. If a copy of the MPL was not distributed with this - * file, you can obtain one at https://mozilla.org/MPL/2.0/. - * - * See the COPYRIGHT file distributed with this work for additional - * information regarding copyright ownership. - */ - -/*! \file */ - -#include -#include - -#include - -#ifndef ISC_FACILITY -#define ISC_FACILITY LOG_DAEMON -#endif /* ifndef ISC_FACILITY */ - -/*% - * When adding a new category, be sure to add the appropriate - * \#define to - */ -isc_logcategory_t ns_categories[] = { { "client", 0 }, - { "network", 0 }, - { "update", 0 }, - { "queries", 0 }, - { "update-security", 0 }, - { "query-errors", 0 }, - { "trust-anchor-telemetry", 0 }, - { "serve-stale", 0 }, - { NULL, 0 } }; - -/*% - * When adding a new module, be sure to add the appropriate - * \#define to . - */ -isc_logmodule_t ns_modules[] = { - { "ns/client", 0 }, { "ns/query", 0 }, { "ns/interfacemgr", 0 }, - { "ns/update", 0 }, { "ns/xfer-in", 0 }, { "ns/xfer-out", 0 }, - { "ns/notify", 0 }, { "ns/hooks", 0 }, { NULL, 0 } -}; - -void -ns_log_init(void) { - isc_log_registercategories(ns_categories); - isc_log_registermodules(ns_modules); -} diff --git a/lib/ns/notify.c b/lib/ns/notify.c index f2ae6e5f84..b973f288c6 100644 --- a/lib/ns/notify.c +++ b/lib/ns/notify.c @@ -22,7 +22,6 @@ #include #include -#include #include #include diff --git a/lib/ns/query.c b/lib/ns/query.c index dfd7cc60fc..e7fce1b101 100644 --- a/lib/ns/query.c +++ b/lib/ns/query.c @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -67,7 +68,6 @@ #include #include #include -#include #include #include #include @@ -1195,9 +1195,9 @@ rpz_log_rewrite(ns_client_t *client, bool disabled, dns_rpz_policy_t policy, dns_rdatatype_format(rdataset->type, typebuf, sizeof(typebuf)); /* It's possible to have a separate log channel for rpz passthru. */ - isc_logcategory_t *log_cat = (policy == DNS_RPZ_POLICY_PASSTHRU) - ? DNS_LOGCATEGORY_RPZ_PASSTHRU - : DNS_LOGCATEGORY_RPZ; + isc_logcategory_t log_cat = (policy == DNS_RPZ_POLICY_PASSTHRU) + ? DNS_LOGCATEGORY_RPZ_PASSTHRU + : DNS_LOGCATEGORY_RPZ; ns_client_log(client, log_cat, NS_LOGMODULE_QUERY, DNS_RPZ_INFO_LEVEL, "%srpz %s %s rewrite %s/%s/%s via %s%s%s%s", @@ -6211,7 +6211,7 @@ fetch_callback(void *arg) { ns_client_t *client = resp->arg; dns_fetch_t *fetch = NULL; bool fetch_canceled = false; - isc_logcategory_t *logcategory = NS_LOGCATEGORY_QUERY_ERRORS; + isc_logcategory_t logcategory = NS_LOGCATEGORY_QUERY_ERRORS; isc_result_t result; int errorloglevel; query_ctx_t qctx; diff --git a/lib/ns/update.c b/lib/ns/update.c index ceeecbbf4d..dbc2a1590c 100644 --- a/lib/ns/update.c +++ b/lib/ns/update.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -48,7 +49,6 @@ #include #include -#include #include #include #include diff --git a/lib/ns/xfrout.c b/lib/ns/xfrout.c index 85c04d8863..35a08c38aa 100644 --- a/lib/ns/xfrout.c +++ b/lib/ns/xfrout.c @@ -15,6 +15,7 @@ #include #include +#include #include #include #include @@ -41,7 +42,6 @@ #include #include -#include #include #include #include diff --git a/tests/bench/qpmulti.c b/tests/bench/qpmulti.c index 6713ecf4c5..6c3678bb35 100644 --- a/tests/bench/qpmulti.c +++ b/tests/bench/qpmulti.c @@ -37,7 +37,6 @@ #include #include -#include #include #include @@ -158,8 +157,6 @@ init_logging(void) { isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; - dns_log_init(); - logconfig = isc_logconfig_get(); destination.file.stream = stderr; destination.file.name = NULL; @@ -174,7 +171,7 @@ init_logging(void) { #endif result = isc_log_usechannel(logconfig, "stderr", - ISC_LOGCATEGORY_DEFAULT, NULL); + ISC_LOGCATEGORY_DEFAULT, ISC_LOGMODULE_ALL); INSIST(result == ISC_R_SUCCESS); } diff --git a/tests/dns/qpmulti_test.c b/tests/dns/qpmulti_test.c index 1718e86825..04392c0b68 100644 --- a/tests/dns/qpmulti_test.c +++ b/tests/dns/qpmulti_test.c @@ -33,7 +33,6 @@ #include #include -#include #include #include @@ -72,8 +71,6 @@ setup_logging(void) { isc_logdestination_t destination; isc_logconfig_t *logconfig = NULL; - dns_log_init(); - logconfig = isc_logconfig_get(); destination.file.stream = stderr; destination.file.name = NULL; @@ -89,7 +86,7 @@ setup_logging(void) { #endif result = isc_log_usechannel(logconfig, "stderr", - ISC_LOGCATEGORY_DEFAULT, NULL); + ISC_LOGCATEGORY_DEFAULT, ISC_LOGMODULE_ALL); assert_int_equal(result, ISC_R_SUCCESS); } diff --git a/tests/dns/rbt_test.c b/tests/dns/rbt_test.c index 57f45926f6..9e1604230e 100644 --- a/tests/dns/rbt_test.c +++ b/tests/dns/rbt_test.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -43,7 +44,6 @@ #include #include -#include #include #include diff --git a/tests/isccfg/duration_test.c b/tests/isccfg/duration_test.c index ca4193760b..37e8b79c3b 100644 --- a/tests/isccfg/duration_test.c +++ b/tests/isccfg/duration_test.c @@ -37,32 +37,19 @@ #include -static isc_logcategory_t categories[] = { { "", 0 }, - { "client", 0 }, - { "network", 0 }, - { "update", 0 }, - { "queries", 0 }, - { "unmatched", 0 }, - { "update-security", 0 }, - { "query-errors", 0 }, - { NULL, 0 } }; - ISC_SETUP_TEST_IMPL(group) { isc_result_t result; - isc_logdestination_t destination; - isc_logconfig_t *logconfig = NULL; - isc_log_registercategories(categories); - - logconfig = isc_logconfig_get(); - destination.file.stream = stderr; - destination.file.name = NULL; - destination.file.versions = ISC_LOG_ROLLNEVER; - destination.file.maximum_size = 0; + isc_logconfig_t *logconfig = isc_logconfig_get(); + isc_logdestination_t destination = { + .file.stream = stderr, + .file.versions = ISC_LOG_ROLLNEVER, + }; isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, 0); - result = isc_log_usechannel(logconfig, "stderr", NULL, NULL); + result = isc_log_usechannel(logconfig, "stderr", ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL); if (result != ISC_R_SUCCESS) { return (-1); } diff --git a/tests/isccfg/parser_test.c b/tests/isccfg/parser_test.c index 0e9e3bf755..1181f2fcde 100644 --- a/tests/isccfg/parser_test.c +++ b/tests/isccfg/parser_test.c @@ -38,31 +38,17 @@ #include -static isc_logcategory_t categories[] = { { "", 0 }, - { "client", 0 }, - { "network", 0 }, - { "update", 0 }, - { "queries", 0 }, - { "unmatched", 0 }, - { "update-security", 0 }, - { "query-errors", 0 }, - { NULL, 0 } }; - ISC_SETUP_TEST_IMPL(group) { isc_result_t result; - isc_logdestination_t destination; - isc_logconfig_t *logconfig = NULL; - - isc_log_registercategories(categories); - - logconfig = isc_logconfig_get(); - destination.file.stream = stderr; - destination.file.name = NULL; - destination.file.versions = ISC_LOG_ROLLNEVER; - destination.file.maximum_size = 0; + isc_logconfig_t *logconfig = isc_logconfig_get(); + isc_logdestination_t destination = { + .file.stream = stderr, + .file.versions = ISC_LOG_ROLLNEVER, + }; isc_log_createchannel(logconfig, "stderr", ISC_LOG_TOFILEDESC, ISC_LOG_DYNAMIC, &destination, 0); - result = isc_log_usechannel(logconfig, "stderr", NULL, NULL); + result = isc_log_usechannel(logconfig, "stderr", ISC_LOGCATEGORY_ALL, + ISC_LOGMODULE_ALL); if (result != ISC_R_SUCCESS) { return (-1); diff --git a/tests/libtest/dns.c b/tests/libtest/dns.c index e4ba0e39a6..2d75700b1d 100644 --- a/tests/libtest/dns.c +++ b/tests/libtest/dns.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,6 @@ #include #include #include -#include #include #include #include diff --git a/tests/libtest/ns.c b/tests/libtest/ns.c index f45c35c220..10038fc059 100644 --- a/tests/libtest/ns.c +++ b/tests/libtest/ns.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -39,7 +40,6 @@ #include #include #include -#include #include #include #include diff --git a/util/check-categories.sh b/util/check-categories.sh index 170aea9543..2f5909181f 100644 --- a/util/check-categories.sh +++ b/util/check-categories.sh @@ -12,10 +12,11 @@ # information regarding copyright ownership. list1=$( - grep LOGCATEGORY lib/*/include/*/*.h bin/named/include/named/*.h \ - | grep "#define.*(&" \ + grep -h LOGCATEGORY lib/*/include/*/*.h bin/named/include/named/*.h \ + | grep -E "^[[:space:]]+[^[:space:]]+_LOGCATEGORY_[^[:space:]]+([[:space:]]+=[[:space:]]+[-0-9]+)?," \ + | grep -Ev "ISC_LOGCATEGORY_(MAX|INVALID)" \ | sed -e 's/.*LOGCATEGORY_\([A-Z_]*\).*/\1/' -e 's/^RRL$/rate-limit/' \ - | tr '[A-Z]' '[a-z]' \ + | tr 'A-Z' 'a-z' \ | tr _ - \ | sed 's/^tat$/trust-anchor-telemetry/' \ | sort -u