Commit 9688f6fd authored by Marek Vavruša's avatar Marek Vavruša

dnstap: updated doc and build

parent ac5fe324
......@@ -350,6 +350,28 @@ The general syntax for importing a query module is described in the
described by a name and a configuration string. Below is a list of
modules and configuration string reference.
``dnstap`` - dnstap-enabled query logging
-----------------------------------------
The Knot DNS supports dnstap_ for query and response logging.
You can capture either either all or zone-specific queries and responses, usually you want to do
the former. The dnstap module accepts only a sink path as a parameter, which can either be a file
or a UNIX socket prefixed with *unix:*.
For example::
zones {
query_module "/tmp/capture.tap";
}
You can also log to a UNIX socket with the prefix::
zones {
query_module "unix:/tmp/capture.tap";
}
.. _dnstap: http://dnstap.info/
``synth_record`` - Automatic forward/reverse records
----------------------------------------------------
......
......@@ -290,7 +290,7 @@ static void conf_acl_item(void *scanner, char *item)
static void query_module_create(void *scanner, const char *name, const char *param, bool on_zone)
{
struct query_module *module = query_module_open(name, param, NULL);
struct query_module *module = query_module_open(new_config, name, param, NULL);
if (module == NULL) {
cf_error(scanner, "cannot load query module '%s'", name);
return;
......
......@@ -58,9 +58,9 @@ static int log_message(int state, const knot_pkt_t *pkt, struct query_data *qdat
/* Create a dnstap message. */
Dnstap__Message msg;
ret = dt_message_fill(&msg, msgtype,
NULL, /* todo: fill me! */
(const struct sockaddr *)qdata->param->query_source,
protocol,
(const struct sockaddr *)qdata->param->remote,
NULL, /* todo: fill me! */
protocol,
pkt->wire, pkt->size, &tv, &tv);
if (ret != KNOT_EOK) {
return NS_PROC_FAIL;
......@@ -78,7 +78,8 @@ static int log_message(int state, const knot_pkt_t *pkt, struct query_data *qdat
}
/* Submit a request. */
fstrm_res res = fstrm_iothr_submit(iothread, ioq, frame, size, fstrm_free_wrapper, NULL);
fstrm_res res = fstrm_iothr_submit(iothread, ioq, frame, size,
fstrm_free_wrapper, NULL);
if (res != fstrm_res_success) {
free(frame);
state = NS_PROC_FAIL;
......@@ -183,7 +184,7 @@ int dnstap_load(struct query_plan *plan, struct query_module *self)
}
/* Initialize queues. */
size_t qcount = conf_udp_threads(conf()) + conf_tcp_threads(conf());
size_t qcount = conf_udp_threads(self->config) + conf_tcp_threads(self->config);
fstrm_iothr_options_set_num_input_queues(opt, qcount);
/* Create the I/O thread. */
......
......@@ -81,7 +81,8 @@ int query_plan_step(struct query_plan *plan, int stage, qmodule_process_t proces
return KNOT_EOK;
}
struct query_module *query_module_open(const char *name, const char *param, mm_ctx_t *mm)
struct query_module *query_module_open(struct conf_t *config, const char *name,
const char *param, mm_ctx_t *mm)
{
/* Locate compiled-in modules. */
struct compiled_module *found = NULL;
......@@ -105,6 +106,7 @@ struct query_module *query_module_open(const char *name, const char *param, mm_c
size_t buflen = strlen(param) + 1;
memset(module, 0, sizeof(struct query_module));
module->mm = mm;
module->config = config;
module->load = found->load;
module->unload = found->unload;
module->param = mm_alloc(mm, buflen);
......
......@@ -61,6 +61,7 @@ enum query_stage {
struct query_data;
struct query_module;
struct query_plan;
struct conf_t;
/* Module callback required API. */
typedef int (*qmodule_load_t)(struct query_plan *plan, struct query_module *self);
......@@ -77,6 +78,7 @@ struct query_module {
void *ctx;
char *param;
mm_ctx_t *mm;
struct conf_t *config;
qmodule_load_t load;
qmodule_unload_t unload;
};
......@@ -110,7 +112,8 @@ int query_plan_step(struct query_plan *plan, int stage, qmodule_process_t proces
* \brief Open query module identified by name.
* \note Module 'load' hook is NOT called and left upon a caller to decide.
*/
struct query_module *query_module_open(const char *name, const char *param, mm_ctx_t *mm);
struct query_module *query_module_open(struct conf_t *config, const char *name,
const char *param, mm_ctx_t *mm);
/*!
* \brief Close query module.
......
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