From 3027f59f6f4c30fbaaa24a83ec5d0482c4a6dc32 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Wed, 11 May 2022 15:38:54 -0700 Subject: [PATCH] move ADB and resolver stats out of the view object for better object separation, ADB and resolver statistics counters are now stored in the ADB and resolver objects themsevles, rather than in the associated view. --- bin/named/server.c | 27 +++++----- bin/named/statschannel.c | 74 ++++++++++++++++----------- lib/dns/adb.c | 42 ++++++++------- lib/dns/include/dns/adb.h | 8 +++ lib/dns/include/dns/resolver.h | 60 ++++++++++++++++++++++ lib/dns/include/dns/view.h | 93 +++------------------------------- lib/dns/resolver.c | 79 +++++++++++++++++++++++++---- lib/dns/view.c | 66 ------------------------ 8 files changed, 226 insertions(+), 223 deletions(-) diff --git a/bin/named/server.c b/bin/named/server.c index 043205b4fa..8bdcc27aa2 100644 --- a/bin/named/server.c +++ b/bin/named/server.c @@ -4661,9 +4661,10 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, "reusing existing cache"); dns_cache_attach(pview->cache, &cache); } - dns_view_getresstats(pview, &resstats); - dns_view_getresquerystats(pview, - &resquerystats); + dns_resolver_getstats(pview->resolver, + &resstats); + dns_resolver_getquerystats(pview->resolver, + &resquerystats); dns_view_detach(&pview); } } @@ -4731,22 +4732,22 @@ configure_view(dns_view_t *view, dns_viewlist_t *viewlist, cfg_obj_t *config, goto cleanup; } - if (resstats == NULL) { - CHECK(isc_stats_create(mctx, &resstats, - dns_resstatscounter_max)); - } - dns_view_setresstats(view, resstats); - if (resquerystats == NULL) { - CHECK(dns_rdatatypestats_create(mctx, &resquerystats)); - } - dns_view_setresquerystats(view, resquerystats); - ndisp = 4 * ISC_MIN(named_g_udpdisp, MAX_UDP_DISPATCH); CHECK(dns_view_createresolver( view, named_g_taskmgr, RESOLVER_NTASKS_PERCPU * named_g_cpus, ndisp, named_g_netmgr, named_g_timermgr, resopts, named_g_dispatchmgr, dispatch4, dispatch6)); + if (resstats == NULL) { + CHECK(isc_stats_create(mctx, &resstats, + dns_resstatscounter_max)); + } + dns_resolver_setstats(view->resolver, resstats); + if (resquerystats == NULL) { + CHECK(dns_rdatatypestats_create(mctx, &resquerystats)); + } + dns_resolver_setquerystats(view->resolver, resquerystats); + if (dscp4 == -1) { dscp4 = named_g_dscp; } diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index 1687d1f7ae..11e50e1689 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -2239,6 +2240,9 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen, TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "views")); while (view != NULL && ((flags & (STATS_XML_SERVER | STATS_XML_ZONES)) != 0)) { + isc_stats_t *istats = NULL; + dns_stats_t *dstats = NULL; + TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "view")); TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "name", ISC_XMLCHAR view->name)); @@ -2261,25 +2265,29 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen, TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type", ISC_XMLCHAR "resqtype")); - if (view->resquerystats != NULL) { + dns_resolver_getquerystats(view->resolver, &dstats); + if (dstats != NULL) { dumparg.result = ISC_R_SUCCESS; - dns_rdatatypestats_dump(view->resquerystats, - rdtypestat_dump, &dumparg, 0); + dns_rdatatypestats_dump(dstats, rdtypestat_dump, + &dumparg, 0); CHECK(dumparg.result); } + dns_stats_detach(&dstats); TRY0(xmlTextWriterEndElement(writer)); /* */ TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters")); TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type", ISC_XMLCHAR "resstats")); - if (view->resstats != NULL) { - CHECK(dump_counters(view->resstats, isc_statsformat_xml, - writer, NULL, resstats_xmldesc, + dns_resolver_getstats(view->resolver, &istats); + if (istats != NULL) { + CHECK(dump_counters(istats, isc_statsformat_xml, writer, + NULL, resstats_xmldesc, dns_resstatscounter_max, resstats_index, resstat_values, ISC_STATSDUMP_VERBOSE)); } + isc_stats_detach(&istats); TRY0(xmlTextWriterEndElement(writer)); /* */ cacherrstats = dns_db_getrrsetstats(view->cachedb); @@ -2300,13 +2308,10 @@ generatexml(named_server_t *server, uint32_t flags, int *buflen, TRY0(xmlTextWriterStartElement(writer, ISC_XMLCHAR "counters")); TRY0(xmlTextWriterWriteAttribute(writer, ISC_XMLCHAR "type", ISC_XMLCHAR "adbstat")); - if (view->adbstats != NULL) { - CHECK(dump_counters(view->adbstats, isc_statsformat_xml, - writer, NULL, adbstats_xmldesc, - dns_adbstats_max, adbstats_index, - adbstat_values, - ISC_STATSDUMP_VERBOSE)); - } + CHECK(dump_counters( + dns_adb_getstats(view->adb), isc_statsformat_xml, + writer, NULL, adbstats_xmldesc, dns_adbstats_max, + adbstats_index, adbstat_values, ISC_STATSDUMP_VERBOSE)); TRY0(xmlTextWriterEndElement(writer)); /* */ /* */ @@ -2993,15 +2998,15 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg, } if ((flags & STATS_JSON_SERVER) != 0) { - json_object *res; - dns_stats_t *dstats; - isc_stats_t *istats; + json_object *res = NULL; + dns_stats_t *dstats = NULL; + isc_stats_t *istats = NULL; res = json_object_new_object(); CHECKMEM(res); json_object_object_add(v, "resolver", res); - istats = view->resstats; + dns_resolver_getstats(view->resolver, &istats); if (istats != NULL) { counters = json_object_new_object(); CHECKMEM(counters); @@ -3021,9 +3026,11 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg, json_object_object_add(res, "stats", counters); + isc_stats_detach(&istats); } - dstats = view->resquerystats; + dns_resolver_getquerystats(view->resolver, + &dstats); if (dstats != NULL) { counters = json_object_new_object(); CHECKMEM(counters); @@ -3041,6 +3048,7 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg, json_object_object_add(res, "qtypes", counters); + dns_stats_detach(&dstats); } dstats = dns_db_getrrsetstats(view->cachedb); @@ -3076,7 +3084,7 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg, json_object_object_add(res, "cachestats", counters); - istats = view->adbstats; + istats = dns_adb_getstats(view->adb); if (istats != NULL) { counters = json_object_new_object(); CHECKMEM(counters); @@ -3926,7 +3934,9 @@ named_stats_dump(named_server_t *server, FILE *fp) { for (view = ISC_LIST_HEAD(server->viewlist); view != NULL; view = ISC_LIST_NEXT(view, link)) { - if (view->resquerystats == NULL) { + dns_stats_t *dstats = NULL; + dns_resolver_getquerystats(view->resolver, &dstats); + if (dstats == NULL) { continue; } if (strcmp(view->name, "_default") == 0) { @@ -3934,8 +3944,8 @@ named_stats_dump(named_server_t *server, FILE *fp) { } else { fprintf(fp, "[View: %s]\n", view->name); } - dns_rdatatypestats_dump(view->resquerystats, rdtypestat_dump, - &dumparg, 0); + dns_rdatatypestats_dump(dstats, rdtypestat_dump, &dumparg, 0); + dns_stats_detach(&dstats); } fprintf(fp, "++ Name Server Statistics ++\n"); @@ -3957,7 +3967,9 @@ named_stats_dump(named_server_t *server, FILE *fp) { for (view = ISC_LIST_HEAD(server->viewlist); view != NULL; view = ISC_LIST_NEXT(view, link)) { - if (view->resstats == NULL) { + isc_stats_t *istats = NULL; + dns_resolver_getstats(view->resolver, &istats); + if (istats == NULL) { continue; } if (strcmp(view->name, "_default") == 0) { @@ -3965,10 +3977,10 @@ named_stats_dump(named_server_t *server, FILE *fp) { } else { fprintf(fp, "[View: %s]\n", view->name); } - (void)dump_counters(view->resstats, isc_statsformat_file, fp, - NULL, resstats_desc, - dns_resstatscounter_max, resstats_index, - resstat_values, 0); + (void)dump_counters(istats, isc_statsformat_file, fp, NULL, + resstats_desc, dns_resstatscounter_max, + resstats_index, resstat_values, 0); + isc_stats_detach(&istats); } fprintf(fp, "++ Cache Statistics ++\n"); @@ -4021,7 +4033,9 @@ named_stats_dump(named_server_t *server, FILE *fp) { for (view = ISC_LIST_HEAD(server->viewlist); view != NULL; view = ISC_LIST_NEXT(view, link)) { - if (view->adbstats == NULL) { + isc_stats_t *adbstats = dns_adb_getstats(view->adb); + + if (adbstats == NULL) { continue; } if (strcmp(view->name, "_default") == 0) { @@ -4029,8 +4043,8 @@ named_stats_dump(named_server_t *server, FILE *fp) { } else { fprintf(fp, "[View: %s]\n", view->name); } - (void)dump_counters(view->adbstats, isc_statsformat_file, fp, - NULL, adbstats_desc, dns_adbstats_max, + (void)dump_counters(adbstats, isc_statsformat_file, fp, NULL, + adbstats_desc, dns_adbstats_max, adbstats_index, adbstat_values, 0); } diff --git a/lib/dns/adb.c b/lib/dns/adb.c index 99619a3d6a..52ebf9bdc8 100644 --- a/lib/dns/adb.c +++ b/lib/dns/adb.c @@ -115,6 +115,8 @@ struct dns_adb { isc_ht_t *entrybuckets; isc_rwlock_t entries_lock; + isc_stats_t *stats; + isc_event_t cevent; bool cevent_out; atomic_bool exiting; @@ -487,10 +489,8 @@ DP(int level, const char *format, ...) { * Increment resolver-related statistics counters. */ static void -inc_stats(dns_adb_t *adb, isc_statscounter_t counter) { - if (adb->view->resstats != NULL) { - isc_stats_increment(adb->view->resstats, counter); - } +inc_resstats(dns_adb_t *adb, isc_statscounter_t counter) { + dns_resolver_incstats(adb->view->resolver, counter); } /*% @@ -498,22 +498,22 @@ inc_stats(dns_adb_t *adb, isc_statscounter_t counter) { */ static void set_adbstat(dns_adb_t *adb, uint64_t val, isc_statscounter_t counter) { - if (adb->view->adbstats != NULL) { - isc_stats_set(adb->view->adbstats, val, counter); + if (adb->stats != NULL) { + isc_stats_set(adb->stats, val, counter); } } static void dec_adbstats(dns_adb_t *adb, isc_statscounter_t counter) { - if (adb->view->adbstats != NULL) { - isc_stats_decrement(adb->view->adbstats, counter); + if (adb->stats != NULL) { + isc_stats_decrement(adb->stats, counter); } } static void inc_adbstats(dns_adb_t *adb, isc_statscounter_t counter) { - if (adb->view->adbstats != NULL) { - isc_stats_increment(adb->view->adbstats, counter); + if (adb->stats != NULL) { + isc_stats_increment(adb->stats, counter); } } @@ -2075,6 +2075,7 @@ destroy(dns_adb_t *adb) { isc_rwlock_destroy(&adb->entries_lock); isc_mutex_destroy(&adb->lock); + isc_stats_detach(&adb->stats); isc_mem_putanddetach(&adb->mctx, adb, sizeof(dns_adb_t)); } @@ -2129,7 +2130,7 @@ dns_adb_create(isc_mem_t *mem, dns_view_t *view, isc_taskmgr_t *taskmgr, isc_task_setname(adb->task, "ADB", adb); - result = isc_stats_create(adb->mctx, &view->adbstats, dns_adbstats_max); + result = isc_stats_create(adb->mctx, &adb->stats, dns_adbstats_max); if (result != ISC_R_SUCCESS) { goto free_task; } @@ -3244,7 +3245,7 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) { } else { name->fetch_err = FIND_ERR_NXRRSET; } - inc_stats(adb, dns_resstatscounter_gluefetchv4fail); + inc_resstats(adb, dns_resstatscounter_gluefetchv4fail); } else { DP(NCACHE_LEVEL, "adb fetch name %p: " @@ -3257,7 +3258,7 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) { } else { name->fetch6_err = FIND_ERR_NXRRSET; } - inc_stats(adb, dns_resstatscounter_gluefetchv6fail); + inc_resstats(adb, dns_resstatscounter_gluefetchv6fail); } goto out; } @@ -3301,11 +3302,11 @@ fetch_callback(isc_task_t *task, isc_event_t *ev) { if (address_type == DNS_ADBFIND_INET) { name->expire_v4 = ISC_MIN(name->expire_v4, now + 10); name->fetch_err = FIND_ERR_FAILURE; - inc_stats(adb, dns_resstatscounter_gluefetchv4fail); + inc_resstats(adb, dns_resstatscounter_gluefetchv4fail); } else { name->expire_v6 = ISC_MIN(name->expire_v6, now + 10); name->fetch6_err = FIND_ERR_FAILURE; - inc_stats(adb, dns_resstatscounter_gluefetchv6fail); + inc_resstats(adb, dns_resstatscounter_gluefetchv6fail); } goto out; } @@ -3396,10 +3397,10 @@ fetch_name(dns_adbname_t *adbname, bool start_at_zone, unsigned int depth, if (type == dns_rdatatype_a) { adbname->fetch_a = fetch; - inc_stats(adb, dns_resstatscounter_gluefetchv4); + inc_resstats(adb, dns_resstatscounter_gluefetchv4); } else { adbname->fetch_aaaa = fetch; - inc_stats(adb, dns_resstatscounter_gluefetchv6); + inc_resstats(adb, dns_resstatscounter_gluefetchv6); } fetch = NULL; /* Keep us from cleaning this up below. */ @@ -4022,3 +4023,10 @@ dns_adb_endudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr) { REQUIRE(atomic_fetch_sub_release(&addr->entry->active, 1) != 0); } + +isc_stats_t * +dns_adb_getstats(dns_adb_t *adb) { + REQUIRE(DNS_ADB_VALID(adb)); + + return (adb->stats); +} diff --git a/lib/dns/include/dns/adb.h b/lib/dns/include/dns/adb.h index d6bb8ddb21..2163a2ce3f 100644 --- a/lib/dns/include/dns/adb.h +++ b/lib/dns/include/dns/adb.h @@ -807,4 +807,12 @@ dns_adb_endudpfetch(dns_adb_t *adb, dns_adbaddrinfo_t *addr); *\li addr be valid. */ +isc_stats_t * +dns_adb_getstats(dns_adb_t *adb); +/*%< + * Get the adb statistics counter set for 'adb'. + * + * Requires: + * \li 'adb' is valid. + */ ISC_LANG_ENDDECLS diff --git a/lib/dns/include/dns/resolver.h b/lib/dns/include/dns/resolver.h index d7d905dbb9..d17b28a177 100644 --- a/lib/dns/include/dns/resolver.h +++ b/lib/dns/include/dns/resolver.h @@ -736,4 +736,64 @@ void dns_resolver_setfuzzing(void); #endif /* ifdef ENABLE_AFL */ +void +dns_resolver_setstats(dns_resolver_t *res, isc_stats_t *stats); +/*%< + * Set a general resolver statistics counter set 'stats' for 'res'. + * + * Requires: + * \li 'res' is valid. + * + *\li stats is a valid statistics supporting resolver statistics counters + * (see dns/stats.h). + */ + +void +dns_resolver_getstats(dns_resolver_t *res, isc_stats_t **statsp); +/*%< + * Get the general statistics counter set for 'res'. If a statistics set is + * set '*statsp' will be attached to the set; otherwise, '*statsp' will be + * untouched. + * + * Requires: + * \li 'res' is valid. + * + *\li 'statsp' != NULL && '*statsp' != NULL + */ + +void +dns_resolver_incstats(dns_resolver_t *res, isc_statscounter_t counter); +/*%< + * Increment the specified statistics counter in res->stats, if res->stats + * is set. + * + * Requires: + * \li 'res' is valid. + */ + +void +dns_resolver_setquerystats(dns_resolver_t *res, dns_stats_t *stats); +/*%< + * Set a statistics counter set of rdata type, 'stats', for 'res'. Once the + * statistic set is installed, the resolver will count outgoing queries + * per rdata type. + * + * Requires: + * \li 'res' is valid. + * + *\li stats is a valid statistics created by dns_rdatatypestats_create(). + */ + +void +dns_resolver_getquerystats(dns_resolver_t *res, dns_stats_t **statsp); +/*%< + * Get the rdatatype statistics counter set for 'res'. If a statistics set is + * set '*statsp' will be attached to the set; otherwise, '*statsp' will be + * untouched. + * + * Requires: + * \li 'res' is valid. + * + *\li 'statsp' != NULL && '*statsp' != NULL + */ ISC_LANG_ENDDECLS diff --git a/lib/dns/include/dns/view.h b/lib/dns/include/dns/view.h index b525583c89..d590dfeaa3 100644 --- a/lib/dns/include/dns/view.h +++ b/lib/dns/include/dns/view.h @@ -101,16 +101,13 @@ struct dns_view { dns_keytable_t *secroots_priv; dns_ntatable_t *ntatable_priv; - isc_mutex_t lock; - bool frozen; - isc_task_t *task; - isc_event_t resevent; - isc_event_t adbevent; - isc_event_t reqevent; - isc_stats_t *adbstats; - isc_stats_t *resstats; - dns_stats_t *resquerystats; - bool cacheshared; + isc_mutex_t lock; + bool frozen; + isc_task_t *task; + isc_event_t resevent; + isc_event_t adbevent; + isc_event_t reqevent; + bool cacheshared; /* Configurable data. */ dns_transport_list_t *transports; @@ -1018,82 +1015,6 @@ dns_view_freezezones(dns_view_t *view, bool freeze); * \li 'view' is valid. */ -void -dns_view_setadbstats(dns_view_t *view, isc_stats_t *stats); -/*%< - * Set a adb statistics set 'stats' for 'view'. - * - * Requires: - * \li 'view' is valid and is not frozen. - * - *\li stats is a valid statistics supporting adb statistics - * (see dns/stats.h). - */ - -void -dns_view_getadbstats(dns_view_t *view, isc_stats_t **statsp); -/*%< - * Get the adb statistics counter set for 'view'. If a statistics set is - * set '*statsp' will be attached to the set; otherwise, '*statsp' will be - * untouched. - * - * Requires: - * \li 'view' is valid and is not frozen. - * - *\li 'statsp' != NULL && '*statsp' != NULL - */ - -void -dns_view_setresstats(dns_view_t *view, isc_stats_t *stats); -/*%< - * Set a general resolver statistics counter set 'stats' for 'view'. - * - * Requires: - * \li 'view' is valid and is not frozen. - * - *\li stats is a valid statistics supporting resolver statistics counters - * (see dns/stats.h). - */ - -void -dns_view_getresstats(dns_view_t *view, isc_stats_t **statsp); -/*%< - * Get the general statistics counter set for 'view'. If a statistics set is - * set '*statsp' will be attached to the set; otherwise, '*statsp' will be - * untouched. - * - * Requires: - * \li 'view' is valid and is not frozen. - * - *\li 'statsp' != NULL && '*statsp' != NULL - */ - -void -dns_view_setresquerystats(dns_view_t *view, dns_stats_t *stats); -/*%< - * Set a statistics counter set of rdata type, 'stats', for 'view'. Once the - * statistic set is installed, view's resolver will count outgoing queries - * per rdata type. - * - * Requires: - * \li 'view' is valid and is not frozen. - * - *\li stats is a valid statistics created by dns_rdatatypestats_create(). - */ - -void -dns_view_getresquerystats(dns_view_t *view, dns_stats_t **statsp); -/*%< - * Get the rdatatype statistics counter set for 'view'. If a statistics set is - * set '*statsp' will be attached to the set; otherwise, '*statsp' will be - * untouched. - * - * Requires: - * \li 'view' is valid and is not frozen. - * - *\li 'statsp' != NULL && '*statsp' != NULL - */ - bool dns_view_iscacheshared(dns_view_t *view); /*%< diff --git a/lib/dns/resolver.c b/lib/dns/resolver.c index fe909eb1bf..02bfb2a72e 100644 --- a/lib/dns/resolver.c +++ b/lib/dns/resolver.c @@ -556,6 +556,8 @@ struct dns_resolver { unsigned int maxdepth; unsigned int maxqueries; isc_result_t quotaresp[2]; + isc_stats_t *stats; + dns_stats_t *querystats; /* Additions for serve-stale feature. */ unsigned int retryinterval; /* in milliseconds */ @@ -911,15 +913,22 @@ rctx_ncache(respctx_t *rctx); */ static void inc_stats(dns_resolver_t *res, isc_statscounter_t counter) { - if (res->view->resstats != NULL) { - isc_stats_increment(res->view->resstats, counter); + if (res->stats != NULL) { + isc_stats_increment(res->stats, counter); } } static void dec_stats(dns_resolver_t *res, isc_statscounter_t counter) { - if (res->view->resstats != NULL) { - isc_stats_decrement(res->view->resstats, counter); + if (res->stats != NULL) { + isc_stats_decrement(res->stats, counter); + } +} + +static void +set_stats(dns_resolver_t *res, isc_statscounter_t counter, uint64_t val) { + if (res->stats != NULL) { + isc_stats_set(res->stats, val, counter); } } @@ -2933,8 +2942,8 @@ resquery_connected(isc_result_t eresult, isc_region_t *region, void *arg) { } else { inc_stats(res, dns_resstatscounter_queryv6); } - if (res->view->resquerystats != NULL) { - dns_rdatatypestats_increment(res->view->resquerystats, + if (res->querystats != NULL) { + dns_rdatatypestats_increment(res->querystats, fctx->type); } break; @@ -10092,6 +10101,13 @@ destroy(dns_resolver_t *res) { REQUIRE(atomic_load_acquire(&res->nfctx) == 0); + if (res->querystats != NULL) { + dns_stats_detach(&res->querystats); + } + if (res->stats != NULL) { + isc_stats_detach(&res->stats); + } + isc_mutex_destroy(&res->primelock); isc_mutex_destroy(&res->lock); for (i = 0; i < res->nbuckets; i++) { @@ -10243,11 +10259,6 @@ dns_resolver_create(dns_view_t *view, isc_taskmgr_t *taskmgr, goto cleanup_res; } - if (view->resstats != NULL) { - isc_stats_set(view->resstats, ntasks, - dns_resstatscounter_buckets); - } - res->buckets = isc_mem_get(view->mctx, ntasks * sizeof(res->buckets[0])); for (uint32_t i = 0; i < ntasks; i++) { @@ -11566,3 +11577,49 @@ dns_resolver_setnonbackofftries(dns_resolver_t *resolver, unsigned int tries) { resolver->nonbackofftries = tries; } + +void +dns_resolver_setstats(dns_resolver_t *res, isc_stats_t *stats) { + REQUIRE(VALID_RESOLVER(res)); + REQUIRE(res->stats == NULL); + + isc_stats_attach(stats, &res->stats); + + /* initialize the bucket "counter"; it's a static value */ + set_stats(res, dns_resstatscounter_buckets, res->nbuckets); +} + +void +dns_resolver_getstats(dns_resolver_t *res, isc_stats_t **statsp) { + REQUIRE(VALID_RESOLVER(res)); + REQUIRE(statsp != NULL && *statsp == NULL); + + if (res->stats != NULL) { + isc_stats_attach(res->stats, statsp); + } +} + +void +dns_resolver_incstats(dns_resolver_t *res, isc_statscounter_t counter) { + REQUIRE(VALID_RESOLVER(res)); + + isc_stats_increment(res->stats, counter); +} + +void +dns_resolver_setquerystats(dns_resolver_t *res, dns_stats_t *stats) { + REQUIRE(VALID_RESOLVER(res)); + REQUIRE(res->querystats == NULL); + + dns_stats_attach(stats, &res->querystats); +} + +void +dns_resolver_getquerystats(dns_resolver_t *res, dns_stats_t **statsp) { + REQUIRE(VALID_RESOLVER(res)); + REQUIRE(statsp != NULL && *statsp == NULL); + + if (res->querystats != NULL) { + dns_stats_attach(res->querystats, statsp); + } +} diff --git a/lib/dns/view.c b/lib/dns/view.c index 969b153ea7..13f55142b5 100644 --- a/lib/dns/view.c +++ b/lib/dns/view.c @@ -433,15 +433,6 @@ destroy(dns_view_t *view) { sizeof(dns_namelist_t) * DNS_VIEW_DELONLYHASH); view->rootexclude = NULL; } - if (view->adbstats != NULL) { - isc_stats_detach(&view->adbstats); - } - if (view->resstats != NULL) { - isc_stats_detach(&view->resstats); - } - if (view->resquerystats != NULL) { - dns_stats_detach(&view->resquerystats); - } if (view->secroots_priv != NULL) { dns_keytable_detach(&view->secroots_priv); } @@ -1741,63 +1732,6 @@ dns_view_freezezones(dns_view_t *view, bool value) { return (dns_zt_freezezones(view->zonetable, view, value)); } -void -dns_view_setadbstats(dns_view_t *view, isc_stats_t *stats) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(!view->frozen); - REQUIRE(view->adbstats == NULL); - - isc_stats_attach(stats, &view->adbstats); -} - -void -dns_view_getadbstats(dns_view_t *view, isc_stats_t **statsp) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(statsp != NULL && *statsp == NULL); - - if (view->adbstats != NULL) { - isc_stats_attach(view->adbstats, statsp); - } -} - -void -dns_view_setresstats(dns_view_t *view, isc_stats_t *stats) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(!view->frozen); - REQUIRE(view->resstats == NULL); - - isc_stats_attach(stats, &view->resstats); -} - -void -dns_view_getresstats(dns_view_t *view, isc_stats_t **statsp) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(statsp != NULL && *statsp == NULL); - - if (view->resstats != NULL) { - isc_stats_attach(view->resstats, statsp); - } -} - -void -dns_view_setresquerystats(dns_view_t *view, dns_stats_t *stats) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(!view->frozen); - REQUIRE(view->resquerystats == NULL); - - dns_stats_attach(stats, &view->resquerystats); -} - -void -dns_view_getresquerystats(dns_view_t *view, dns_stats_t **statsp) { - REQUIRE(DNS_VIEW_VALID(view)); - REQUIRE(statsp != NULL && *statsp == NULL); - - if (view->resquerystats != NULL) { - dns_stats_attach(view->resquerystats, statsp); - } -} - isc_result_t dns_view_initntatable(dns_view_t *view, isc_taskmgr_t *taskmgr, isc_timermgr_t *timermgr) {