"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);
}
}
goto cleanup;
}
+ 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_view_setresstats(view, resstats);
+ dns_resolver_setstats(view->resolver, 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));
+ dns_resolver_setquerystats(view->resolver, resquerystats);
if (dscp4 == -1) {
dscp4 = named_g_dscp;
#include <isc/string.h>
#include <isc/util.h>
+#include <dns/adb.h>
#include <dns/cache.h>
#include <dns/db.h>
#include <dns/opcode.h>
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));
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));
/* <resstats> */
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)); /* </resstats> */
cacherrstats = dns_db_getrrsetstats(view->cachedb);
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)); /* </adbstats> */
/* <cachestats> */
}
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);
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);
json_object_object_add(res, "qtypes",
counters);
+ dns_stats_detach(&dstats);
}
dstats = dns_db_getrrsetstats(view->cachedb);
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);
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) {
} 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");
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) {
} 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");
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) {
} 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);
}
isc_ht_t *entrybuckets;
isc_rwlock_t entries_lock;
+ isc_stats_t *stats;
+
isc_event_t cevent;
bool cevent_out;
atomic_bool exiting;
* 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);
}
/*%
*/
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);
}
}
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));
}
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;
}
} 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: "
} else {
name->fetch6_err = FIND_ERR_NXRRSET;
}
- inc_stats(adb, dns_resstatscounter_gluefetchv6fail);
+ inc_resstats(adb, dns_resstatscounter_gluefetchv6fail);
}
goto out;
}
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;
}
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. */
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);
+}
*\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
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
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;
* \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);
/*%<
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 */
*/
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);
}
}
} 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;
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++) {
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++) {
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);
+ }
+}
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);
}
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) {