Commit 93483791 authored by Mark Andrews's avatar Mark Andrews

4447. [tuning] Allow the fstrm_iothr_init() options to be set using

                        named.conf to control how dnstap manages the data
                        flow. [RT #42974]
parent 0967d759
4447. [tuning] Allow the fstrm_iothr_init() options to be set using
named.conf to control how dnstap manages the data
flow. [RT #42974]
4446. [bug] The cache_find() and _findrdataset() functions
could find rdatasets that had been marked stale.
[RT #42853]
......
......@@ -200,8 +200,19 @@ options {
coresize <replaceable>size</replaceable>;
datasize <replaceable>size</replaceable>;
directory <replaceable>quoted_string</replaceable>;
dnstap { <replaceable>message_type</replaceable>; ... };
dnstap-output ( <literal>file</literal> | <literal>unix</literal> ) <replaceable>path_name</replaceable>;
dnstap-identity ( <replaceable>string</replaceable> | <literal>hostname</literal> | <literal>none</literal> );
dnstap-version ( <replaceable>string</replaceable> | <literal>none</literal> );
dump-file <replaceable>quoted_string</replaceable>;
files <replaceable>size</replaceable>;
fstrm-set-buffer-hint <replaceable>number</replaceable>;
fstrm-set-flush-timeout <replaceable>number</replaceable>;
fstrm-set-input-queue-size <replaceable>number</replaceable>;
fstrm-set-output-notify-threshold <replaceable>number</replaceable>;
fstrm-set-output-queue-model ( <replaceable>mpsc</replaceable> | <replaceable>spsc</replaceable> ) ;
fstrm-set-output-queue-size <replaceable>number</replaceable>;
fstrm-set-reopen-interval <replaceable>number</replaceable>;
heartbeat-interval <replaceable>integer</replaceable>;
host-statistics <replaceable>boolean</replaceable>; // not implemented
host-statistics-max <replaceable>number</replaceable>; // not implemented
......
......@@ -2939,6 +2939,8 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
const cfg_obj_t *dlist = NULL;
dns_dtmsgtype_t dttypes = 0;
dns_dtmode_t dmode;
unsigned int i;
struct fstrm_iothr_options *fopt = NULL;
result = ns_config_get(maps, "dnstap", &dlist);
if (result != ISC_R_SUCCESS)
......@@ -3004,7 +3006,71 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
dpath = cfg_obj_asstring(obj2);
CHECKM(dns_dt_create(ns_g_mctx, dmode, dpath, ns_g_cpus,
fopt = fstrm_iothr_options_init();
fstrm_iothr_options_set_num_input_queues(fopt, ns_g_cpus);
fstrm_iothr_options_set_queue_model(fopt,
FSTRM_IOTHR_QUEUE_MODEL_MPSC);
obj = NULL;
result = ns_config_get(maps, "fstrm-set-buffer-hint", &obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
fstrm_iothr_options_set_buffer_hint(fopt, i);
}
obj = NULL;
result = ns_config_get(maps, "fstrm-set-flush-timeout", &obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
fstrm_iothr_options_set_flush_timeout(fopt, i);
}
obj = NULL;
result = ns_config_get(maps, "fstrm-set-input-queue-size",
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
fstrm_iothr_options_set_input_queue_size(fopt, i);
}
obj = NULL;
result = ns_config_get(maps,
"fstrm-set-output-notify-threshold",
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
fstrm_iothr_options_set_queue_notify_threshold(fopt,
i);
}
obj = NULL;
result = ns_config_get(maps, "fstrm-set-output-queue-model",
&obj);
if (result == ISC_R_SUCCESS) {
if (strcasecmp(cfg_obj_asstring(obj), "spsc") == 0)
i = FSTRM_IOTHR_QUEUE_MODEL_SPSC;
else
i = FSTRM_IOTHR_QUEUE_MODEL_MPSC;
fstrm_iothr_options_set_queue_model(fopt, i);
}
obj = NULL;
result = ns_config_get(maps, "fstrm-set-output-queue-size",
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
fstrm_iothr_options_set_output_queue_size(fopt, i);
}
obj = NULL;
result = ns_config_get(maps, "fstrm-set-reopen-interval",
&obj);
if (result == ISC_R_SUCCESS) {
i = cfg_obj_asuint32(obj);
fstrm_iothr_options_set_reopen_interval(fopt, i);
}
CHECKM(dns_dt_create(ns_g_mctx, dmode, dpath, fopt,
&ns_g_server->dtenv),
"unable to create dnstap environment");
}
......@@ -3041,6 +3107,9 @@ configure_dnstap(const cfg_obj_t **maps, dns_view_t *view) {
result = ISC_R_SUCCESS;
cleanup:
if (fopt != NULL)
fstrm_iothr_options_destroy(&fopt);
return (result);
}
#endif /* HAVE_DNSTAP */
......@@ -11011,7 +11080,7 @@ nzd_count(dns_view_t *view, int *countp) {
int status;
MDB_txn *txn = NULL;
MDB_dbi dbi;
MDB_stat stat;
MDB_stat statbuf;
REQUIRE(countp != NULL);
......@@ -11019,7 +11088,7 @@ nzd_count(dns_view_t *view, int *countp) {
if (result != ISC_R_SUCCESS)
goto cleanup;
status = mdb_stat(txn, dbi, &stat);
status = mdb_stat(txn, dbi, &statbuf);
if (status != 0) {
isc_log_write(ns_g_lctx,
NS_LOGCATEGORY_GENERAL, NS_LOGMODULE_SERVER,
......@@ -11029,7 +11098,7 @@ nzd_count(dns_view_t *view, int *countp) {
goto cleanup;
}
*countp = stat.ms_entries;
*countp = statbuf.ms_entries;
cleanup:
(void) nzd_close(&txn, ISC_FALSE);
......
......@@ -123,6 +123,7 @@ static const char *udpinsizestats_desc[dns_sizecounter_in_max];
static const char *udpoutsizestats_desc[dns_sizecounter_out_max];
static const char *tcpinsizestats_desc[dns_sizecounter_in_max];
static const char *tcpoutsizestats_desc[dns_sizecounter_out_max];
static const char *dnstapstats_desc[dns_dnstapcounter_max];
#if defined(EXTENDED_STATS)
static const char *nsstats_xmldesc[dns_nsstatscounter_max];
static const char *resstats_xmldesc[dns_resstatscounter_max];
......@@ -134,6 +135,7 @@ static const char *udpinsizestats_xmldesc[dns_sizecounter_in_max];
static const char *udpoutsizestats_xmldesc[dns_sizecounter_out_max];
static const char *tcpinsizestats_xmldesc[dns_sizecounter_in_max];
static const char *tcpoutsizestats_xmldesc[dns_sizecounter_out_max];
static const char *dnstapstats_xmldesc[dns_dnstapcounter_max];
#else
#define nsstats_xmldesc NULL
#define resstats_xmldesc NULL
......@@ -145,6 +147,7 @@ static const char *tcpoutsizestats_xmldesc[dns_sizecounter_out_max];
#define udpoutsizestats_xmldesc NULL
#define tcpinsizestats_xmldesc NULL
#define tcpoutsizestats_xmldesc NULL
#define dnstapstats_xmldesc NULL
#endif /* EXTENDED_STATS */
#define TRY0(a) do { xmlrc = (a); if (xmlrc < 0) goto error; } while(0)
......@@ -164,6 +167,7 @@ static int udpinsizestats_index[dns_sizecounter_in_max];
static int udpoutsizestats_index[dns_sizecounter_out_max];
static int tcpinsizestats_index[dns_sizecounter_in_max];
static int tcpoutsizestats_index[dns_sizecounter_out_max];
static int dnstapstats_index[dns_dnstapcounter_max];
static inline void
set_desc(int counter, int maxcounter, const char *fdesc, const char **fdescs,
......@@ -574,6 +578,27 @@ init_desc(void) {
SET_DNSSECSTATDESC(fail, "dnssec validation failures", "DNSSECfail");
INSIST(i == dns_dnssecstats_max);
/* Initialize dnstap statistics */
for (i = 0; i < dns_dnstapcounter_max; i++)
dnstapstats_desc[i] = NULL;
#if defined(EXTENDED_STATS)
for (i = 0; i < dns_dnstapcounter_max; i++)
dnstapstats_xmldesc[i] = NULL;
#endif
#define SET_DNSTAPSTATDESC(counterid, desc, xmldesc) \
do { \
set_desc(dns_dnstapcounter_ ## counterid, \
dns_dnstapcounter_max, \
desc, dnstapstats_desc, \
xmldesc, dnstapstats_xmldesc); \
dnstapstats_index[i++] = dns_dnstapcounter_ ## counterid; \
} while (0)
i = 0;
SET_DNSTAPSTATDESC(success, "dnstap messges written", "DNSTAPsuccess");
SET_DNSTAPSTATDESC(drop, "dnstap messages dropped", "DNSSECdropped");
INSIST(i == dns_dnstapcounter_max);
/* Sanity check */
for (i = 0; i < dns_nsstatscounter_max; i++)
INSIST(nsstats_desc[i] != NULL);
......@@ -587,6 +612,8 @@ init_desc(void) {
INSIST(sockstats_desc[i] != NULL);
for (i = 0; i < dns_dnssecstats_max; i++)
INSIST(dnssecstats_desc[i] != NULL);
for (i = 0; i < dns_dnstapcounter_max; i++)
INSIST(dnstapstats_desc[i] != NULL);
#if defined(EXTENDED_STATS)
for (i = 0; i < dns_nsstatscounter_max; i++)
INSIST(nsstats_xmldesc[i] != NULL);
......@@ -600,6 +627,8 @@ init_desc(void) {
INSIST(sockstats_xmldesc[i] != NULL);
for (i = 0; i < dns_dnssecstats_max; i++)
INSIST(dnssecstats_xmldesc[i] != NULL);
for (i = 0; i < dns_dnstapcounter_max; i++)
INSIST(dnstapstats_xmldesc[i] != NULL);
#endif
/* Initialize traffic size statistics */
......@@ -1480,6 +1509,9 @@ generatexml(ns_server_t *server, isc_uint32_t flags,
isc_uint64_t udpoutsizestat_values[dns_sizecounter_out_max];
isc_uint64_t tcpinsizestat_values[dns_sizecounter_in_max];
isc_uint64_t tcpoutsizestat_values[dns_sizecounter_out_max];
#if HAVE_DNSTAP
isc_uint64_t dnstapstat_values[dns_dnstapcounter_max];
#endif
isc_result_t result;
isc_time_now(&now);
......@@ -1595,6 +1627,28 @@ generatexml(ns_server_t *server, isc_uint32_t flags,
if (result != ISC_R_SUCCESS)
goto error;
TRY0(xmlTextWriterEndElement(writer)); /* resstat */
#if HAVE_DNSTAP
if (server->dtenv != NULL) {
isc_stats_t *dnstapstats = NULL;
TRY0(xmlTextWriterStartElement(writer,
ISC_XMLCHAR "counters"));
TRY0(xmlTextWriterWriteAttribute(writer,
ISC_XMLCHAR "type",
ISC_XMLCHAR "dnstap"));
dns_dt_getstats(ns_g_server->dtenv, &dnstapstats);
result = dump_counters(dnstapstats,
isc_statsformat_xml, writer,
NULL, dnstapstats_xmldesc,
dns_dnstapcounter_max,
dnstapstats_index,
dnstapstat_values, 0);
isc_stats_detach(&dnstapstats);
if (result != ISC_R_SUCCESS)
goto error;
TRY0(xmlTextWriterEndElement(writer)); /* dnstap */
}
#endif
}
if ((flags & STATS_XML_NET) != 0) {
......@@ -2209,6 +2263,9 @@ generatejson(ns_server_t *server, size_t *msglen,
isc_uint64_t udpoutsizestat_values[dns_sizecounter_out_max];
isc_uint64_t tcpinsizestat_values[dns_sizecounter_in_max];
isc_uint64_t tcpoutsizestat_values[dns_sizecounter_out_max];
#if HAVE_DNSTAP
isc_uint64_t dnstapstat_values[dns_dnstapcounter_max];
#endif
stats_dumparg_t dumparg;
char boottime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
char configtime[sizeof "yyyy-mm-ddThh:mm:ss.sssZ"];
......@@ -2370,6 +2427,35 @@ generatejson(ns_server_t *server, size_t *msglen,
json_object_object_add(bindstats, "resstats", counters);
else
json_object_put(counters);
#if HAVE_DNSTAP
/* dnstap stat counters */
if (ns_g_server->dtenv != NULL) {
isc_stats_t *dnstapstats = NULL;
dns_dt_getstats(ns_g_server->dtenv, &dnstapstats);
counters = json_object_new_object();
dumparg.result = ISC_R_SUCCESS;
dumparg.arg = counters;
result = dump_counters(dnstapstats,
isc_statsformat_json, counters,
NULL, dnstapstats_xmldesc,
dns_dnstapcounter_max,
dnstapstats_index,
dnstapstat_values, 0);
isc_stats_detach(&dnstapstats);
if (result != ISC_R_SUCCESS) {
json_object_put(counters);
goto error;
}
if (json_object_get_object(counters)->count != 0)
json_object_object_add(bindstats,
"dnstapstats",
counters);
else
json_object_put(counters);
}
#endif
}
if ((flags & (STATS_JSON_ZONES | STATS_JSON_SERVER)) != 0) {
......
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-buffer-hint 65537;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-buffer-hint 1023;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-flush-timeout 0;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-flush-timeout 601;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-input-queue-size 1;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-input-queue-size 16385;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-input-queue-size 513;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-output-notify-threshold 0;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
/*
* This value is system dependent and matches IOV_MAX.
*/
fstrm-set-output-queue-size 10000000;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-output-queue-size 1;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-reopen-interval 601;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-reopen-interval 0;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-buffer-hint 8192;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-flush-timeout 1;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-input-queue-size 512;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-output-notify-threshold 32;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-output-queue-model mpsc;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-output-queue-model spsc;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-output-queue-size 64;
};
/*
* Copyright (C) 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
options {
fstrm-set-reopen-interval 5;
};
......@@ -13,6 +13,24 @@ RNDCCMD="$RNDC -p 9953 -c ../common/rndc.conf"
status=0
for bad in bad-*.conf
do
ret=0
echo "I: checking that named-checkconf detects error in $bad"
$CHECKCONF $bad > /dev/null 2>&1
if [ $? != 1 ]; then echo "I:failed"; ret=1; fi
status=`expr $status + $ret`
done
for good in good-*.conf
do
ret=0
echo "I: checking that named-checkconf detects no error in $good"
$CHECKCONF $good > /dev/null 2>&1
if [ $? != 0 ]; then echo "I:failed"; ret=1; fi
status=`expr $status + $ret`
done
$DIG +short @10.53.0.3 -p 5300 a.example > dig.out
# check three different dnstap reopen/roll methods:
......
......@@ -4396,6 +4396,14 @@ badresp:1,adberr:0,findfail:0,valfail:0]
<optional> dnstap-output ( <literal>file</literal> | <literal>unix</literal> ) <replaceable>path_name</replaceable>; </optional>
<optional> dnstap-identity ( <replaceable>string</replaceable> | <literal>hostname</literal> | <literal>none</literal> ); </optional>
<optional> dnstap-version ( <replaceable>string</replaceable> | <literal>none</literal> ); </optional>
<optional> fstrm-set-buffer-hint <replaceable>number</replaceable> ; </optional>
<optional> fstrm-set-flush-timeout <replaceable>number</replaceable> ; </optional>
<optional> fstrm-set-input-queue-size <replaceable>number</replaceable> ; </optional>
<optional> fstrm-set-output-notify-threshold <replaceable>number</replaceable> ; </optional>
<optional> fstrm-set-output-queue-model ( <replaceable>mpsc</replaceable> |
<replaceable>spsc</replaceable> ) ; </optional>
<optional> fstrm-set-output-queue-size <replaceable>number</replaceable> ; </optional>
<optional> fstrm-set-reopen-interval <replaceable>number</replaceable> ; </optional>
<optional> geoip-directory <replaceable>path_name</replaceable>; </optional>
<optional> key-directory <replaceable>path_name</replaceable>; </optional>
<optional> managed-keys-directory <replaceable>path_name</replaceable>; </optional>
......@@ -4870,6 +4878,81 @@ badresp:1,adberr:0,findfail:0,valfail:0]
For more information on <command>dnstap</command>, see
<link xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://dnstap.info">http://dnstap.info</link>.
</para>
<para>
The fstrm library has a number of tunables that are exposed
in <filename>named.conf</filename>, and can be modified
if necessary to improve performance or prevent loss of data.
These are:
</para>
<itemizedlist>
<listitem>
<simpara>
<command>fstrm-set-buffer-hint</command>: The
threshold number of bytes to accumulate in the output
buffer before forcing a buffer flush. The minimum is
1K, the maximum is 64K, and the default is 8K.
</simpara>
</listitem>
<listitem>
<simpara>
<command>fstrm-set-flush-timeout</command>: The number
of seconds to allow unflushed data to remain in the
output buffer. The minimum is 1 second, the maximum is
600 seconds (10 minutes), and the default is 1 second.
</simpara>
</listitem>
<listitem>
<simpara>
<command>fstrm-set-output-notify-threshold</command>:
The number of outstanding queue entries to allow on
an input queue before waking the I/O thread.
The minimum is 1 and the default is 32.
</simpara>