mirror of
https://gitlab.isc.org/isc-projects/bind9
synced 2025-08-31 06:25:31 +00:00
2355. [func] Extend the number statistics counters available.
[RT #17590]
This commit is contained in:
@@ -15,7 +15,7 @@
|
||||
* PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/* $Id: client.c,v 1.255 2008/04/03 02:01:08 marka Exp $ */
|
||||
/* $Id: client.c,v 1.256 2008/04/03 05:55:51 marka Exp $ */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
@@ -41,6 +41,7 @@
|
||||
#include <dns/rdatalist.h>
|
||||
#include <dns/rdataset.h>
|
||||
#include <dns/resolver.h>
|
||||
#include <dns/stats.h>
|
||||
#include <dns/tsig.h>
|
||||
#include <dns/view.h>
|
||||
#include <dns/zone.h>
|
||||
@@ -918,6 +919,7 @@ ns_client_send(ns_client_t *client) {
|
||||
unsigned char sendbuf[SEND_BUFFER_SIZE];
|
||||
unsigned int dnssec_opts;
|
||||
unsigned int preferred_glue;
|
||||
isc_boolean_t opt_included = ISC_FALSE;
|
||||
|
||||
REQUIRE(NS_CLIENT_VALID(client));
|
||||
|
||||
@@ -958,6 +960,7 @@ ns_client_send(ns_client_t *client) {
|
||||
|
||||
if (client->opt != NULL) {
|
||||
result = dns_message_setopt(client->message, client->opt);
|
||||
opt_included = ISC_TRUE;
|
||||
client->opt = NULL;
|
||||
if (result != ISC_R_SUCCESS)
|
||||
goto done;
|
||||
@@ -1013,6 +1016,26 @@ ns_client_send(ns_client_t *client) {
|
||||
result = client_sendpkg(client, &tcpbuffer);
|
||||
} else
|
||||
result = client_sendpkg(client, &buffer);
|
||||
|
||||
/* update statistics (XXXJT: is it okay to access message->xxxkey?) */
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_response);
|
||||
if (opt_included) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_edns0out);
|
||||
}
|
||||
if (client->message->tsigkey != NULL) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_tsigout);
|
||||
}
|
||||
if (client->message->sig0key != NULL) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_sig0out);
|
||||
}
|
||||
if ((client->message->flags & DNS_MESSAGEFLAG_TC) != 0)
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_truncatedresp);
|
||||
|
||||
if (result == ISC_R_SUCCESS)
|
||||
return;
|
||||
|
||||
@@ -1329,6 +1352,7 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
isc_buffer_t tbuffer;
|
||||
dns_view_t *view;
|
||||
dns_rdataset_t *opt;
|
||||
dns_name_t *signame;
|
||||
isc_boolean_t ra; /* Recursion available. */
|
||||
isc_netaddr_t netaddr;
|
||||
isc_netaddr_t destaddr;
|
||||
@@ -1486,6 +1510,20 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Update some statistics counters. Don't count responses.
|
||||
*/
|
||||
if (isc_sockaddr_pf(&client->peeraddr) == PF_INET) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_requestv4);
|
||||
} else {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_requestv6);
|
||||
}
|
||||
if (TCP_CLIENT(client))
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_tcp);
|
||||
|
||||
/*
|
||||
* Hash the incoming request here as it is after
|
||||
* dns_dispatch_importrecv().
|
||||
@@ -1507,6 +1545,8 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
dns_opcodestats_increment(ns_g_server->opcodestats,
|
||||
client->message->opcode);
|
||||
switch (client->message->opcode) {
|
||||
case dns_opcode_query:
|
||||
case dns_opcode_update:
|
||||
@@ -1554,6 +1594,8 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
*/
|
||||
client->ednsversion = (opt->ttl & 0x00FF0000) >> 16;
|
||||
if (client->ednsversion > 0) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_badednsver);
|
||||
result = client_addopt(client);
|
||||
if (result == ISC_R_SUCCESS)
|
||||
result = DNS_R_BADVERS;
|
||||
@@ -1578,6 +1620,9 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
}
|
||||
}
|
||||
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_edns0in);
|
||||
|
||||
/*
|
||||
* Create an OPT for our reply.
|
||||
*/
|
||||
@@ -1722,6 +1767,17 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
client->signer = NULL;
|
||||
dns_name_init(&client->signername, NULL);
|
||||
result = dns_message_signer(client->message, &client->signername);
|
||||
if (result != ISC_R_NOTFOUND) {
|
||||
signame = NULL;
|
||||
if (dns_message_gettsig(client->message, &signame) != NULL) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_tsigin);
|
||||
} else {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_sig0in);
|
||||
}
|
||||
|
||||
}
|
||||
if (result == ISC_R_SUCCESS) {
|
||||
ns_client_log(client, DNS_LOGCATEGORY_SECURITY,
|
||||
NS_LOGMODULE_CLIENT, ISC_LOG_DEBUG(3),
|
||||
@@ -1738,15 +1794,17 @@ client_request(isc_task_t *task, isc_event_t *event) {
|
||||
} else {
|
||||
char tsigrcode[64];
|
||||
isc_buffer_t b;
|
||||
dns_name_t *name = NULL;
|
||||
dns_rcode_t status;
|
||||
isc_result_t tresult;
|
||||
|
||||
/* There is a signature, but it is bad. */
|
||||
if (dns_message_gettsig(client->message, &name) != NULL) {
|
||||
dns_generalstats_increment(ns_g_server->nsstats,
|
||||
dns_nsstatscounter_invalidsig);
|
||||
signame = NULL;
|
||||
if (dns_message_gettsig(client->message, &signame) != NULL) {
|
||||
char namebuf[DNS_NAME_FORMATSIZE];
|
||||
char cnamebuf[DNS_NAME_FORMATSIZE];
|
||||
dns_name_format(name, namebuf, sizeof(namebuf));
|
||||
dns_name_format(signame, namebuf, sizeof(namebuf));
|
||||
status = client->message->tsigstatus;
|
||||
isc_buffer_init(&b, tsigrcode, sizeof(tsigrcode) - 1);
|
||||
tresult = dns_tsigrcode_totext(status, &b);
|
||||
|
Reference in New Issue
Block a user