2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-31 14:35:26 +00:00

add "rndc fetchlimit" to show fetchlimited servers

this command runs dns_adb_dumpquota() to display all servers
in the ADB that are being actively fetchlimited by the
fetches-per-server controls (i.e, servers with a nonzero average
timeout ratio or with the quota having been reduced from the
default value).

the "fetchlimit" system test has been updated to use the
new command to check quota values instead of "rndc dumpdb".
This commit is contained in:
Evan Hunt
2022-05-26 02:33:52 -07:00
parent 7cac4ca03c
commit 6175897478
9 changed files with 210 additions and 12 deletions

View File

@@ -2976,6 +2976,67 @@ print_find_list(FILE *f, dns_adbname_t *name) {
}
}
static isc_result_t
putstr(isc_buffer_t **b, const char *str) {
isc_result_t result;
result = isc_buffer_reserve(b, strlen(str));
if (result != ISC_R_SUCCESS) {
return (result);
}
isc_buffer_putstr(*b, str);
return (ISC_R_SUCCESS);
}
isc_result_t
dns_adb_dumpquota(dns_adb_t *adb, isc_buffer_t **buf) {
isc_result_t result;
isc_ht_iter_t *it = NULL;
REQUIRE(DNS_ADB_VALID(adb));
RWLOCK(&adb->entries_lock, isc_rwlocktype_read);
isc_ht_iter_create(adb->entrybuckets, &it);
for (result = isc_ht_iter_first(it); result == ISC_R_SUCCESS;
result = isc_ht_iter_next(it))
{
dns_adbentrybucket_t *ebucket = NULL;
dns_adbentry_t *entry = NULL;
isc_ht_iter_current(it, (void **)&ebucket);
LOCK(&ebucket->lock);
for (entry = ISC_LIST_HEAD(ebucket->entries); entry != NULL;
entry = ISC_LIST_NEXT(entry, plink))
{
char addrbuf[ISC_NETADDR_FORMATSIZE];
char text[BUFSIZ];
isc_netaddr_t netaddr;
if (entry->atr == 0.0 && entry->quota == adb->quota) {
continue;
}
isc_netaddr_fromsockaddr(&netaddr, &entry->sockaddr);
isc_netaddr_format(&netaddr, addrbuf, sizeof(addrbuf));
snprintf(text, sizeof(text),
"\n- quota %s (%" PRIuFAST32 "/%d) atr %0.2f",
addrbuf, atomic_load_relaxed(&entry->quota),
adb->quota, entry->atr);
putstr(buf, text);
}
UNLOCK(&ebucket->lock);
}
RWUNLOCK(&adb->entries_lock, isc_rwlocktype_read);
isc_ht_iter_destroy(&it);
if (result == ISC_R_NOMORE) {
result = ISC_R_SUCCESS;
}
return (result);
}
static isc_result_t
dbfind_name(dns_adbname_t *adbname, isc_stdtime_t now, dns_rdatatype_t rdtype) {
isc_result_t result;
@@ -3965,6 +4026,32 @@ dns_adb_setquota(dns_adb_t *adb, uint32_t quota, uint32_t freq, double low,
adb->atr_discount = discount;
}
void
dns_adb_getquota(dns_adb_t *adb, uint32_t *quotap, uint32_t *freqp,
double *lowp, double *highp, double *discountp) {
REQUIRE(DNS_ADB_VALID(adb));
if (quotap != NULL) {
*quotap = adb->quota;
}
if (freqp != NULL) {
*freqp = adb->atr_freq;
}
if (lowp != NULL) {
*lowp = adb->atr_low;
}
if (highp != NULL) {
*highp = adb->atr_high;
}
if (discountp != NULL) {
*discountp = adb->atr_discount;
}
}
bool
dns_adbentry_overquota(dns_adbentry_t *entry) {
uint_fast32_t quota, active;