Skip to content
Snippets Groups Projects
Verified Commit 1f810f89 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

modules/dnstap: improve UX for common errors

The main thing is the "failed to open socket" message.
But let's also elevate other fatal one-off logs to ERROR level.
parent 73f6ce7d
Branches
Tags
1 merge request!1256modules/dnstap: improve UX for common errors
Pipeline #95780 canceled with stages
in 9 minutes and 12 seconds
......@@ -10,6 +10,8 @@ socket in `dnstap format <https://dnstap.info>`_ using fstrm framing library.
This logging is useful if you need effectively log all DNS traffic.
The unix socket and the socket reader must be present before starting resolver instances.
Also it needs appropriate filesystem permissions;
the typical user and group of the daemon are called ``knot-resolver``.
Tunables:
......
......@@ -22,6 +22,7 @@
#include <uv.h>
#define DEBUG_MSG(fmt, ...) kr_log_debug(DNSTAP, fmt, ##__VA_ARGS__);
#define ERROR_MSG(fmt, ...) kr_log_error(DNSTAP, fmt, ##__VA_ARGS__);
#define CFG_SOCK_PATH "socket_path"
#define CFG_IDENTITY_STRING "identity"
#define CFG_VERSION_STRING "version"
......@@ -415,7 +416,7 @@ int dnstap_config(struct kr_module *module, const char *conf) {
JsonNode *root_node = json_decode(conf);
if (!root_node) {
DEBUG_MSG("error parsing json\n");
ERROR_MSG("error parsing json\n");
return kr_error(EINVAL);
}
......@@ -484,13 +485,15 @@ int dnstap_config(struct kr_module *module, const char *conf) {
DEBUG_MSG("opening sock file %s\n",sock_path);
struct fstrm_writer *writer = dnstap_unix_writer(sock_path);
if (!writer) {
DEBUG_MSG("can't create unix writer\n");
ERROR_MSG("failed to open socket %s\n"
"Please ensure that it exists beforehand and has appropriate access permissions.\n",
sock_path);
return kr_error(EINVAL);
}
struct fstrm_iothr_options *opt = fstrm_iothr_options_init();
if (!opt) {
DEBUG_MSG("can't init fstrm options\n");
ERROR_MSG("can't init fstrm options\n");
fstrm_writer_destroy(&writer);
return kr_error(EINVAL);
}
......@@ -499,7 +502,7 @@ int dnstap_config(struct kr_module *module, const char *conf) {
data->iothread = fstrm_iothr_init(opt, &writer);
fstrm_iothr_options_destroy(&opt);
if (!data->iothread) {
DEBUG_MSG("can't init fstrm_iothr\n");
ERROR_MSG("can't init fstrm_iothr\n");
fstrm_writer_destroy(&writer);
return kr_error(ENOMEM);
}
......@@ -510,7 +513,7 @@ int dnstap_config(struct kr_module *module, const char *conf) {
data->ioq = fstrm_iothr_get_input_queue_idx(data->iothread, 0);
if (!data->ioq) {
fstrm_iothr_destroy(&data->iothread);
DEBUG_MSG("can't get fstrm queue\n");
ERROR_MSG("can't get fstrm queue\n");
return kr_error(EBUSY);
}
......
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