Merge branch '4425-current-level-of-tcp-clients-missing-from-statistics-channel-v9_18' into 'bind-9.18'

[9.18] Expose the TCP client count in statistics channel

See merge request isc-projects/bind9!8660
This commit is contained in:
Aydın Mercan 2024-02-27 08:40:34 +00:00
commit d2542a38ed
8 changed files with 30 additions and 7 deletions

View file

@ -33,6 +33,9 @@
listener transport type. Thanks to Thomas Amgarten.
[GL #4518] [GL #4528]
6325. [func] Expose the TCP client count in statistics channel.
[GL #4425]
6324. [bug] Fix a possible crash in 'dig +nssearch +nofail' and
'host -C' commands when one of the name servers returns
SERVFAIL. [GL #4508]

View file

@ -626,6 +626,11 @@ init_desc(void) {
SET_SOCKSTATDESC(unixactive, "Unix domain sockets active",
"UnixActive");
SET_SOCKSTATDESC(rawactive, "Raw sockets active", "RawActive");
SET_SOCKSTATDESC(tcp4clients, "TCP/IPv4 clients currently connected",
"TCP4Clients");
SET_SOCKSTATDESC(tcp6clients, "TCP/IPv6 clients currently connected",
"TCP6Clients");
INSIST(i == isc_sockstatscounter_max);
/* Initialize DNSSEC statistics */

View file

@ -20,7 +20,8 @@ Security Fixes
New Features
~~~~~~~~~~~~
- None.
- The statistics channel now includes counters that indicate the number
of currently connected TCP IPv4/IPv6 clients. :gl:`#4425`
Removed Features
~~~~~~~~~~~~~~~~

View file

@ -100,7 +100,10 @@ enum {
isc_sockstatscounter_rawrecvfail = 60,
isc_sockstatscounter_rawactive = 61,
isc_sockstatscounter_max = 62
isc_sockstatscounter_tcp4clients = 62,
isc_sockstatscounter_tcp6clients = 63,
isc_sockstatscounter_max = 64
};
ISC_LANG_BEGINDECLS

View file

@ -856,7 +856,8 @@ typedef enum {
STATID_SENDFAIL = 8,
STATID_RECVFAIL = 9,
STATID_ACTIVE = 10,
STATID_MAX = 11,
STATID_CLIENTS = 11,
STATID_MAX = 12,
} isc__nm_statid_t;
#if HAVE_LIBNGHTTP2

View file

@ -67,7 +67,8 @@ static const isc_statscounter_t udp4statsindex[] = {
-1,
isc_sockstatscounter_udp4sendfail,
isc_sockstatscounter_udp4recvfail,
isc_sockstatscounter_udp4active
isc_sockstatscounter_udp4active,
-1,
};
static const isc_statscounter_t udp6statsindex[] = {
@ -81,7 +82,8 @@ static const isc_statscounter_t udp6statsindex[] = {
-1,
isc_sockstatscounter_udp6sendfail,
isc_sockstatscounter_udp6recvfail,
isc_sockstatscounter_udp6active
isc_sockstatscounter_udp6active,
-1,
};
static const isc_statscounter_t tcp4statsindex[] = {
@ -90,7 +92,7 @@ static const isc_statscounter_t tcp4statsindex[] = {
isc_sockstatscounter_tcp4connectfail, isc_sockstatscounter_tcp4connect,
isc_sockstatscounter_tcp4acceptfail, isc_sockstatscounter_tcp4accept,
isc_sockstatscounter_tcp4sendfail, isc_sockstatscounter_tcp4recvfail,
isc_sockstatscounter_tcp4active
isc_sockstatscounter_tcp4active, isc_sockstatscounter_tcp4clients,
};
static const isc_statscounter_t tcp6statsindex[] = {
@ -99,7 +101,7 @@ static const isc_statscounter_t tcp6statsindex[] = {
isc_sockstatscounter_tcp6connectfail, isc_sockstatscounter_tcp6connect,
isc_sockstatscounter_tcp6acceptfail, isc_sockstatscounter_tcp6accept,
isc_sockstatscounter_tcp6sendfail, isc_sockstatscounter_tcp6recvfail,
isc_sockstatscounter_tcp6active
isc_sockstatscounter_tcp6active, isc_sockstatscounter_tcp6clients,
};
#if 0

View file

@ -689,6 +689,7 @@ destroy:
* chance to be executed.
*/
if (sock->quota != NULL) {
isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}
}
@ -1004,6 +1005,8 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
UV_RUNTIME_CHECK(uv_timer_init, r);
uv_handle_set_data((uv_handle_t *)&csock->read_timer, csock);
isc__nm_incstats(csock, STATID_CLIENTS);
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
if (r != 0) {
result = isc__nm_uverr2result(r);
@ -1366,6 +1369,7 @@ tcpdns_close_direct(isc_nmsocket_t *sock) {
REQUIRE(atomic_load(&sock->closing));
if (sock->quota != NULL) {
isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}

View file

@ -895,6 +895,7 @@ destroy:
* had a chance to be executed.
*/
if (sock->quota != NULL) {
isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}
}
@ -1628,6 +1629,8 @@ accept_connection(isc_nmsocket_t *ssock, isc_quota_t *quota) {
UV_RUNTIME_CHECK(uv_timer_init, r);
uv_handle_set_data((uv_handle_t *)&csock->read_timer, csock);
isc__nm_incstats(csock, STATID_CLIENTS);
r = uv_accept(&ssock->uv_handle.stream, &csock->uv_handle.stream);
if (r != 0) {
result = isc__nm_uverr2result(r);
@ -2109,6 +2112,7 @@ tlsdns_close_direct(isc_nmsocket_t *sock) {
REQUIRE(sock->tls.pending_req == NULL);
if (sock->quota != NULL) {
isc__nm_decstats(sock, STATID_CLIENTS);
isc_quota_detach(&sock->quota);
}