Commit 1f91cf92 authored by Diego dos Santos Fronza's avatar Diego dos Santos Fronza Committed by Ondřej Surý

Added TCP high-water statistics variable

This variable will report the maximum number of simultaneous tcp clients
that BIND has served while running.

It can be verified by running rndc status, then inspect "tcp high-water:
count", or by generating statistics file, rndc stats, then inspect the
line with "TCP connection high-water" text.

The tcp-highwater variable is atomically updated based on an existing
tcp-quota system handled in ns/client.c.

(cherry picked from commit 66fe8627)
parent 29f61b78
......@@ -3507,7 +3507,6 @@ client_accept(ns_client_t *client) {
isc_result_t result;
CTRACE("accept");
/*
* Set up a new TCP connection. This means try to attach to the
* TCP client quota (tcp-clients), but fail if we're over quota.
......@@ -3558,6 +3557,12 @@ client_accept(ns_client_t *client) {
RUNTIME_CHECK(result == ISC_R_SUCCESS);
}
/* TCP high-water stats update. */
unsigned int curr_tcpquota = isc_quota_getused(&ns_g_server->tcpquota);
isc_stats_update_if_greater(ns_g_server->nsstats,
dns_nsstatscounter_tcphighwater,
curr_tcpquota);
/*
* If this client was set up using get_client() or get_worker(),
* then TCP is already marked active. However, if it was restarted
......
......@@ -220,7 +220,9 @@ enum {
dns_nsstatscounter_keytagopt = 56,
dns_nsstatscounter_max = 57
dns_nsstatscounter_tcphighwater = 57,
dns_nsstatscounter_max = 58
};
/*%
......
......@@ -10880,6 +10880,11 @@ ns_server_status(ns_server_t *server, isc_buffer_t **text) {
server->tcpquota.used, server->tcpquota.max);
CHECK(putstr(text, line));
snprintf(line, sizeof(line), "TCP high-water: %" PRIu64 "\n",
isc_stats_get_counter(ns_g_server->nsstats,
dns_nsstatscounter_tcphighwater));
CHECK(putstr(text, line));
CHECK(putstr(text, "server is up and running"));
CHECK(putnull(text));
......
......@@ -227,6 +227,8 @@ init_desc(void) {
SET_NSSTATDESC(invalidsig, "requests with invalid signature",
"ReqBadSIG");
SET_NSSTATDESC(requesttcp, "TCP requests received", "ReqTCP");
SET_NSSTATDESC(tcphighwater, "TCP connection high-water",
"TCPConnHighWater");
SET_NSSTATDESC(authrej, "auth queries rejected", "AuthQryRej");
SET_NSSTATDESC(recurserej, "recursive queries rejected", "RecQryRej");
SET_NSSTATDESC(xfrrej, "transfer requests rejected", "XfrRej");
......
......@@ -498,11 +498,12 @@ void isc_stats_update_if_greater(isc_stats_t *stats,
(int64_t *)&curr_value,
value));
#else
isc_rwlock_lock(&stats->counterlock, isc_rwlocktype_write);
/* This is not exactly thread safe, but we are ok with that on
* platforms without stdatomic support.
*/
if (stats->counters[counter] < value) {
stats->counters[counter] = value;
}
isc_rwlock_unlock(&stats->counterlock, isc_rwlocktype_write);
#endif
#if ISC_STATS_LOCKCOUNTERS
......@@ -523,7 +524,7 @@ isc_stats_get_counter(isc_stats_t *stats, isc_statscounter_t counter)
#endif
#if ISC_STATS_USEMULTIFIELDS
curr_value = (stats->counters[counter].hi << 32) &&
curr_value = ((uint64_t)stats->counters[counter].hi << 32) &&
stats->counters[counter].lo;
#elif ISC_STATS_HAVEATOMICQ
#if defined(ISC_STATS_HAVESTDATOMICQ)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment