From: Lukáš Ježek Date: Fri, 18 Jun 2021 13:02:17 +0000 (+0200) Subject: log: shortening LOG_GRP_ to X-Git-Tag: v5.4.0~2^2~50 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f994f1027650af50b78877dbf6bf6e14d5daffc8;p=thirdparty%2Fknot-resolver.git log: shortening LOG_GRP_ to --- diff --git a/daemon/bindings/cache.c b/daemon/bindings/cache.c index b761fdb04..ef3f7b0b8 100644 --- a/daemon/bindings/cache.c +++ b/daemon/bindings/cache.c @@ -206,7 +206,7 @@ static int cache_open(lua_State *L) * even in case of not having any work to do. */ ret = kr_cache_check_health(&engine->resolver.cache, 5000); if (ret != 0) { - kr_log_error(LOG_GRP_CACHE, "periodic health check failed (ignored): %s\n", + kr_log_error(CACHE, "periodic health check failed (ignored): %s\n", kr_strerror(ret)); } diff --git a/daemon/bindings/impl.h b/daemon/bindings/impl.h index 0955681e4..fe4be2d66 100644 --- a/daemon/bindings/impl.h +++ b/daemon/bindings/impl.h @@ -69,7 +69,7 @@ static inline int execute_callback(lua_State *L, int argc) { int ret = engine_pcall(L, argc); if (ret != 0) { - kr_log_error(LOG_GRP_SYSTEM, "error: %s\n", lua_tostring(L, -1)); + kr_log_error(SYSTEM, "error: %s\n", lua_tostring(L, -1)); } /* Clear the stack, there may be event a/o enything returned */ lua_settop(L, 0); diff --git a/daemon/bindings/net.c b/daemon/bindings/net.c index 702c84951..1c66358c7 100644 --- a/daemon/bindings/net.c +++ b/daemon/bindings/net.c @@ -141,7 +141,7 @@ static bool net_listen_addrs(lua_State *L, int port, endpoint_flags_t flags, int if (ret == 0) return true; /* success */ if (is_unix) { - kr_log_error(LOG_GRP_NETWORK, "bind to '%s' (UNIX): %s\n", + kr_log_error(NETWORK, "bind to '%s' (UNIX): %s\n", str, kr_strerror(ret)); } else if (flags.xdp) { const char *err_str = knot_strerror(ret); @@ -157,18 +157,18 @@ static bool net_listen_addrs(lua_State *L, int port, endpoint_flags_t flags, int /* Notable OK strerror: KNOT_EPERM Operation not permitted */ if (nic_queue == -1) { - kr_log_error(LOG_GRP_NETWORK, "failed to initialize XDP for '%s@%d'" + kr_log_error(NETWORK, "failed to initialize XDP for '%s@%d'" " (nic_queue = ): %s\n", str, port, err_str); } else { - kr_log_error(LOG_GRP_NETWORK, "failed to initialize XDP for '%s@%d'" + kr_log_error(NETWORK, "failed to initialize XDP for '%s@%d'" " (nic_queue = %d): %s\n", str, port, nic_queue, err_str); } } else { const char *stype = flags.sock_type == SOCK_DGRAM ? "UDP" : "TCP"; - kr_log_error(LOG_GRP_NETWORK, "bind to '%s@%d' (%s): %s\n", + kr_log_error(NETWORK, "bind to '%s@%d' (%s): %s\n", str, port, stype, kr_strerror(ret)); } return false; /* failure */ @@ -775,7 +775,7 @@ static int net_tls_client(lua_State *L) ok_ca = memcmp(newcfg->pins.at[i], oldcfg->pins.at[i], TLS_SHA256_RAW_LEN) == 0; const bool ok_insecure = newcfg->insecure == oldcfg->insecure; if (!(ok_h && ok_ca && ok_pins && ok_insecure)) { - kr_log_warning(LOG_GRP_TLSCLIENT, + kr_log_warning(TLSCLIENT, "warning: re-defining TLS authentication parameters for %s\n", addr_str); } diff --git a/daemon/engine.c b/daemon/engine.c index 8a120006f..5119ed1c5 100644 --- a/daemon/engine.c +++ b/daemon/engine.c @@ -709,7 +709,7 @@ int engine_load_sandbox(struct engine *engine) /* Init environment */ int ret = luaL_dofile(engine->L, LIBDIR "/sandbox.lua"); if (ret != 0) { - kr_log_error(LOG_GRP_SYSTEM, "error %s\n", lua_tostring(engine->L, -1)); + kr_log_error(SYSTEM, "error %s\n", lua_tostring(engine->L, -1)); lua_pop(engine->L, 1); return kr_error(ENOEXEC); } @@ -728,7 +728,7 @@ int engine_loadconf(struct engine *engine, const char *config_path) int ret = luaL_dofile(engine->L, config_path); if (ret != 0) { - kr_log_error(LOG_GRP_SYSTEM, "error while loading config: " + kr_log_error(SYSTEM, "error while loading config: " "%s (workdir '%s')\n", lua_tostring(engine->L, -1), cwd); lua_pop(engine->L, 1); } @@ -808,7 +808,7 @@ int engine_register(struct engine *engine, const char *name, const char *precede ret = engine_pcall(L, 1); } if (kr_fails_assert(ret == 0)) { /* probably not critical, but weird */ - kr_log_error(LOG_GRP_SYSTEM, "internal error when loading C module %s: %s\n", + kr_log_error(SYSTEM, "internal error when loading C module %s: %s\n", module->name, lua_tostring(L, -1)); lua_pop(L, 1); } @@ -817,12 +817,12 @@ int engine_register(struct engine *engine, const char *name, const char *precede /* No luck with C module, so try to load and .init() lua module. */ ret = ffimodule_register_lua(engine, module, name); if (ret != 0) { - kr_log_error(LOG_GRP_SYSTEM, "failed to load module '%s'\n", name); + kr_log_error(SYSTEM, "failed to load module '%s'\n", name); } } else if (ret == kr_error(ENOTSUP)) { /* Print a more helpful message when module is linked against an old resolver ABI. */ - kr_log_error(LOG_GRP_SYSTEM, "module '%s' links to unsupported ABI, please rebuild it\n", name); + kr_log_error(SYSTEM, "module '%s' links to unsupported ABI, please rebuild it\n", name); } if (ret != 0) { diff --git a/daemon/ffimodule.c b/daemon/ffimodule.c index a9562f7e5..073b12c04 100644 --- a/daemon/ffimodule.c +++ b/daemon/ffimodule.c @@ -66,7 +66,7 @@ static int l_ffi_modcb(lua_State *L, struct kr_module *module) lua_pushpointer(L, module); if (lua_pcall(L, 2, 0, 0) == 0) return kr_ok(); - kr_log_error(LOG_GRP_SYSTEM, "error: %s\n", lua_tostring(L, -1)); + kr_log_error(SYSTEM, "error: %s\n", lua_tostring(L, -1)); lua_pop(L, 1); return kr_error(1); } @@ -117,12 +117,12 @@ static int l_ffi_call_layer(kr_layer_t *ctx, int slot_ix) int state = ctx->req->state; if (ret) { /* Exception or another lua problem. */ state = KR_STATE_FAIL; - kr_log_error(LOG_GRP_SYSTEM, "error: %s\n", lua_tostring(L, -1)); + kr_log_error(SYSTEM, "error: %s\n", lua_tostring(L, -1)); } else if (lua_isnumber(L, -1)) { /* Explicitly returned state. */ state = lua_tointeger(L, -1); if (!kr_state_consistent(state)) { - kr_log_error(LOG_GRP_SYSTEM, "error: nonsense state returned from lua module layer: %d\n", + kr_log_error(SYSTEM, "error: nonsense state returned from lua module layer: %d\n", state); state = KR_STATE_FAIL; } @@ -136,7 +136,7 @@ static int l_ffi_call_layer(kr_layer_t *ctx, int slot_ix) } else { /* Nonsense returned. */ state = KR_STATE_FAIL; - kr_log_error(LOG_GRP_SYSTEM, "error: nonsense returned from lua module layer: %s\n", + kr_log_error(SYSTEM, "error: nonsense returned from lua module layer: %s\n", lua_tostring(L, -1)); /* Unfortunately we can't easily get name of the module/function here. */ } @@ -278,7 +278,7 @@ int ffimodule_register_lua(struct engine *engine, struct kr_module *module, cons lua_getglobal(L, "require"); lua_pushfstring(L, "kres_modules.%s", name); if (lua_pcall(L, 1, LUA_MULTRET, 0) != 0) { - kr_log_error(LOG_GRP_SYSTEM, "error: %s\n", lua_tostring(L, -1)); + kr_log_error(SYSTEM, "error: %s\n", lua_tostring(L, -1)); lua_pop(L, 1); return kr_error(ENOENT); } diff --git a/daemon/http.c b/daemon/http.c index b08824563..b1563a9d0 100644 --- a/daemon/http.c +++ b/daemon/http.c @@ -409,7 +409,7 @@ static int data_chunk_recv_callback(nghttp2_session *h2, uint8_t flags, int32_t required += sizeof(uint16_t); if (required > remaining) { - kr_log_error(LOG_GRP_DOH, "insufficient space in buffer\n"); + kr_log_error(DOH, "insufficient space in buffer\n"); ctx->incomplete_stream = -1; return NGHTTP2_ERR_CALLBACK_FAILURE; } diff --git a/daemon/io.c b/daemon/io.c index a384fef3f..39b6b4ec9 100644 --- a/daemon/io.c +++ b/daemon/io.c @@ -165,7 +165,7 @@ int io_bind(const struct sockaddr *addr, int type, const endpoint_flags_t *flags int omit = IP_PMTUDISC_OMIT; if (type == SOCK_DGRAM && addr->sa_family == AF_INET && setsockopt(fd, IPPROTO_IP, IP_MTU_DISCOVER, &omit, sizeof(omit))) { - kr_log_error(LOG_GRP_IO, + kr_log_error(IO, "failed to disable Path MTU discovery for %s UDP: %s\n", kr_straddr(addr), strerror(errno)); } @@ -199,7 +199,7 @@ int io_listen_udp(uv_loop_t *loop, uv_udp_t *handle, int fd) int socklen = sizeof(union inaddr); ret = uv_udp_getsockname(handle, session_get_sockname(s), &socklen); if (ret) { - kr_log_error(LOG_GRP_IO, "ERROR: getsockname failed: %s\n", uv_strerror(ret)); + kr_log_error(IO, "ERROR: getsockname failed: %s\n", uv_strerror(ret)); abort(); /* It might be nontrivial not to leak something here. */ } @@ -517,7 +517,7 @@ int io_listen_tcp(uv_loop_t *loop, uv_tcp_t *handle, int fd, int tcp_backlog, bo #if ENABLE_DOH2 connection = https_accept; #else - kr_log_error(LOG_GRP_IO, "kresd was compiled without libnghttp2 support\n"); + kr_log_error(IO, "kresd was compiled without libnghttp2 support\n"); return kr_error(ENOPROTOOPT); #endif } else if (has_tls) { @@ -536,7 +536,7 @@ int io_listen_tcp(uv_loop_t *loop, uv_tcp_t *handle, int fd, int tcp_backlog, bo #ifdef TCP_DEFER_ACCEPT val = KR_CONN_RTT_MAX/1000; if (setsockopt(fd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &val, sizeof(val))) { - kr_log_error(LOG_GRP_IO, "listen TCP (defer_accept): %s\n", strerror(errno)); + kr_log_error(IO, "listen TCP (defer_accept): %s\n", strerror(errno)); } #endif @@ -553,7 +553,7 @@ int io_listen_tcp(uv_loop_t *loop, uv_tcp_t *handle, int fd, int tcp_backlog, bo val = 1; /* Accepts on/off */ #endif if (setsockopt(fd, IPPROTO_TCP, TCP_FASTOPEN, &val, sizeof(val))) { - kr_log_error(LOG_GRP_IO, "listen TCP (fastopen): %s%s\n", strerror(errno), + kr_log_error(IO, "listen TCP (fastopen): %s%s\n", strerror(errno), (errno != EPERM ? "" : ". This may be caused by TCP Fast Open being disabled in the OS.")); } @@ -686,7 +686,7 @@ void io_tty_process_input(uv_stream_t *stream, ssize_t nread, const uv_buf_t *bu if (data->mode == io_mode_binary) { /* Leader expects length field in all cases */ if (!message || len_s > UINT32_MAX) { - kr_log_error(LOG_GRP_IO, "unrepresentable respose on control socket, " + kr_log_error(IO, "unrepresentable respose on control socket, " "sending back empty block (command '%s')\n", cmd); len_s = 0; } @@ -798,11 +798,11 @@ static void xdp_rx(uv_poll_t* handle, int status, int events) { const int XDP_RX_BATCH_SIZE = 64; if (status < 0) { - kr_log_error(LOG_GRP_XDP, "poll status %d: %s\n", status, uv_strerror(status)); + kr_log_error(XDP, "poll status %d: %s\n", status, uv_strerror(status)); return; } if (events != UV_READABLE) { - kr_log_error(LOG_GRP_XDP, "poll unexpected events: %d\n", events); + kr_log_error(XDP, "poll unexpected events: %d\n", events); return; } @@ -818,7 +818,7 @@ static void xdp_rx(uv_poll_t* handle, int status, int events) if (kr_fails_assert(ret == KNOT_EOK)) { /* ATM other error codes can only be returned when called incorrectly */ - kr_log_error(LOG_GRP_XDP, "knot_xdp_recv(): %d, %s\n", ret, knot_strerror(ret)); + kr_log_error(XDP, "knot_xdp_recv(): %d, %s\n", ret, knot_strerror(ret)); return; } kr_log_verbose("poll triggered, processing a batch of %d packets\n", (int)rcvd); @@ -850,7 +850,7 @@ static void xdp_warn_mode(const char *ifname) const unsigned if_index = if_nametoindex(ifname); if (!if_index) { - kr_log_warning(LOG_GRP_XDP, "warning: interface %s, unexpected error when converting its name: %s\n", + kr_log_warning(XDP, "warning: interface %s, unexpected error when converting its name: %s\n", ifname, strerror(errno)); return; } @@ -860,13 +860,13 @@ static void xdp_warn_mode(const char *ifname) case KNOT_XDP_MODE_FULL: return; case KNOT_XDP_MODE_EMUL: - kr_log_warning(LOG_GRP_XDP, "warning: interface %s running only with XDP emulation\n", + kr_log_warning(XDP, "warning: interface %s running only with XDP emulation\n", ifname); return; case KNOT_XDP_MODE_NONE: // enum warnings from compiler break; } - kr_log_warning(LOG_GRP_XDP, "warning: interface %s running in unexpected XDP mode %d\n", + kr_log_warning(XDP, "warning: interface %s running in unexpected XDP mode %d\n", ifname, (int)mode); } int io_listen_xdp(uv_loop_t *loop, struct endpoint *ep, const char *ifname) diff --git a/daemon/main.c b/daemon/main.c index 1d7b3a70a..084cd1024 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -56,7 +56,7 @@ static void signal_handler(uv_signal_t *handle, int signum) while (waitpid(-1, NULL, WNOHANG) > 0); break; default: - kr_log_error(LOG_GRP_SYSTEM, "unhandled signal: %d\n", signum); + kr_log_error(SYSTEM, "unhandled signal: %d\n", signum); break; } } @@ -149,7 +149,7 @@ static int run_worker(uv_loop_t *loop, struct engine *engine, bool leader, struc case UV_NAMED_PIPE: /* echo 'quit()' | kresd ... */ break; default: - kr_log_error(LOG_GRP_SYSTEM, + kr_log_error(SYSTEM, "error: standard input is not a terminal or pipe; " "use '-n' if you want non-interactive mode. " "Commands can be simply added to your configuration file or sent over the control socket.\n" @@ -245,12 +245,12 @@ static int parse_args(int argc, char **argv, struct args *args) kr_require(optarg); args->forks = strtol(optarg, NULL, 10); if (args->forks == 1) { - kr_log_deprecate(LOG_GRP_SYSTEM, "use --noninteractive instead of --forks=1\n"); + kr_log_deprecate(SYSTEM, "use --noninteractive instead of --forks=1\n"); } else { - kr_log_deprecate(LOG_GRP_SYSTEM, "support for running multiple --forks will be removed\n"); + kr_log_deprecate(SYSTEM, "support for running multiple --forks will be removed\n"); } if (args->forks <= 0) { - kr_log_error(LOG_GRP_SYSTEM, "error '-f' requires a positive" + kr_log_error(SYSTEM, "error '-f' requires a positive" " number, not '%s'\n", optarg); return EXIT_FAILURE; } @@ -265,7 +265,7 @@ static int parse_args(int argc, char **argv, struct args *args) args->quiet = true; break; case 'V': - kr_log_info(LOG_GRP_SYSTEM, "%s, version %s\n", "Knot Resolver", PACKAGE_VERSION); + kr_log_info(SYSTEM, "%s, version %s\n", "Knot Resolver", PACKAGE_VERSION); return EXIT_SUCCESS; case 'h': case '?': @@ -290,7 +290,7 @@ static int parse_args(int argc, char **argv, struct args *args) /* Some other kind; no checks here. */ ffd.flags.kind = strdup(endptr + 1); } else { - kr_log_error(LOG_GRP_SYSTEM, "incorrect value passed to '-S/--fd': %s\n", + kr_log_error(SYSTEM, "incorrect value passed to '-S/--fd': %s\n", optarg); return EXIT_FAILURE; } @@ -349,7 +349,7 @@ static int bind_sockets(addr_array_t *addrs, bool tls, flagged_fd_array_t *fds) } free(sa); if (ret != 0) { - kr_log_error(LOG_GRP_NETWORK, "bind to '%s'%s: %s\n", + kr_log_error(NETWORK, "bind to '%s'%s: %s\n", addrs->at[i], tls ? " (TLS)" : "", kr_strerror(ret)); has_error = true; } @@ -368,7 +368,7 @@ static int start_listening(struct network *net, flagged_fd_array_t *fds) { /* TODO: try logging address@port. It's not too important, * because typical problems happen during binding already. * (invalid address, permission denied) */ - kr_log_error(LOG_GRP_NETWORK, "listen on fd=%d: %s\n", + kr_log_error(NETWORK, "listen on fd=%d: %s\n", ffd->fd, kr_strerror(ret)); /* Continue printing all of these before exiting. */ } else { @@ -392,7 +392,7 @@ static void drop_capabilities(void) /* Apply. */ if (capng_apply(CAPNG_SELECT_BOTH) < 0) { - kr_log_error(LOG_GRP_SYSTEM, "failed to set process capabilities: %s\n", + kr_log_error(SYSTEM, "failed to set process capabilities: %s\n", strerror(errno)); } else { kr_log_verbose("[system] all capabilities dropped\n"); @@ -407,12 +407,12 @@ static void drop_capabilities(void) int main(int argc, char **argv) { if (setvbuf(stdout, NULL, _IONBF, 0) || setvbuf(stderr, NULL, _IONBF, 0)) { - kr_log_error(LOG_GRP_SYSTEM, "failed to to set output buffering (ignored): %s\n", + kr_log_error(SYSTEM, "failed to to set output buffering (ignored): %s\n", strerror(errno)); fflush(stderr); } if (strcmp("linux", OPERATING_SYSTEM) != 0) - kr_log_warning(LOG_GRP_SYSTEM, "Knot Resolver is tested on Linux, other platforms might exhibit bugs.\n" + kr_log_warning(SYSTEM, "Knot Resolver is tested on Linux, other platforms might exhibit bugs.\n" "Please report issues to https://gitlab.nic.cz/knot/knot-resolver/issues/\n" "Thank you for your time and interest!\n"); @@ -432,7 +432,7 @@ int main(int argc, char **argv) /* FIXME: access isn't a good way if we start as root and drop privileges later */ if (access(the_args->rundir, W_OK) != 0 || chdir(the_args->rundir) != 0) { - kr_log_error(LOG_GRP_SYSTEM, "rundir '%s': %s\n", + kr_log_error(SYSTEM, "rundir '%s': %s\n", the_args->rundir, strerror(errno)); return EXIT_FAILURE; } @@ -450,7 +450,7 @@ int main(int argc, char **argv) } else if (access(config, R_OK) != 0) { char cwd[PATH_MAX]; get_workdir(cwd, sizeof(cwd)); - kr_log_error(LOG_GRP_SYSTEM, "config '%s' (workdir '%s'): %s\n", + kr_log_error(SYSTEM, "config '%s' (workdir '%s'): %s\n", config, cwd, strerror(errno)); return EXIT_FAILURE; } @@ -471,10 +471,10 @@ int main(int argc, char **argv) ret = setrlimit(RLIMIT_NOFILE, &rlim); } if (ret) { - kr_log_error(LOG_GRP_SYSTEM, "failed to get or set file-descriptor limit: %s\n", + kr_log_error(SYSTEM, "failed to get or set file-descriptor limit: %s\n", strerror(errno)); } else if (rlim.rlim_cur < 512*1024) { - kr_log_warning(LOG_GRP_SYSTEM, "warning: hard limit for number of file-descriptors is only %ld but recommended value is 524288\n", + kr_log_warning(SYSTEM, "warning: hard limit for number of file-descriptors is only %ld but recommended value is 524288\n", (long)rlim.rlim_cur); } @@ -492,13 +492,13 @@ int main(int argc, char **argv) static struct engine engine; ret = engine_init(&engine, &pool); if (ret != 0) { - kr_log_error(LOG_GRP_SYSTEM, "failed to initialize engine: %s\n", kr_strerror(ret)); + kr_log_error(SYSTEM, "failed to initialize engine: %s\n", kr_strerror(ret)); return EXIT_FAILURE; } /* Initialize the worker */ ret = worker_init(&engine, the_args->forks); if (ret != 0) { - kr_log_error(LOG_GRP_SYSTEM, "failed to initialize worker: %s\n", kr_strerror(ret)); + kr_log_error(SYSTEM, "failed to initialize worker: %s\n", kr_strerror(ret)); return EXIT_FAILURE; } @@ -525,7 +525,7 @@ int main(int argc, char **argv) } } if (ret) { - kr_log_error(LOG_GRP_SYSTEM, "failed to set up signal handlers: %s\n", + kr_log_error(SYSTEM, "failed to set up signal handlers: %s\n", strerror(abs(errno))); ret = EXIT_FAILURE; goto cleanup; @@ -534,7 +534,7 @@ int main(int argc, char **argv) * (of the usual type) may skew results, e.g. epoll_pwait() taking lots of time. */ ret = uv_loop_configure(loop, UV_LOOP_BLOCK_SIGNAL, SIGPROF); if (ret) { - kr_log_info(LOG_GRP_SYSTEM, "failed to block SIGPROF in event loop, ignoring: %s\n", + kr_log_info(SYSTEM, "failed to block SIGPROF in event loop, ignoring: %s\n", uv_strerror(ret)); } @@ -546,7 +546,7 @@ int main(int argc, char **argv) ret = udp_queue_init_global(loop); if (ret) { - kr_log_error(LOG_GRP_SYSTEM, "failed to initialize UDP queue: %s\n", + kr_log_error(SYSTEM, "failed to initialize UDP queue: %s\n", kr_strerror(ret)); ret = EXIT_FAILURE; goto cleanup; diff --git a/daemon/network.c b/daemon/network.c index db401daf7..e018a02e5 100644 --- a/daemon/network.c +++ b/daemon/network.c @@ -46,11 +46,11 @@ static int endpoint_open_lua_cb(struct network *net, struct endpoint *ep, void **pp = trie_get_try(net->endpoint_kinds, ep->flags.kind, strlen(ep->flags.kind)); if (!pp && net->missing_kind_is_error) { - kr_log_error(LOG_GRP_NETWORK, "error: network socket kind '%s' not handled when opening '%s", + kr_log_error(NETWORK, "error: network socket kind '%s' not handled when opening '%s", ep->flags.kind, log_addr); if (ep->family != AF_UNIX) - kr_log_error(LOG_GRP_NETWORK, "#%d", ep->port); - kr_log_error(LOG_GRP_NETWORK, "'\n"); + kr_log_error(NETWORK, "#%d", ep->port); + kr_log_error(NETWORK, "'\n"); return kr_error(ENOENT); } if (!pp) return kr_ok(); @@ -66,7 +66,7 @@ static int endpoint_open_lua_cb(struct network *net, struct endpoint *ep, lua_pushfstring(L, "%s#%d", log_addr, ep->port); } if (lua_pcall(L, 3, 0, 0)) { - kr_log_error(LOG_GRP_NETWORK, "error opening %s: %s\n", log_addr, lua_tostring(L, -1)); + kr_log_error(NETWORK, "error opening %s: %s\n", log_addr, lua_tostring(L, -1)); return kr_error(ENOSYS); /* TODO: better value? */ } ep->engaged = true; @@ -106,7 +106,7 @@ static void endpoint_close_lua_cb(struct network *net, struct endpoint *ep) void **pp = trie_get_try(net->endpoint_kinds, ep->flags.kind, strlen(ep->flags.kind)); if (!pp && net->missing_kind_is_error) { - kr_log_error(LOG_GRP_NETWORK, "internal error: missing kind '%s' in endpoint registry\n", + kr_log_error(NETWORK, "internal error: missing kind '%s' in endpoint registry\n", ep->flags.kind); return; } @@ -118,7 +118,7 @@ static void endpoint_close_lua_cb(struct network *net, struct endpoint *ep) lua_pushpointer(L, ep); lua_pushstring(L, "FIXME:endpoint-identifier"); if (lua_pcall(L, 3, 0, 0)) { - kr_log_error(LOG_GRP_NETWORK, "failed to close FIXME:endpoint-identifier: %s\n", + kr_log_error(NETWORK, "failed to close FIXME:endpoint-identifier: %s\n", lua_tostring(L, -1)); } } @@ -135,7 +135,7 @@ static void endpoint_close(struct network *net, struct endpoint *ep, bool force) socklen_t addr_len = sizeof(sa); if (getsockname(ep->fd, (struct sockaddr *)&sa, &addr_len) || unlink(sa.sun_path)) { - kr_log_error(LOG_GRP_NETWORK, "error (ignored) when closing unix socket (fd = %d): %s\n", + kr_log_error(NETWORK, "error (ignored) when closing unix socket (fd = %d): %s\n", ep->fd, strerror(errno)); return; } @@ -292,7 +292,7 @@ static int open_endpoint(struct network *net, const char *addr_str, if (ep->family == AF_UNIX) { /* Some parts of connection handling would need more work, * so let's support AF_UNIX only with .kind != NULL for now. */ - kr_log_error(LOG_GRP_NETWORK, "AF_UNIX only supported with set { kind = '...' }\n"); + kr_log_error(NETWORK, "AF_UNIX only supported with set { kind = '...' }\n"); ret = EAFNOSUPPORT; goto finish_ret; /* @@ -549,9 +549,9 @@ void network_new_hostname(struct network *net, struct engine *engine) if (newcreds) { tls_credentials_release(net->tls_credentials); net->tls_credentials = newcreds; - kr_log_info(LOG_GRP_TLS, "Updated ephemeral X.509 cert with new hostname\n"); + kr_log_info(TLS, "Updated ephemeral X.509 cert with new hostname\n"); } else { - kr_log_error(LOG_GRP_TLS, "Failed to update ephemeral X.509 cert with new hostname, using existing one\n"); + kr_log_error(TLS, "Failed to update ephemeral X.509 cert with new hostname, using existing one\n"); } } } @@ -588,7 +588,7 @@ int network_set_bpf(struct network *net, int bpf_fd) return 0; } #else - kr_log_error(LOG_GRP_NETWORK, "SO_ATTACH_BPF socket option doesn't supported\n"); + kr_log_error(NETWORK, "SO_ATTACH_BPF socket option doesn't supported\n"); (void)net; (void)bpf_fd; return 0; @@ -611,7 +611,7 @@ static int clear_bpf_cb(const char *key, void *val, void *ext) kr_require(sockfd != -1); if (setsockopt(sockfd, SOL_SOCKET, SO_DETACH_BPF, NULL, 0) != 0) { - kr_log_error(LOG_GRP_NETWORK, "failed to clear SO_DETACH_BPF socket option\n"); + kr_log_error(NETWORK, "failed to clear SO_DETACH_BPF socket option\n"); } /* Proceed even if setsockopt() failed, * as we want to process all opened sockets. */ @@ -625,7 +625,7 @@ void network_clear_bpf(struct network *net) #ifdef SO_DETACH_BPF map_walk(&net->endpoints, clear_bpf_cb, NULL); #else - kr_log_error(LOG_GRP_NETWORK, "SO_DETACH_BPF socket option doesn't supported\n"); + kr_log_error(NETWORK, "SO_DETACH_BPF socket option doesn't supported\n"); (void)net; #endif } diff --git a/daemon/tls.c b/daemon/tls.c index c3ef8b3bb..e402be7f4 100644 --- a/daemon/tls.c +++ b/daemon/tls.c @@ -60,7 +60,7 @@ static int kres_gnutls_set_priority(gnutls_session_t session) { const char *errpos = NULL; int err = gnutls_priority_set_direct(session, priorities, &errpos); if (err != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "setting priority '%s' failed at character %zd (...'%s') with %s (%d)\n", + kr_log_error(TLS, "setting priority '%s' failed at character %zd (...'%s') with %s (%d)\n", priorities, errpos - priorities, errpos, gnutls_strerror_name(err), err); } return err; @@ -295,10 +295,10 @@ struct tls_ctx *tls_new(struct worker_ctx *worker) if (!net->tls_credentials) { net->tls_credentials = tls_get_ephemeral_credentials(worker->engine); if (!net->tls_credentials) { - kr_log_error(LOG_GRP_TLS, "X.509 credentials are missing, and ephemeral credentials failed; no TLS\n"); + kr_log_error(TLS, "X.509 credentials are missing, and ephemeral credentials failed; no TLS\n"); return NULL; } - kr_log_info(LOG_GRP_TLS, "Using ephemeral TLS credentials\n"); + kr_log_info(TLS, "Using ephemeral TLS credentials\n"); tls_credentials_log_pins(net->tls_credentials); } @@ -311,15 +311,15 @@ struct tls_ctx *tls_new(struct worker_ctx *worker) if (newcreds) { tls_credentials_release(net->tls_credentials); net->tls_credentials = newcreds; - kr_log_info(LOG_GRP_TLS, "Renewed expiring ephemeral X.509 cert\n"); + kr_log_info(TLS, "Renewed expiring ephemeral X.509 cert\n"); } else { - kr_log_error(LOG_GRP_TLS, "Failed to renew expiring ephemeral X.509 cert, using existing one\n"); + kr_log_error(TLS, "Failed to renew expiring ephemeral X.509 cert, using existing one\n"); } } } else { /* non-ephemeral cert: warn once when certificate expires */ if (now >= net->tls_credentials->valid_until) { - kr_log_error(LOG_GRP_TLS, "X.509 certificate has expired!\n"); + kr_log_error(TLS, "X.509 certificate has expired!\n"); net->tls_credentials->valid_until = GNUTLS_X509_NO_WELL_DEFINED_EXPIRATION; } } @@ -327,13 +327,13 @@ struct tls_ctx *tls_new(struct worker_ctx *worker) struct tls_ctx *tls = calloc(1, sizeof(struct tls_ctx)); if (tls == NULL) { - kr_log_error(LOG_GRP_TLS, "failed to allocate TLS context\n"); + kr_log_error(TLS, "failed to allocate TLS context\n"); return NULL; } int err = gnutls_init(&tls->c.tls_session, GNUTLS_SERVER | GNUTLS_NONBLOCK); if (err != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "gnutls_init(): %s (%d)\n", gnutls_strerror_name(err), err); + kr_log_error(TLS, "gnutls_init(): %s (%d)\n", gnutls_strerror_name(err), err); tls_free(tls); return NULL; } @@ -341,7 +341,7 @@ struct tls_ctx *tls_new(struct worker_ctx *worker) err = gnutls_credentials_set(tls->c.tls_session, GNUTLS_CRD_CERTIFICATE, tls->credentials->credentials); if (err != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "gnutls_credentials_set(): %s (%d)\n", gnutls_strerror_name(err), err); + kr_log_error(TLS, "gnutls_credentials_set(): %s (%d)\n", gnutls_strerror_name(err), err); tls_free(tls); return NULL; } @@ -435,7 +435,7 @@ int tls_write(uv_write_t *req, uv_handle_t *handle, knot_pkt_t *pkt, uv_write_cb } if (ret != submitted) { - kr_log_error(LOG_GRP_TLS, "[%s] gnutls_record_uncork didn't send all data (%d of %zd)\n", + kr_log_error(TLS, "[%s] gnutls_record_uncork didn't send all data (%d of %zd)\n", logstring, ret, submitted); return kr_error(EIO); } @@ -605,7 +605,7 @@ void tls_credentials_log_pins(struct tls_credentials *tls_credentials) index, &certs, &cert_count); if (err != GNUTLS_E_SUCCESS) { if (err != GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) { - kr_log_error(LOG_GRP_TLS, "could not get X.509 certificates (%d) %s\n", + kr_log_error(TLS, "could not get X.509 certificates (%d) %s\n", err, gnutls_strerror_name(err)); } return; @@ -615,10 +615,10 @@ void tls_credentials_log_pins(struct tls_credentials *tls_credentials) char pin[TLS_SHA256_BASE64_BUFLEN] = { 0 }; err = get_oob_key_pin(certs[i], pin, sizeof(pin), false); if (err != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "could not calculate RFC 7858 OOB key-pin from cert %d (%d) %s\n", + kr_log_error(TLS, "could not calculate RFC 7858 OOB key-pin from cert %d (%d) %s\n", i, err, gnutls_strerror_name(err)); } else { - kr_log_info(LOG_GRP_TLS, "RFC 7858 OOB key-pin (%d): pin-sha256=\"%s\"\n", + kr_log_info(TLS, "RFC 7858 OOB key-pin (%d): pin-sha256=\"%s\"\n", i, pin); } gnutls_x509_crt_deinit(certs[i]); @@ -653,17 +653,17 @@ static time_t _get_end_entity_expiration(gnutls_certificate_credentials_t creds) time_t ret = GNUTLS_X509_NO_WELL_DEFINED_EXPIRATION; if ((err = gnutls_certificate_get_crt_raw(creds, 0, 0, &data)) != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "failed to get cert to check expiration: (%d) %s\n", + kr_log_error(TLS, "failed to get cert to check expiration: (%d) %s\n", err, gnutls_strerror_name(err)); goto done; } if ((err = gnutls_x509_crt_init(&cert)) != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "failed to initialize cert: (%d) %s\n", + kr_log_error(TLS, "failed to initialize cert: (%d) %s\n", err, gnutls_strerror_name(err)); goto done; } if ((err = gnutls_x509_crt_import(cert, &data, GNUTLS_X509_FMT_DER)) != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "failed to construct cert while checking expiration: (%d) %s\n", + kr_log_error(TLS, "failed to construct cert while checking expiration: (%d) %s\n", err, gnutls_strerror_name(err)); goto done; } @@ -689,14 +689,14 @@ int tls_certificate_set(struct network *net, const char *tls_cert, const char *t int err = 0; if ((err = gnutls_certificate_allocate_credentials(&tls_credentials->credentials)) != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLS, "gnutls_certificate_allocate_credentials() failed: (%d) %s\n", + kr_log_error(TLS, "gnutls_certificate_allocate_credentials() failed: (%d) %s\n", err, gnutls_strerror_name(err)); tls_credentials_free(tls_credentials); return kr_error(ENOMEM); } if ((err = gnutls_certificate_set_x509_system_trust(tls_credentials->credentials)) < 0) { if (err != GNUTLS_E_UNIMPLEMENTED_FEATURE) { - kr_log_warning(LOG_GRP_TLS, "warning: gnutls_certificate_set_x509_system_trust() failed: (%d) %s\n", + kr_log_warning(TLS, "warning: gnutls_certificate_set_x509_system_trust() failed: (%d) %s\n", err, gnutls_strerror_name(err)); tls_credentials_free(tls_credentials); return err; @@ -712,7 +712,7 @@ int tls_certificate_set(struct network *net, const char *tls_cert, const char *t if ((err = gnutls_certificate_set_x509_key_file(tls_credentials->credentials, tls_cert, tls_key, GNUTLS_X509_FMT_PEM)) != GNUTLS_E_SUCCESS) { tls_credentials_free(tls_credentials); - kr_log_error(LOG_GRP_TLS, "gnutls_certificate_set_x509_key_file(%s,%s) failed: %d (%s)\n", + kr_log_error(TLS, "gnutls_certificate_set_x509_key_file(%s,%s) failed: %d (%s)\n", tls_cert, tls_key, err, gnutls_strerror_name(err)); return kr_error(EINVAL); } @@ -829,7 +829,7 @@ tls_client_param_t * tls_client_param_new() e->refs = 1; int ret = gnutls_certificate_allocate_credentials(&e->credentials); if (ret != GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLSCLIENT, "error: gnutls_certificate_allocate_credentials() fails (%s)\n", + kr_log_error(TLSCLIENT, "error: gnutls_certificate_allocate_credentials() fails (%s)\n", gnutls_strerror_name(ret)); free(e); return NULL; @@ -961,12 +961,12 @@ static int client_verify_pin(const unsigned int cert_list_size, params->pins.len); } - kr_log_error(LOG_GRP_TLSCLIENT, "no pin matched: %zu pins * %d certificates\n", + kr_log_error(TLSCLIENT, "no pin matched: %zu pins * %d certificates\n", params->pins.len, cert_list_size); return GNUTLS_E_CERTIFICATE_ERROR; #else /* TLS_CAN_USE_PINS */ - kr_log_error(LOG_GRP_TLSCLIENT, "internal inconsistency: TLS_CAN_USE_PINS\n"); + kr_log_error(TLSCLIENT, "internal inconsistency: TLS_CAN_USE_PINS\n"); kr_assert(false); return GNUTLS_E_CERTIFICATE_ERROR; #endif @@ -981,7 +981,7 @@ static int client_verify_pin(const unsigned int cert_list_size, static int client_verify_certchain(gnutls_session_t tls_session, const char *hostname) { if (kr_fails_assert(hostname)) { - kr_log_error(LOG_GRP_TLSCLIENT, "internal config inconsistency: no hostname set\n"); + kr_log_error(TLSCLIENT, "internal config inconsistency: no hostname set\n"); return GNUTLS_E_CERTIFICATE_ERROR; } @@ -996,16 +996,16 @@ static int client_verify_certchain(gnutls_session_t tls_session, const char *hos ret = gnutls_certificate_verification_status_print( status, gnutls_certificate_type_get(tls_session), &msg, 0); if (ret == GNUTLS_E_SUCCESS) { - kr_log_error(LOG_GRP_TLSCLIENT, "failed to verify peer certificate: " + kr_log_error(TLSCLIENT, "failed to verify peer certificate: " "%s\n", msg.data); gnutls_free(msg.data); } else { - kr_log_error(LOG_GRP_TLSCLIENT, "failed to verify peer certificate: " + kr_log_error(TLSCLIENT, "failed to verify peer certificate: " "unable to print reason: %s (%s)\n", gnutls_strerror(ret), gnutls_strerror_name(ret)); } /* gnutls_certificate_verification_status_print end */ } else { - kr_log_error(LOG_GRP_TLSCLIENT, "failed to verify peer certificate: " + kr_log_error(TLSCLIENT, "failed to verify peer certificate: " "gnutls_certificate_verify_peers3 error: %s (%s)\n", gnutls_strerror(ret), gnutls_strerror_name(ret)); } /* gnutls_certificate_verify_peers3 end */ @@ -1029,7 +1029,7 @@ static int client_verify_certificate(gnutls_session_t tls_session) gnutls_certificate_type_t cert_type = gnutls_certificate_type_get(tls_session); if (cert_type != GNUTLS_CRT_X509) { - kr_log_error(LOG_GRP_TLSCLIENT, "invalid certificate type %i has been received\n", + kr_log_error(TLSCLIENT, "invalid certificate type %i has been received\n", cert_type); return GNUTLS_E_CERTIFICATE_ERROR; } @@ -1037,7 +1037,7 @@ static int client_verify_certificate(gnutls_session_t tls_session) const gnutls_datum_t *cert_list = gnutls_certificate_get_peers(tls_session, &cert_list_size); if (cert_list == NULL || cert_list_size == 0) { - kr_log_error(LOG_GRP_TLSCLIENT, "empty certificate list\n"); + kr_log_error(TLSCLIENT, "empty certificate list\n"); return GNUTLS_E_CERTIFICATE_ERROR; } diff --git a/daemon/tls_ephemeral_credentials.c b/daemon/tls_ephemeral_credentials.c index 2cab8b4b2..316894cf2 100644 --- a/daemon/tls_ephemeral_credentials.c +++ b/daemon/tls_ephemeral_credentials.c @@ -63,12 +63,12 @@ static gnutls_x509_privkey_t get_ephemeral_privkey () * with a shared cache don't both create the same privkey: */ lock = _lock_filename(EPHEMERAL_PRIVKEY_FILENAME ".lock"); if (_lock_is_invalid(lock)) { - kr_log_error(LOG_GRP_TLS, "unable to lock lockfile " EPHEMERAL_PRIVKEY_FILENAME ".lock\n"); + kr_log_error(TLS, "unable to lock lockfile " EPHEMERAL_PRIVKEY_FILENAME ".lock\n"); goto done; } if ((err = gnutls_x509_privkey_init (&privkey)) < 0) { - kr_log_error(LOG_GRP_TLS, "gnutls_x509_privkey_init() failed: %d (%s)\n", + kr_log_error(TLS, "gnutls_x509_privkey_init() failed: %d (%s)\n", err, gnutls_strerror_name(err)); goto done; } @@ -81,22 +81,22 @@ static gnutls_x509_privkey_t get_ephemeral_privkey () struct stat stat; ssize_t bytes_read; if (fstat(datafd, &stat)) { - kr_log_error(LOG_GRP_TLS, "unable to stat ephemeral private key " EPHEMERAL_PRIVKEY_FILENAME "\n"); + kr_log_error(TLS, "unable to stat ephemeral private key " EPHEMERAL_PRIVKEY_FILENAME "\n"); goto bad_data; } data.data = gnutls_malloc(stat.st_size); if (data.data == NULL) { - kr_log_error(LOG_GRP_TLS, "unable to allocate memory for reading ephemeral private key\n"); + kr_log_error(TLS, "unable to allocate memory for reading ephemeral private key\n"); goto bad_data; } data.size = stat.st_size; bytes_read = read(datafd, data.data, stat.st_size); if (bytes_read != stat.st_size) { - kr_log_error(LOG_GRP_TLS, "unable to read ephemeral private key\n"); + kr_log_error(TLS, "unable to read ephemeral private key\n"); goto bad_data; } if ((err = gnutls_x509_privkey_import (privkey, &data, GNUTLS_X509_FMT_PEM)) < 0) { - kr_log_error(LOG_GRP_TLS, "gnutls_x509_privkey_import() failed: %d (%s)\n", + kr_log_error(TLS, "gnutls_x509_privkey_import() failed: %d (%s)\n", err, gnutls_strerror_name(err)); /* goto bad_data; */ bad_data: @@ -115,25 +115,25 @@ static gnutls_x509_privkey_t get_ephemeral_privkey () #else if ((err = gnutls_x509_privkey_generate(privkey, GNUTLS_PK_RSA, gnutls_sec_param_to_pk_bits(GNUTLS_PK_RSA, GNUTLS_SEC_PARAM_MEDIUM), 0)) < 0) { #endif - kr_log_error(LOG_GRP_TLS, "gnutls_x509_privkey_init() failed: %d (%s)\n", + kr_log_error(TLS, "gnutls_x509_privkey_init() failed: %d (%s)\n", err, gnutls_strerror_name(err)); gnutls_x509_privkey_deinit(privkey); goto done; } /* ... and save */ - kr_log_info(LOG_GRP_TLS, "Stashing ephemeral private key in " EPHEMERAL_PRIVKEY_FILENAME "\n"); + kr_log_info(TLS, "Stashing ephemeral private key in " EPHEMERAL_PRIVKEY_FILENAME "\n"); if ((err = gnutls_x509_privkey_export2(privkey, GNUTLS_X509_FMT_PEM, &data)) < 0) { - kr_log_error(LOG_GRP_TLS, "gnutls_x509_privkey_export2() failed: %d (%s), not storing\n", + kr_log_error(TLS, "gnutls_x509_privkey_export2() failed: %d (%s), not storing\n", err, gnutls_strerror_name(err)); } else { datafd = open(EPHEMERAL_PRIVKEY_FILENAME, O_WRONLY|O_CREAT, 0600); if (datafd == -1) { - kr_log_error(LOG_GRP_TLS, "failed to open " EPHEMERAL_PRIVKEY_FILENAME " to store the ephemeral key\n"); + kr_log_error(TLS, "failed to open " EPHEMERAL_PRIVKEY_FILENAME " to store the ephemeral key\n"); } else { ssize_t bytes_written; bytes_written = write(datafd, data.data, data.size); if (bytes_written != data.size) - kr_log_error(LOG_GRP_TLS, "failed to write %d octets to " + kr_log_error(TLS, "failed to write %d octets to " EPHEMERAL_PRIVKEY_FILENAME " (%zd written)\n", data.size, bytes_written); @@ -164,7 +164,7 @@ static gnutls_x509_crt_t get_ephemeral_cert(gnutls_x509_privkey_t privkey, const #define gtx(fn, ...) \ if ((err = fn ( __VA_ARGS__ )) != GNUTLS_E_SUCCESS) { \ - kr_log_error(LOG_GRP_TLS, #fn "() failed: %d (%s)\n", \ + kr_log_error(TLS, #fn "() failed: %d (%s)\n", \ err, gnutls_strerror_name(err)); \ goto bad; } @@ -199,20 +199,20 @@ struct tls_credentials * tls_get_ephemeral_credentials(struct engine *engine) creds = calloc(1, sizeof(*creds)); if (!creds) { - kr_log_error(LOG_GRP_TLS, "failed to allocate memory for ephemeral credentials\n"); + kr_log_error(TLS, "failed to allocate memory for ephemeral credentials\n"); return NULL; } if ((err = gnutls_certificate_allocate_credentials(&(creds->credentials))) < 0) { - kr_log_error(LOG_GRP_TLS, "failed to allocate memory for ephemeral credentials\n"); + kr_log_error(TLS, "failed to allocate memory for ephemeral credentials\n"); goto failure; } creds->valid_until = now + EPHEMERAL_CERT_EXPIRATION_SECONDS; creds->ephemeral_servicename = strdup(engine_get_hostname(engine)); if (creds->ephemeral_servicename == NULL) { - kr_log_error(LOG_GRP_TLS, "could not get server's hostname, using '" INVALID_HOSTNAME "' instead\n"); + kr_log_error(TLS, "could not get server's hostname, using '" INVALID_HOSTNAME "' instead\n"); if ((creds->ephemeral_servicename = strdup(INVALID_HOSTNAME)) == NULL) { - kr_log_error(LOG_GRP_TLS, "failed to allocate memory for ephemeral credentials\n"); + kr_log_error(TLS, "failed to allocate memory for ephemeral credentials\n"); goto failure; } } @@ -223,7 +223,7 @@ struct tls_credentials * tls_get_ephemeral_credentials(struct engine *engine) goto failure; } if ((err = gnutls_certificate_set_x509_key(creds->credentials, &cert, 1, privkey)) < 0) { - kr_log_error(LOG_GRP_TLS, "failed to set up ephemeral credentials\n"); + kr_log_error(TLS, "failed to set up ephemeral credentials\n"); goto failure; } gnutls_x509_privkey_deinit(privkey); diff --git a/daemon/tls_session_ticket-srv.c b/daemon/tls_session_ticket-srv.c index cf8f6eb27..49b36f67f 100644 --- a/daemon/tls_session_ticket-srv.c +++ b/daemon/tls_session_ticket-srv.c @@ -80,7 +80,7 @@ static tst_ctx_t * tst_key_create(const char *secret, size_t secret_len, uv_loop return NULL; #if !TLS_SESSION_RESUMPTION_SYNC if (secret_len) { - kr_log_error(LOG_GRP_TLS, "session ticket: secrets were not enabled at compile-time (your GnuTLS version is not supported)\n"); + kr_log_error(TLS, "session ticket: secrets were not enabled at compile-time (your GnuTLS version is not supported)\n"); return NULL; /* ENOTSUP */ } #endif @@ -166,7 +166,7 @@ static void tst_key_check(uv_timer_t *timer, bool force_update) /* Compute the current epoch. */ struct timeval now; if (gettimeofday(&now, NULL)) { - kr_log_error(LOG_GRP_TLS, "session ticket: gettimeofday failed, %s\n", + kr_log_error(TLS, "session ticket: gettimeofday failed, %s\n", strerror(errno)); return; } @@ -177,7 +177,7 @@ static void tst_key_check(uv_timer_t *timer, bool force_update) * for gnutls_session_ticket_enable_server() doesn't say. */ int err = tst_key_update(stst, epoch, force_update); if (err) { - kr_log_error(LOG_GRP_TLS, "session ticket: failed rotation, %s\n", + kr_log_error(TLS, "session ticket: failed rotation, %s\n", kr_strerror(err)); if (kr_fails_assert(err != kr_error(EINVAL))) return; @@ -195,7 +195,7 @@ static void tst_key_check(uv_timer_t *timer, bool force_update) (uint64_t)epoch, remain_ms); err = uv_timer_start(timer, &tst_timer_callback, remain_ms, 0); if (kr_fails_assert(err == 0)) { - kr_log_error(LOG_GRP_TLS, "session ticket: failed to schedule, %s\n", + kr_log_error(TLS, "session ticket: failed to schedule, %s\n", uv_strerror(err)); return; } @@ -213,7 +213,7 @@ void tls_session_ticket_enable(struct tls_session_ticket_ctx *ctx, gnutls_sessio }; int err = gnutls_session_ticket_enable_server(session, &gd); if (err) { - kr_log_error(LOG_GRP_TLS, "failed to enable session tickets: %s (%d)\n", + kr_log_error(TLS, "failed to enable session tickets: %s (%d)\n", gnutls_strerror_name(err), err); /* but continue without tickets */ } diff --git a/daemon/udp_queue.c b/daemon/udp_queue.c index d59877a51..04225bcfb 100644 --- a/daemon/udp_queue.c +++ b/daemon/udp_queue.c @@ -101,7 +101,7 @@ int udp_queue_init_global(uv_loop_t *loop) void udp_queue_push(int fd, struct kr_request *req, struct qr_task *task) { if (fd < 0) { - kr_log_error(LOG_GRP_SYSTEM, "ERROR: called udp_queue_push(fd = %d, ...)\n", fd); + kr_log_error(SYSTEM, "ERROR: called udp_queue_push(fd = %d, ...)\n", fd); abort(); } worker_task_ref(task); diff --git a/daemon/worker.c b/daemon/worker.c index cfeee9e2a..4647a8b79 100644 --- a/daemon/worker.c +++ b/daemon/worker.c @@ -51,7 +51,7 @@ #define MAX_PIPELINED 100 #endif -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_WORKER, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, WORKER, __VA_ARGS__) /** Client request state. */ struct request_ctx @@ -1276,7 +1276,7 @@ static void xdp_tx_waker(uv_idle_t *handle) { int ret = knot_xdp_send_finish(handle->data); if (ret != KNOT_EAGAIN && ret != KNOT_EOK) - kr_log_error(LOG_GRP_XDP, "check: ret = %d, %s\n", ret, knot_strerror(ret)); + kr_log_error(XDP, "check: ret = %d, %s\n", ret, knot_strerror(ret)); /* Apparently some drivers need many explicit wake-up calls * even if we push no additional packets (in case they accumulated a lot) */ if (ret != KNOT_EAGAIN) diff --git a/daemon/zimport.c b/daemon/zimport.c index 0f352fd26..6c8b410af 100644 --- a/daemon/zimport.c +++ b/daemon/zimport.c @@ -47,7 +47,7 @@ #include "lib/generic/map.h" #include "lib/generic/array.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_ZIMPORT, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, ZIMPORT, __VA_ARGS__) /* Pause between parse and import stages, milliseconds. * See comment in zi_zone_import() */ @@ -465,14 +465,14 @@ static void zi_zone_process(uv_timer_t* handle) KR_DNAME_GET_STR(zone_name_str, z_import->origin); if (strcmp(".", zone_name_str) != 0) { - kr_log_error(LOG_GRP_ZIMPORT, "unexpected zone name `%s` (root zone expected), fail\n", + kr_log_error(ZIMPORT, "unexpected zone name `%s` (root zone expected), fail\n", zone_name_str); failed = 1; goto finish; } if (z_import->rrset_sorted.len <= 0) { - kr_log_error(LOG_GRP_ZIMPORT, "zone `%s` is empty\n", zone_name_str); + kr_log_error(ZIMPORT, "zone `%s` is empty\n", zone_name_str); goto finish; } @@ -490,7 +490,7 @@ static void zi_zone_process(uv_timer_t* handle) knot_rrset_t *rr_key = map_get(&z_import->rrset_indexed, key); if (!rr_key) { /* DNSKEY MUST be here. If not found - fail. */ - kr_log_error(LOG_GRP_ZIMPORT, "DNSKEY not found for `%s`, fail\n", zone_name_str); + kr_log_error(ZIMPORT, "DNSKEY not found for `%s`, fail\n", zone_name_str); failed = 1; goto finish; } @@ -499,7 +499,7 @@ static void zi_zone_process(uv_timer_t* handle) map_t *trust_anchors = &z_import->worker->engine->resolver.trust_anchors; knot_rrset_t *rr_ta = kr_ta_get(trust_anchors, z_import->origin); if (!rr_ta) { - kr_log_error(LOG_GRP_ZIMPORT, "error: TA for zone `%s` vanished, fail", zone_name_str); + kr_log_error(ZIMPORT, "error: TA for zone `%s` vanished, fail", zone_name_str); failed = 1; goto finish; } @@ -519,7 +519,7 @@ static void zi_zone_process(uv_timer_t* handle) int res = zi_rrset_import(z_import, rr_key); if (res != 0) { - kr_log_error(LOG_GRP_ZIMPORT, "import failed: qname: '%s' type: '%s'\n", + kr_log_error(ZIMPORT, "import failed: qname: '%s' type: '%s'\n", kname_str, ktype_str); failed = 1; goto finish; @@ -596,7 +596,7 @@ finish: if (failed != 0) { if (ns_imported == 0 && other_imported == 0) { import_state = -1; - kr_log_error(LOG_GRP_ZIMPORT, "import failed; zone `%s` \n", zone_name_str); + kr_log_error(ZIMPORT, "import failed; zone `%s` \n", zone_name_str); } else { import_state = 1; } @@ -615,13 +615,13 @@ static int zi_record_store(zs_scanner_t *s) { if (s->r_data_length > UINT16_MAX) { /* Due to knot_rrset_add_rdata(..., const uint16_t size, ...); */ - kr_log_error(LOG_GRP_ZSCANNER, "line %"PRIu64": rdata is too long\n", + kr_log_error(ZSCANNER, "line %"PRIu64": rdata is too long\n", s->line_counter); return -1; } if (knot_dname_size(s->r_owner) != strlen((const char *)(s->r_owner)) + 1) { - kr_log_error(LOG_GRP_ZSCANNER, "line %"PRIu64 + kr_log_error(ZSCANNER, "line %"PRIu64 ": owner name contains zero byte, skip\n", s->line_counter); return 0; @@ -632,14 +632,14 @@ static int zi_record_store(zs_scanner_t *s) knot_rrset_t *new_rr = knot_rrset_new(s->r_owner, s->r_type, s->r_class, s->r_ttl, &z_import->pool); if (!new_rr) { - kr_log_error(LOG_GRP_ZSCANNER, "line %"PRIu64": error creating rrset\n", + kr_log_error(ZSCANNER, "line %"PRIu64": error creating rrset\n", s->line_counter); return -1; } int res = knot_rrset_add_rdata(new_rr, s->r_data, s->r_data_length, &z_import->pool); if (res != KNOT_EOK) { - kr_log_error(LOG_GRP_ZSCANNER, "line %"PRIu64": error adding rdata to rrset\n", + kr_log_error(ZSCANNER, "line %"PRIu64": error adding rdata to rrset\n", s->line_counter); return -1; } @@ -653,7 +653,7 @@ static int zi_record_store(zs_scanner_t *s) res = kr_rrkey(key, new_rr->rclass, new_rr->owner, new_rr->type, additional_key_field); if (res <= 0) { - kr_log_error(LOG_GRP_ZSCANNER, "line %"PRIu64": error constructing rrkey\n", + kr_log_error(ZSCANNER, "line %"PRIu64": error constructing rrkey\n", s->line_counter); return -1; } @@ -666,7 +666,7 @@ static int zi_record_store(zs_scanner_t *s) res = map_set(&z_import->rrset_indexed, key, new_rr); } if (res != 0) { - kr_log_error(LOG_GRP_ZSCANNER, "line %"PRIu64": error saving parsed rrset\n", + kr_log_error(ZSCANNER, "line %"PRIu64": error saving parsed rrset\n", s->line_counter); return -1; } @@ -692,29 +692,29 @@ static int zi_state_parsing(zs_scanner_t *s) } break; case ZS_STATE_ERROR: - kr_log_error(LOG_GRP_ZSCANNER, "line: %"PRIu64 + kr_log_error(ZSCANNER, "line: %"PRIu64 ": parse error; code: %i ('%s')\n", s->line_counter, s->error.code, zs_strerror(s->error.code)); return -1; case ZS_STATE_INCLUDE: - kr_log_error(LOG_GRP_ZSCANNER, "line: %"PRIu64 + kr_log_error(ZSCANNER, "line: %"PRIu64 ": INCLUDE is not supported\n", s->line_counter); return -1; case ZS_STATE_EOF: case ZS_STATE_STOP: if (empty) { - kr_log_error(LOG_GRP_ZIMPORT, "empty zone file\n"); + kr_log_error(ZIMPORT, "empty zone file\n"); return -1; } if (!((zone_import_ctx_t *) s->process.data)->origin) { - kr_log_error(LOG_GRP_ZIMPORT, "zone file doesn't contain SOA record\n"); + kr_log_error(ZIMPORT, "zone file doesn't contain SOA record\n"); return -1; } return (s->error.counter == 0) ? 0 : -1; default: - kr_log_error(LOG_GRP_ZSCANNER, "line: %"PRIu64 + kr_log_error(ZSCANNER, "line: %"PRIu64 ": unexpected parse state: %i\n", s->line_counter, s->state); return -1; @@ -733,7 +733,7 @@ int zi_zone_import(struct zone_import_ctx *z_import, zs_scanner_t *s = malloc(sizeof(zs_scanner_t)); if (s == NULL) { - kr_log_error(LOG_GRP_ZSCANNER, "error creating instance of zone scanner (malloc() fails)\n"); + kr_log_error(ZSCANNER, "error creating instance of zone scanner (malloc() fails)\n"); return -1; } @@ -741,7 +741,7 @@ int zi_zone_import(struct zone_import_ctx *z_import, * so don't print error code as it meaningless. */ int res = zs_init(s, origin, rclass, ttl); if (res != 0) { - kr_log_error(LOG_GRP_ZSCANNER, "error initializing zone scanner instance, error: %i (%s)\n", + kr_log_error(ZSCANNER, "error initializing zone scanner instance, error: %i (%s)\n", s->error.code, zs_strerror(s->error.code)); free(s); return -1; @@ -749,7 +749,7 @@ int zi_zone_import(struct zone_import_ctx *z_import, res = zs_set_input_file(s, zone_file); if (res != 0) { - kr_log_error(LOG_GRP_ZSCANNER, "error opening zone file `%s`, error: %i (%s)\n", + kr_log_error(ZSCANNER, "error opening zone file `%s`, error: %i (%s)\n", zone_file, s->error.code, zs_strerror(s->error.code)); zs_deinit(s); free(s); @@ -760,7 +760,7 @@ int zi_zone_import(struct zone_import_ctx *z_import, * Parsing as well error processing will be performed in zi_state_parsing(). * Store pointer to zone import context for further use. */ if (zs_set_processing(s, NULL, NULL, (void *)z_import) != 0) { - kr_log_error(LOG_GRP_ZSCANNER, "zs_set_processing() failed for zone file `%s`, " + kr_log_error(ZSCANNER, "zs_set_processing() failed for zone file `%s`, " "error: %i (%s)\n", zone_file, s->error.code, zs_strerror(s->error.code)); zs_deinit(s); @@ -784,7 +784,7 @@ int zi_zone_import(struct zone_import_ctx *z_import, /* For now - fail. * TODO - query DS and continue after answer had been obtained. */ KR_DNAME_GET_STR(zone_name_str, z_import->origin); - kr_log_error(LOG_GRP_ZIMPORT, "no TA found for `%s`, fail\n", zone_name_str); + kr_log_error(ZIMPORT, "no TA found for `%s`, fail\n", zone_name_str); ret = 1; } elapsed = kr_now() - z_import->start_timestamp; @@ -795,7 +795,7 @@ int zi_zone_import(struct zone_import_ctx *z_import, free(s); if (ret != 0) { - kr_log_error(LOG_GRP_ZSCANNER, "error parsing zone file `%s`\n", zone_file); + kr_log_error(ZSCANNER, "error parsing zone file `%s`\n", zone_file); z_import->started = false; return ret; } diff --git a/lib/cache/api.c b/lib/cache/api.c index 583c61211..34c99f57e 100644 --- a/lib/cache/api.c +++ b/lib/cache/api.c @@ -81,7 +81,7 @@ static int assert_right_version(struct kr_cache *cache) * Recreate cache and write version key. */ ret = cache_op(cache, count); if (ret != 0) { /* Log for non-empty cache to limit noise on fresh start. */ - kr_log_info(LOG_GRP_CACHE, "incompatible cache database detected, purging\n"); + kr_log_info(CACHE, "incompatible cache database detected, purging\n"); if (oldret) { kr_log_verbose("[cache] reading version returned: %d\n", oldret); } else if (val.len != sizeof(CACHE_VERSION)) { @@ -142,7 +142,7 @@ int kr_cache_open(struct kr_cache *cache, const struct kr_cdb_api *api, struct k if (ret == 0 && opts->maxsize) { size_t maxsize = cache->api->get_maxsize(cache->db); - if (maxsize > opts->maxsize) kr_log_warning(LOG_GRP_CACHE, + if (maxsize > opts->maxsize) kr_log_warning(CACHE, "Warning: real cache size is %zu instead of the requested %zu bytes." " To reduce the size you need to remove the file '%s' by hand.\n", maxsize, opts->maxsize, fpath); @@ -690,7 +690,7 @@ static int stash_rrarray_entry(ranked_rr_array_t *arr, int arr_i, ssize_t written = stash_rrset(cache, qry, rr, rr_sigs, qry->timestamp.tv_sec, entry->rank, nsec_pmap, needs_pkt); if (written < 0) { - kr_log_error(LOG_GRP_CACHE, "[%05u.%02u] stash failed, ret = %d\n", qry->request->uid, + kr_log_error(CACHE, "[%05u.%02u] stash failed, ret = %d\n", qry->request->uid, qry->uid, ret); return (int) written; } diff --git a/lib/cache/cdb_lmdb.c b/lib/cache/cdb_lmdb.c index 3d93ded53..ab36dbe68 100644 --- a/lib/cache/cdb_lmdb.c +++ b/lib/cache/cdb_lmdb.c @@ -87,7 +87,7 @@ static int lmdb_error(int error) case MDB_TXN_FULL: return kr_error(ENOSPC); default: - kr_log_error(LOG_GRP_CACHE, "LMDB error: %s\n", mdb_strerror(error)); + kr_log_error(CACHE, "LMDB error: %s\n", mdb_strerror(error)); return kr_error(error); } } @@ -116,7 +116,7 @@ static int refresh_mapsize(struct lmdb_env *env) env->mapsize = info.me_mapsize; if (env->mapsize != env->st_size) { - kr_log_info(LOG_GRP_CACHE, "suspicious size of cache file '%s'" + kr_log_info(CACHE, "suspicious size of cache file '%s'" ": file size %zu != LMDB map size %zu\n", env->mdb_data_path, (size_t)env->st_size, env->mapsize); } @@ -128,10 +128,10 @@ static void clear_stale_readers(struct lmdb_env *env) int cleared; int ret = mdb_reader_check(env->env, &cleared); if (ret != MDB_SUCCESS) { - kr_log_error(LOG_GRP_CACHE, "failed to clear stale reader locks: " + kr_log_error(CACHE, "failed to clear stale reader locks: " "LMDB error %d %s\n", ret, mdb_strerror(ret)); } else if (cleared != 0) { - kr_log_info(LOG_GRP_CACHE, "cleared %d stale reader locks\n", cleared); + kr_log_info(CACHE, "cleared %d stale reader locks\n", cleared); } } @@ -160,7 +160,7 @@ retry: } if (unlikely(ret == MDB_MAP_RESIZED)) { - kr_log_info(LOG_GRP_CACHE, "detected size increased by another process\n"); + kr_log_info(CACHE, "detected size increased by another process\n"); ret = refresh_mapsize(env); if (ret == 0) goto retry; @@ -384,7 +384,7 @@ static int cdb_open_env(struct lmdb_env *env, const char *path, const size_t map if (ret == EINVAL) { /* POSIX says this can happen when the feature isn't supported by the FS. * We haven't seen this happen on Linux+glibc but it was reported on FreeBSD.*/ - kr_log_info(LOG_GRP_CACHE, "space pre-allocation failed and ignored; " + kr_log_info(CACHE, "space pre-allocation failed and ignored; " "your (file)system probably doesn't support it.\n"); } else if (ret != 0) { mdb_txn_abort(txn); @@ -495,7 +495,7 @@ static int cdb_check_health(kr_cdb_pt db, struct kr_cdb_stats *stats) * contrary to methods based on mdb_env_info(). */ if (st.st_size == env->st_size) return kr_ok(); - kr_log_info(LOG_GRP_CACHE, "detected size change (by another instance?) of file '%s'" + kr_log_info(CACHE, "detected size change (by another instance?) of file '%s'" ": file size %zu -> file size %zu\n", env->mdb_data_path, (size_t)env->st_size, (size_t)st.st_size); env->st_size = st.st_size; // avoid retrying in cycle even if we fail @@ -558,7 +558,7 @@ static int cdb_clear(kr_cdb_pt db, struct kr_cdb_stats *stats) return ret; } } - kr_log_info(LOG_GRP_CACHE, "clearing error, falling back\n"); + kr_log_info(CACHE, "clearing error, falling back\n"); } /* Fallback: we'll remove the database files and reopen. * Other instances can continue to use the removed lmdb, @@ -582,7 +582,7 @@ static int cdb_clear(kr_cdb_pt db, struct kr_cdb_stats *stats) /* Find if we get a lock on lockfile. */ const int lockfile_fd = lockfile_get(lockfile); if (lockfile_fd < 0) { - kr_log_error(LOG_GRP_CACHE, "clearing failed to get ./krcachelock (%s); retry later\n", + kr_log_error(CACHE, "clearing failed to get ./krcachelock (%s); retry later\n", kr_strerror(lockfile_fd)); /* As we're out of space (almost certainly - mdb_drop didn't work), * we will retry on the next failing write operation. */ @@ -608,7 +608,7 @@ static int cdb_clear(kr_cdb_pt db, struct kr_cdb_stats *stats) /* Environment updated, release lockfile. */ int lrerr = lockfile_release(lockfile_fd); if (lrerr) { - kr_log_error(LOG_GRP_CACHE, "failed to release ./krcachelock: %s\n", + kr_log_error(CACHE, "failed to release ./krcachelock: %s\n", kr_strerror(lrerr)); } return ret; diff --git a/lib/cache/entry_list.c b/lib/cache/entry_list.c index 5276d5a5a..38334c092 100644 --- a/lib/cache/entry_list.c +++ b/lib/cache/entry_list.c @@ -185,7 +185,7 @@ static int cache_write_or_clear(struct kr_cache *cache, const knot_db_val_t *key */ const uint64_t now = kr_now(); if (!ignoring_errors_until) { // First error after a success. - kr_log_info(LOG_GRP_CACHE, "LMDB refusing writes (ignored for 5-9s): %s\n", + kr_log_info(CACHE, "LMDB refusing writes (ignored for 5-9s): %s\n", kr_strerror(ret)); ignoring_errors_until = now + 5000 + kr_rand_bytes(2)/16; return kr_error(ret); @@ -198,11 +198,11 @@ recovery: // Try to recover by clearing cache. ret = kr_cache_clear(cache); switch (ret) { default: - kr_log_fatal(LOG_GRP_CACHE, "CRITICAL: clearing cache failed: %s; fatal error, aborting\n", + kr_log_fatal(CACHE, "CRITICAL: clearing cache failed: %s; fatal error, aborting\n", kr_strerror(ret)); abort(); case 0: - kr_log_info(LOG_GRP_CACHE, "stuck cache cleared\n"); + kr_log_info(CACHE, "stuck cache cleared\n"); ignoring_errors_until = 0; case -EAGAIN: // fall-through; krcachelock race -> retry later return kr_error(ENOSPC); diff --git a/lib/cache/entry_rr.c b/lib/cache/entry_rr.c index a16eff5a9..7ab5a56a1 100644 --- a/lib/cache/entry_rr.c +++ b/lib/cache/entry_rr.c @@ -98,7 +98,7 @@ int entry2answer(struct answer *ans, int id, /* Sanity check: we consumed exactly all data. */ int unused_bytes = eh_bound - (uint8_t *)eh->data - data_off - ret; if (kr_fails_assert(unused_bytes == 0)) { - kr_log_error(LOG_GRP_CACHE, "entry2answer ERROR: unused bytes: %d\n", + kr_log_error(CACHE, "entry2answer ERROR: unused bytes: %d\n", unused_bytes); ret = kr_error(EILSEQ); goto fail; /* to be on the safe side */ diff --git a/lib/cache/impl.h b/lib/cache/impl.h index 54815fe2d..e837d16ea 100644 --- a/lib/cache/impl.h +++ b/lib/cache/impl.h @@ -409,7 +409,7 @@ int nsec3_src_synth(struct key *k, struct answer *ans, const knot_dname_t *clenc -#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), LOG_GRP_CACHE, ## __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), CACHE, ## __VA_ARGS__) /** Shorthand for operations on cache backend */ #define cache_op(cache, op, ...) (cache)->api->op((cache)->db, &(cache)->stats, ## __VA_ARGS__) diff --git a/lib/dnssec.c b/lib/dnssec.c index 138e2f16c..e11e1b0d3 100644 --- a/lib/dnssec.c +++ b/lib/dnssec.c @@ -255,7 +255,7 @@ static int kr_rrset_validate_with_key(kr_rrset_validation_ctx_t *vctx, auto_free char *name_str = kr_dname_text(covered->owner), *type_str = kr_rrtype_text(covered->type); - QRVERBOSE(NULL, LOG_GRP_VALIDATOR, + QRVERBOSE(NULL, VALIDATOR, "trimming TTL of %s %s: %d -> %d\n", name_str, type_str, (int)covered->ttl, (int)ttl_max); diff --git a/lib/dnssec/ta.c b/lib/dnssec/ta.c index 27591d37c..4dc836c02 100644 --- a/lib/dnssec/ta.c +++ b/lib/dnssec/ta.c @@ -58,14 +58,14 @@ static int dnskey2ds(dnssec_binary_t *dst, const knot_dname_t *owner, const uint const bool flags_ok = kr_dnssec_key_zsk(rdata) && !kr_dnssec_key_revoked(rdata); if (!flags_ok) { auto_free char *owner_str = kr_dname_text(owner); - kr_log_error(LOG_GRP_TA, "refusing to trust %s DNSKEY because of flags %d\n", + kr_log_error(TA, "refusing to trust %s DNSKEY because of flags %d\n", owner_str, dnssec_key_get_flags(key)); ret = kr_error(EILSEQ); goto cleanup; } else if (!kr_dnssec_key_ksk(rdata)) { auto_free char *owner_str = kr_dname_text(owner); int flags = dnssec_key_get_flags(key); - kr_log_warning(LOG_GRP_TA, "warning: %s DNSKEY is missing the SEP bit; " + kr_log_warning(TA, "warning: %s DNSKEY is missing the SEP bit; " "flags %d instead of %d\n", owner_str, flags, flags + 1/*a little ugly*/); } diff --git a/lib/layer.h b/lib/layer.h index 3ac844e01..66644f60c 100644 --- a/lib/layer.h +++ b/lib/layer.h @@ -16,7 +16,7 @@ #define QRVERBOSE(_query, grp, ...) do { \ const struct kr_query *_qry = (_query); \ if (VERBOSE_STATUS || kr_log_qtrace_enabled(_qry)) { \ - kr_log_q1(_query, grp, grp ## _TAG, __VA_ARGS__); \ + kr_log_q(_query, grp, ## __VA_ARGS__); \ } \ } while (false) diff --git a/lib/layer/iterate.c b/lib/layer/iterate.c index 91a4da445..2aa6578d1 100644 --- a/lib/layer/iterate.c +++ b/lib/layer/iterate.c @@ -32,8 +32,8 @@ #include "lib/module.h" #include "lib/dnssec/ta.h" -#define VERBOSE_MSG(...) QRVERBOSE(req->current_query, LOG_GRP_ITERATOR, __VA_ARGS__) -#define QVERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_ITERATOR, __VA_ARGS__) +#define VERBOSE_MSG(...) QRVERBOSE(req->current_query, ITERATOR, __VA_ARGS__) +#define QVERBOSE_MSG(qry, ...) QRVERBOSE(qry, ITERATOR, __VA_ARGS__) /* Iterator often walks through packet section, this is an abstraction. */ typedef int (*rr_callback_t)(const knot_rrset_t *, unsigned, struct kr_request *); diff --git a/lib/layer/validate.c b/lib/layer/validate.c index 08f96e814..5c22d5b9a 100644 --- a/lib/layer/validate.c +++ b/lib/layer/validate.c @@ -25,7 +25,7 @@ #include "lib/module.h" #include "lib/selection.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_VALIDATOR, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, VALIDATOR, __VA_ARGS__) #define MAX_REVALIDATION_CNT 2 @@ -583,7 +583,7 @@ static const knot_dname_t *find_first_signer(ranked_rr_array_t *arr, struct kr_q return signame; } else { /* otherwise it's some nonsense, so we skip it */ - kr_log_q(qry, LOG_GRP_VALIDATOR, "protocol violation: " + kr_log_q(qry, VALIDATOR, "protocol violation: " "out-of-bailwick RRSIG signer, skipping\n"); } } diff --git a/lib/log.c b/lib/log.c index 694447dae..a10424419 100644 --- a/lib/log.c +++ b/lib/log.c @@ -104,7 +104,7 @@ void kr_log_fmt(log_groups_t group, log_level_t level, const char *file, static void kres_gnutls_log(int level, const char *message) { - kr_log_debug(LOG_GRP_GNUTLS, "(%d) %s", level, message); + kr_log_debug(GNUTLS, "(%d) %s", level, message); } char *kr_log_level2name(log_level_t level) diff --git a/lib/log.h b/lib/log.h index eaa88ffff..e1ede8160 100644 --- a/lib/log.h +++ b/lib/log.h @@ -117,20 +117,27 @@ void kr_log_init(log_level_t level, log_target_t target); #define SD_JOURNAL_METADATA "CODE_FILE=" __FILE__, "CODE_LINE=" TO_STR(__LINE__), "" #define kr_log_debug(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_DEBUG, SD_JOURNAL_METADATA, "[" grp ## _TAG "] " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_DEBUG, SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] " fmt, ## __VA_ARGS__) #define kr_log_info(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_INFO, SD_JOURNAL_METADATA, "[" grp ## _TAG "] " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_INFO, SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] " fmt, ## __VA_ARGS__) #define kr_log_notice(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_NOTICE, SD_JOURNAL_METADATA, "[" grp ## _TAG "] " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_NOTICE, SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] " fmt, ## __VA_ARGS__) #define kr_log_warning(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_WARNING, SD_JOURNAL_METADATA, "[" grp ## _TAG "] " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_WARNING, SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] " fmt, ## __VA_ARGS__) #define kr_log_error(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_ERR, SD_JOURNAL_METADATA, "[" grp ## _TAG "] " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_ERR, SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] " fmt, ## __VA_ARGS__) #define kr_log_fatal(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_CRIT, SD_JOURNAL_METADATA, "[" grp ## _TAG "] " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_CRIT, SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] " fmt, ## __VA_ARGS__) #define kr_log_deprecate(grp, fmt, ...) \ - kr_log_fmt(grp, LOG_WARNING,SD_JOURNAL_METADATA, "[" grp ## _TAG "] deprecation WARNING: " fmt, ## __VA_ARGS__) + kr_log_fmt(LOG_GRP_ ## grp, LOG_WARNING,SD_JOURNAL_METADATA, \ + "[" LOG_GRP_ ## grp ## _TAG "] deprecation WARNING: " fmt, ## __VA_ARGS__) #define KR_LOG_LEVEL_IS(exp) ((kr_log_level >= (exp)) ? true : false) @@ -167,7 +174,7 @@ struct kr_query; * @param fmt message format */ #define kr_log_req(req, qry_id, indent, grp, fmt, ...) \ - kr_log_req1(req, qry_id, indent, grp, grp ## _TAG, fmt, ## __VA_ARGS__) + kr_log_req1(req, qry_id, indent, LOG_GRP_ ## grp, LOG_GRP_ ## grp ## _TAG, fmt, ## __VA_ARGS__) KR_EXPORT KR_PRINTF(6) void kr_log_req1(const struct kr_request * const req, uint32_t qry_uid, const unsigned int indent, log_groups_t group, const char *tag, const char *fmt, ...); @@ -179,7 +186,7 @@ void kr_log_req1(const struct kr_request * const req, uint32_t qry_uid, * @param source message source * @param fmt message format */ -#define kr_log_q(qry, grp, fmt, ...) kr_log_q1(qry, grp, grp ## _TAG, fmt, ## __VA_ARGS__) +#define kr_log_q(qry, grp, fmt, ...) kr_log_q1(qry, LOG_GRP_ ## grp, LOG_GRP_ ## grp ## _TAG, fmt, ## __VA_ARGS__) KR_EXPORT KR_PRINTF(4) void kr_log_q1(const struct kr_query *qry, log_groups_t group, const char *tag, const char *fmt, ...); diff --git a/lib/module.c b/lib/module.c index e33091e47..e38ce6184 100644 --- a/lib/module.c +++ b/lib/module.c @@ -87,7 +87,7 @@ static int load_sym_c(struct kr_module *module, uint32_t api_required) || load_symbol(module->lib, m_prefix, "props")) { /* In case someone re-compiled against new kresd * but haven't actually changed the symbols. */ - kr_log_error(LOG_GRP_SYSTEM, "module %s requires upgrade. Please refer to " + kr_log_error(SYSTEM, "module %s requires upgrade. Please refer to " "https://knot-resolver.readthedocs.io/en/stable/upgrading.html", module->name); return kr_error(ENOTSUP); diff --git a/lib/resolve.c b/lib/resolve.c index 3c3b61542..8ef862cd0 100644 --- a/lib/resolve.c +++ b/lib/resolve.c @@ -26,7 +26,7 @@ #define KNOT_EDNS_OPTION_COOKIE 10 #endif /* ENABLE_COOKIES */ -#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), LOG_GRP_RESOLVER, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), RESOLVER, __VA_ARGS__) bool kr_rank_check(uint8_t rank) { @@ -458,7 +458,7 @@ static void answer_fail(struct kr_request *request) { /* Note: OPT in SERVFAIL response is still useful for cookies/additional info. */ if (VERBOSE_STATUS || kr_log_rtrace_enabled(request)) - kr_log_req(request, 0, 0, LOG_GRP_RESOLVER, + kr_log_req(request, 0, 0, RESOLVER, "request failed, answering with empty SERVFAIL\n"); knot_pkt_t *answer = request->answer; knot_rrset_t *opt_rr = answer->opt_rr; /* it gets NULLed below */ @@ -834,7 +834,7 @@ int kr_resolve_consume(struct kr_request *request, struct kr_transport **transpo if (request->state & KR_STATE_FAIL) { if (++request->count_fail_row > KR_CONSUME_FAIL_ROW_LIMIT) { if (VERBOSE_STATUS || kr_log_rtrace_enabled(request)) { - kr_log_req(request, 0, 2, LOG_GRP_RESOLVER, + kr_log_req(request, 0, 2, RESOLVER, "=> too many failures in a row, " "bail out (mitigation for NXNSAttack " "CVE-2020-12667)\n"); diff --git a/lib/rplan.c b/lib/rplan.c index 7eac9fa0b..ad048d862 100644 --- a/lib/rplan.c +++ b/lib/rplan.c @@ -11,7 +11,7 @@ #include "lib/defines.h" #include "lib/layer.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_PLAN, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, PLAN, __VA_ARGS__) inline static unsigned char chars_or(const unsigned char a, const unsigned char b) { diff --git a/lib/selection.c b/lib/selection.c index dc2382d1a..dc72c474d 100644 --- a/lib/selection.c +++ b/lib/selection.c @@ -14,7 +14,7 @@ #include "lib/utils.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), LOG_GRP_SELECTION, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), SELECTION, __VA_ARGS__) #define DEFAULT_TIMEOUT 400 #define MAX_TIMEOUT 10000 diff --git a/lib/selection_forward.c b/lib/selection_forward.c index f2f233d1a..f60117d29 100644 --- a/lib/selection_forward.c +++ b/lib/selection_forward.c @@ -5,7 +5,7 @@ #include "lib/selection_forward.h" #include "lib/resolve.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), LOG_GRP_SELECTION, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), SELECTION, __VA_ARGS__) #define FORWARDING_TIMEOUT 2000 diff --git a/lib/selection_iter.c b/lib/selection_iter.c index 0a5bbda17..50b170724 100644 --- a/lib/selection_iter.c +++ b/lib/selection_iter.c @@ -10,7 +10,7 @@ #include "lib/zonecut.h" #include "lib/resolve.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), LOG_GRP_SELECTION, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE((qry), SELECTION, __VA_ARGS__) /// To be held per query and locally. Allocations are in the kr_request's mempool. struct iter_local_state { diff --git a/lib/utils.c b/lib/utils.c index 016247c56..3b55f866c 100644 --- a/lib/utils.c +++ b/lib/utils.c @@ -39,9 +39,9 @@ void kr_fail(bool is_fatal, const char *expr, const char *func, const char *file { const int errno_orig = errno; if (is_fatal) - kr_log_fatal(LOG_GRP_SYSTEM, "requirement \"%s\" failed in %s@%s:%d\n", expr, func, file, line); + kr_log_fatal(SYSTEM, "requirement \"%s\" failed in %s@%s:%d\n", expr, func, file, line); else - kr_log_error(LOG_GRP_SYSTEM, "assertion \"%s\" failed in %s@%s:%d\n", expr, func, file, line); + kr_log_error(SYSTEM, "assertion \"%s\" failed in %s@%s:%d\n", expr, func, file, line); if (is_fatal || (kr_dbg_assertion_abort && !kr_dbg_assertion_fork)) abort(); @@ -768,7 +768,7 @@ int kr_ranked_rrarray_finalize(ranked_rr_array_t *array, uint32_t qry_uid, knot_ if (knot_rdata_cmp(ra->at[i], ra->at[i + 1]) == 0) { ra->at[i] = NULL; ++dup_count; - QRVERBOSE(NULL, LOG_GRP_ITERATOR, "deleted duplicate RR\n"); + QRVERBOSE(NULL, ITERATOR, "deleted duplicate RR\n"); } } /* Prepare rdataset, except rdata contents. */ @@ -1108,7 +1108,7 @@ static void rnd_noerror(void *data, uint size) { int ret = gnutls_rnd(GNUTLS_RND_NONCE, data, size); if (ret) { - kr_log_error(LOG_GRP_TLS, "gnutls_rnd(): %s\n", gnutls_strerror(ret)); + kr_log_error(TLS, "gnutls_rnd(): %s\n", gnutls_strerror(ret)); abort(); } } diff --git a/lib/utils.h b/lib/utils.h index ba628b417..b472935e2 100644 --- a/lib/utils.h +++ b/lib/utils.h @@ -201,7 +201,7 @@ static inline uint64_t kr_rand_bytes(unsigned int size) { uint64_t result; if (size <= 0 || size > sizeof(result)) { - kr_log_error(LOG_GRP_SYSTEM, "kr_rand_bytes(): EINVAL\n"); + kr_log_error(SYSTEM, "kr_rand_bytes(): EINVAL\n"); abort(); } uint8_t data[sizeof(result)]; diff --git a/lib/zonecut.c b/lib/zonecut.c index b0d5aeb5b..5ab4a461e 100644 --- a/lib/zonecut.c +++ b/lib/zonecut.c @@ -15,7 +15,7 @@ #include #include -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_ZCUT, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, ZCUT, __VA_ARGS__) /** Information for one NS name + address type. */ typedef enum { diff --git a/modules/bogus_log/bogus_log.c b/modules/bogus_log/bogus_log.c index 3a4e6fc68..489879993 100644 --- a/modules/bogus_log/bogus_log.c +++ b/modules/bogus_log/bogus_log.c @@ -38,7 +38,7 @@ static int consume(kr_layer_t *ctx, knot_pkt_t *pkt) auto_free char *qname_text = kr_dname_text(knot_pkt_qname(pkt)); auto_free char *qtype_text = kr_rrtype_text(knot_pkt_qtype(pkt)); - kr_log_error(LOG_GRP_DNSSEC, "DNSSEC validation failure %s %s\n", qname_text, qtype_text); + kr_log_error(DNSSEC, "DNSSEC validation failure %s %s\n", qname_text, qtype_text); /* log of most frequent bogus queries */ uint16_t type = knot_pkt_qtype(pkt); diff --git a/modules/cookies/cookiemonster.c b/modules/cookies/cookiemonster.c index eca6df8fb..f118b7e75 100644 --- a/modules/cookies/cookiemonster.c +++ b/modules/cookies/cookiemonster.c @@ -20,7 +20,7 @@ #include "lib/rplan.h" #include "modules/cookies/cookiemonster.h" -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_COOKIES, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, COOKIES, __VA_ARGS__) /** * Obtain address from query/response context if if can be obtained. diff --git a/modules/hints/hints.c b/modules/hints/hints.c index 35cdaf44f..01e9b6d68 100644 --- a/modules/hints/hints.c +++ b/modules/hints/hints.c @@ -25,8 +25,8 @@ #include /* Defaults */ -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_HINT, __VA_ARGS__) -#define ERR_MSG(...) kr_log_error(LOG_GRP_HINT, "[ ]" __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, HINT, __VA_ARGS__) +#define ERR_MSG(...) kr_log_error(HINT, "[ ]" __VA_ARGS__) struct hints_data { struct kr_zonecut hints; diff --git a/modules/stats/stats.c b/modules/stats/stats.c index 75b6a9127..0cb7d32e5 100644 --- a/modules/stats/stats.c +++ b/modules/stats/stats.c @@ -25,7 +25,7 @@ #include "lib/resolve.h" /* Defaults */ -#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, LOG_GRP_STATISTICS, __VA_ARGS__) +#define VERBOSE_MSG(qry, ...) QRVERBOSE(qry, STATISTICS, __VA_ARGS__) #define FREQUENT_PSAMPLE 10 /* Sampling rate, 1 in N */ #ifdef LRU_REP_SIZE #define FREQUENT_COUNT LRU_REP_SIZE /* Size of frequent tables */