mirror of
https://gitlab.nic.cz/knot/knot-dns.git
synced 2026-06-09 00:22:42 -04:00
log: replace 'xdp.quic-log' with new 'quic' log module
This commit is contained in:
parent
d1c4b4b926
commit
112682df18
7 changed files with 86 additions and 38 deletions
|
|
@ -630,7 +630,6 @@ xdp:
|
|||
tcp: BOOL
|
||||
quic: BOOL
|
||||
quic\-port: INT
|
||||
quic\-log: BOOL
|
||||
tcp\-max\-clients: INT
|
||||
tcp\-inbuf\-max\-size: SIZE
|
||||
tcp\-outbuf\-max\-size: SIZE
|
||||
|
|
@ -723,13 +722,6 @@ but on different port, configured by this option.
|
|||
Change of this parameter requires restart of the Knot server to take effect.
|
||||
.sp
|
||||
\fIDefault:\fP \fB853\fP
|
||||
.SS quic\-log
|
||||
.sp
|
||||
Triggers extensive logging of all QUIC protocol internals for every connection.
|
||||
.sp
|
||||
Change of this parameter requires restart of the Knot server to take effect.
|
||||
.sp
|
||||
\fIDefault:\fP \fBoff\fP
|
||||
.SS tcp\-max\-clients
|
||||
.sp
|
||||
A maximum number of TCP clients connected in parallel.
|
||||
|
|
@ -872,6 +864,7 @@ log:
|
|||
server: critical | error | warning | notice | info | debug
|
||||
control: critical | error | warning | notice | info | debug
|
||||
zone: critical | error | warning | notice | info | debug
|
||||
quic: critical | error | warning | notice | info | debug
|
||||
any: critical | error | warning | notice | info | debug
|
||||
.ft P
|
||||
.fi
|
||||
|
|
@ -915,9 +908,14 @@ Minimum severity level for messages related to server control to be logged.
|
|||
Minimum severity level for messages related to zones to be logged.
|
||||
.sp
|
||||
\fIDefault:\fP not set
|
||||
.SS quic
|
||||
.sp
|
||||
Minimum severity level for messages related to QUIC to be logged.
|
||||
.sp
|
||||
\fIDefault:\fP not set
|
||||
.SS any
|
||||
.sp
|
||||
Minimum severity level for all message types to be logged.
|
||||
Minimum severity level for all message types, except \fBquic\fP, to be logged.
|
||||
.sp
|
||||
\fIDefault:\fP not set
|
||||
.SH STATS SECTION
|
||||
|
|
|
|||
|
|
@ -684,7 +684,6 @@ Various options related to XDP listening, especially TCP.
|
|||
tcp: BOOL
|
||||
quic: BOOL
|
||||
quic-port: INT
|
||||
quic-log: BOOL
|
||||
tcp-max-clients: INT
|
||||
tcp-inbuf-max-size: SIZE
|
||||
tcp-outbuf-max-size: SIZE
|
||||
|
|
@ -774,17 +773,6 @@ Change of this parameter requires restart of the Knot server to take effect.
|
|||
|
||||
*Default:* ``853``
|
||||
|
||||
.. _xdp_quic-log:
|
||||
|
||||
quic-log
|
||||
--------
|
||||
|
||||
Triggers extensive logging of all QUIC protocol internals for every connection.
|
||||
|
||||
Change of this parameter requires restart of the Knot server to take effect.
|
||||
|
||||
*Default:* ``off``
|
||||
|
||||
.. _xdp_tcp-max-clients:
|
||||
|
||||
tcp-max-clients
|
||||
|
|
@ -947,6 +935,7 @@ will be logged to both standard error output and syslog. The ``info`` and
|
|||
server: critical | error | warning | notice | info | debug
|
||||
control: critical | error | warning | notice | info | debug
|
||||
zone: critical | error | warning | notice | info | debug
|
||||
quic: critical | error | warning | notice | info | debug
|
||||
any: critical | error | warning | notice | info | debug
|
||||
|
||||
.. _log_target:
|
||||
|
|
@ -998,12 +987,21 @@ Minimum severity level for messages related to zones to be logged.
|
|||
|
||||
*Default:* not set
|
||||
|
||||
.. _log_quic:
|
||||
|
||||
quic
|
||||
----
|
||||
|
||||
Minimum severity level for messages related to QUIC to be logged.
|
||||
|
||||
*Default:* not set
|
||||
|
||||
.. _log_any:
|
||||
|
||||
any
|
||||
---
|
||||
|
||||
Minimum severity level for all message types to be logged.
|
||||
Minimum severity level for all message types, except ``quic``, to be logged.
|
||||
|
||||
*Default:* not set
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2021 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
|
||||
/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -48,6 +48,10 @@ typedef struct {
|
|||
size_t file_count; /*!< Open files count. */
|
||||
FILE **file; /*!< Open files. */
|
||||
log_flag_t flags; /*!< Formatting flags. */
|
||||
struct {
|
||||
bool debug; /*!< Indication if any target uses DEBUG. */
|
||||
bool quic_debug; /*!< Indication if any target uses QUIC DEBUG. */
|
||||
} active;
|
||||
} log_t;
|
||||
|
||||
/*! Log singleton. */
|
||||
|
|
@ -123,15 +127,31 @@ static int *src_levels(log_t *log, log_target_t target, log_source_t src)
|
|||
return &log->target[LOG_SOURCE_ANY * target + src];
|
||||
}
|
||||
|
||||
static void mark_level(log_t *log, log_source_t src, int levels)
|
||||
{
|
||||
if (levels & LOG_MASK(LOG_DEBUG)) {
|
||||
if (src == LOG_SOURCE_QUIC) {
|
||||
log->active.quic_debug = true;
|
||||
} else {
|
||||
log->active.debug = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void sink_levels_set(log_t *log, log_target_t target, log_source_t src, int levels)
|
||||
{
|
||||
// Assign levels to the specified source.
|
||||
if (src != LOG_SOURCE_ANY) {
|
||||
*src_levels(log, target, src) = levels;
|
||||
mark_level(log, src, levels);
|
||||
} else {
|
||||
// ANY ~ set levels to all sources.
|
||||
for (int i = 0; i < LOG_SOURCE_ANY; ++i) {
|
||||
if (i == LOG_SOURCE_QUIC) {
|
||||
continue;
|
||||
}
|
||||
*src_levels(log, target, i) = levels;
|
||||
mark_level(log, i, levels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -141,10 +161,15 @@ static void sink_levels_add(log_t *log, log_target_t target, log_source_t src, i
|
|||
// Add levels to the specified source.
|
||||
if (src != LOG_SOURCE_ANY) {
|
||||
*src_levels(log, target, src) |= levels;
|
||||
mark_level(log, src, levels);
|
||||
} else {
|
||||
// ANY ~ add levels to all sources.
|
||||
for (int i = 0; i < LOG_SOURCE_ANY; ++i) {
|
||||
if (i == LOG_SOURCE_QUIC) {
|
||||
continue;
|
||||
}
|
||||
*src_levels(log, target, i) |= levels;
|
||||
mark_level(log, i, levels);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -481,6 +506,11 @@ void log_reconfigure(conf_t *conf)
|
|||
levels = conf_opt(&levels_val);
|
||||
sink_levels_add(log, target, LOG_SOURCE_ZONE, levels);
|
||||
|
||||
// Set QUIC logging.
|
||||
levels_val = conf_id_get(conf, C_LOG, C_QUIC, &id);
|
||||
levels = conf_opt(&levels_val);
|
||||
sink_levels_add(log, target, LOG_SOURCE_QUIC, levels);
|
||||
|
||||
// Set ANY logging.
|
||||
levels_val = conf_id_get(conf, C_LOG, C_ANY, &id);
|
||||
levels = conf_opt(&levels_val);
|
||||
|
|
@ -489,3 +519,13 @@ void log_reconfigure(conf_t *conf)
|
|||
|
||||
sink_publish(log);
|
||||
}
|
||||
|
||||
bool log_enabled_debug(void)
|
||||
{
|
||||
return s_log != NULL && s_log->active.debug;
|
||||
}
|
||||
|
||||
bool log_enabled_quic_debug(void)
|
||||
{
|
||||
return s_log != NULL && s_log->active.quic_debug;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
/* Copyright (C) 2020 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
|
||||
/* Copyright (C) 2023 CZ.NIC, z.s.p.o. <knot-dns@labs.nic.cz>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -49,7 +49,8 @@ typedef enum {
|
|||
LOG_SOURCE_SERVER = 0, /*!< Server module. */
|
||||
LOG_SOURCE_CONTROL = 1, /*!< Server control module. */
|
||||
LOG_SOURCE_ZONE = 2, /*!< Zone manipulation module. */
|
||||
LOG_SOURCE_ANY = 3 /*!< Any module. */
|
||||
LOG_SOURCE_QUIC = 3, /*!< QUIC debug information. */
|
||||
LOG_SOURCE_ANY = 4 /*!< Any module (QUIC not included). */
|
||||
} log_source_t;
|
||||
|
||||
/*! \brief Logging format flags. */
|
||||
|
|
@ -76,8 +77,8 @@ void log_flag_set(log_flag_t flag);
|
|||
/*!
|
||||
* \brief Set log levels for given target.
|
||||
*
|
||||
* \param target Logging target index (LOG_TARGET_SYSLOG...).
|
||||
* \param src Logging source (LOG_SOURCE_SERVER...LOG_SOURCE_ANY).
|
||||
* \param target Logging target index.
|
||||
* \param src Logging source.
|
||||
* \param levels Bitmask of specified log levels.
|
||||
*/
|
||||
void log_levels_set(log_target_t target, log_source_t src, int levels);
|
||||
|
|
@ -88,8 +89,8 @@ void log_levels_set(log_target_t target, log_source_t src, int levels);
|
|||
* New levels are added on top of existing, the resulting levels set is
|
||||
* "old_levels OR new_levels".
|
||||
*
|
||||
* \param target Logging target index (LOG_TARGET_SYSLOG...).
|
||||
* \param src Logging source (LOG_SOURCE_SERVER...LOG_SOURCE_ANY).
|
||||
* \param target Logging target index.
|
||||
* \param src Logging source.
|
||||
* \param levels Bitmask of specified log levels.
|
||||
*/
|
||||
void log_levels_add(log_target_t target, log_source_t src, int levels);
|
||||
|
|
@ -102,7 +103,7 @@ void log_levels_add(log_target_t target, log_source_t src, int levels);
|
|||
* \note LOG_SOURCE_ANY is not a valid value for the src parameter.
|
||||
*
|
||||
* \param priority Message priority.
|
||||
* \param src Message source (LOG_SOURCE_SERVER...LOG_SOURCE_ZONE).
|
||||
* \param src Message source.
|
||||
* \param fmt Content of the logged message.
|
||||
*/
|
||||
void log_fmt(int priority, log_source_t src, const char *fmt, ...)
|
||||
|
|
@ -114,7 +115,7 @@ __attribute__((format(printf, 3, 4)));
|
|||
* \see log_fmt
|
||||
*
|
||||
* \param priority Message priority.
|
||||
* \param src Message source (LOG_SOURCE_SERVER...LOG_SOURCE_ZONE).
|
||||
* \param src Message source.
|
||||
* \param zone Zone name in wire format.
|
||||
* \param param Optional key-value parameter for structured logging.
|
||||
* \param fmt Content of the logged message.
|
||||
|
|
@ -130,7 +131,7 @@ __attribute__((format(printf, 5, 6)));
|
|||
*
|
||||
* \param zone Zone name as an ASCII string.
|
||||
* \param priority Message priority.
|
||||
* \param src Message source (LOG_SOURCE_SERVER...LOG_SOURCE_ZONE).
|
||||
* \param src Message source.
|
||||
* \param fmt Content of the logged message.
|
||||
*/
|
||||
void log_fmt_zone_str(int priority, log_source_t src, const char *zone, const char *fmt, ...)
|
||||
|
|
@ -185,3 +186,13 @@ int log_update_privileges(int uid, int gid);
|
|||
* \brief Setup logging facilities from config.
|
||||
*/
|
||||
void log_reconfigure(conf_t *conf);
|
||||
|
||||
/*!
|
||||
* \brief Check if debug logging is enabled.
|
||||
*/
|
||||
bool log_enabled_debug(void);
|
||||
|
||||
/*!
|
||||
* \brief Check if QUIC debug logging is enabled.
|
||||
*/
|
||||
bool log_enabled_quic_debug(void);
|
||||
|
|
|
|||
|
|
@ -265,7 +265,6 @@ static const yp_item_t desc_xdp[] = {
|
|||
{ C_TCP, YP_TBOOL, YP_VNONE },
|
||||
{ C_QUIC, YP_TBOOL, YP_VNONE },
|
||||
{ C_QUIC_PORT, YP_TINT, YP_VINT = { 1, 65535, 853 } },
|
||||
{ C_QUIC_LOG, YP_TBOOL, YP_VNONE },
|
||||
{ C_TCP_MAX_CLIENTS, YP_TINT, YP_VINT = { 1024, INT32_MAX, 1000000 } },
|
||||
{ C_TCP_INBUF_MAX_SIZE, YP_TINT, YP_VINT = { MEGA(1), SSIZE_MAX, MEGA(100), YP_SSIZE } },
|
||||
{ C_TCP_OUTBUF_MAX_SIZE, YP_TINT, YP_VINT = { MEGA(1), SSIZE_MAX, MEGA(100), YP_SSIZE } },
|
||||
|
|
@ -274,6 +273,8 @@ static const yp_item_t desc_xdp[] = {
|
|||
{ C_TCP_RESEND, YP_TINT, YP_VINT = { 1, INT32_MAX, 5, YP_STIME } },
|
||||
{ C_ROUTE_CHECK, YP_TBOOL, YP_VNONE },
|
||||
{ C_COMMENT, YP_TSTR, YP_VNONE },
|
||||
// Legacy items.
|
||||
{ C_QUIC_LOG, YP_TBOOL, YP_VNONE, YP_FNONE, { legacy_item } },
|
||||
{ NULL }
|
||||
};
|
||||
|
||||
|
|
@ -289,6 +290,7 @@ static const yp_item_t desc_log[] = {
|
|||
{ C_SERVER, YP_TOPT, YP_VOPT = { log_severities, 0 } },
|
||||
{ C_CTL, YP_TOPT, YP_VOPT = { log_severities, 0 } },
|
||||
{ C_ZONE, YP_TOPT, YP_VOPT = { log_severities, 0 } },
|
||||
{ C_QUIC, YP_TOPT, YP_VOPT = { log_severities, 0 } },
|
||||
{ C_ANY, YP_TOPT, YP_VOPT = { log_severities, 0 } },
|
||||
{ C_COMMENT, YP_TSTR, YP_VNONE },
|
||||
{ NULL }
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
static void quic_log_cb(const char *line)
|
||||
{
|
||||
log_debug("QUIC requestor: %s", line);
|
||||
log_fmt(LOG_DEBUG, LOG_SOURCE_QUIC, "QUIC requestor, %s", line);
|
||||
}
|
||||
|
||||
typedef union {
|
||||
|
|
@ -179,8 +179,7 @@ int knot_qreq_connect(struct knot_quic_reply **out,
|
|||
return KNOT_ENOMEM;
|
||||
}
|
||||
|
||||
conf_val_t qlval = conf_get(conf(), C_XDP, C_QUIC_LOG);
|
||||
if (conf_bool(&qlval)) {
|
||||
if (log_enabled_quic_debug()) {
|
||||
table->log_cb = quic_log_cb;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
static void quic_log_cb(const char *line)
|
||||
{
|
||||
log_debug("QUIC: %s", line);
|
||||
log_fmt(LOG_DEBUG, LOG_SOURCE_QUIC, "QUIC, %s", line);
|
||||
}
|
||||
|
||||
static int uq_alloc_reply(knot_quic_reply_t *r)
|
||||
|
|
@ -104,7 +104,7 @@ knot_quic_table_t *quic_make_table(struct server *server)
|
|||
knot_quic_table_t *table =
|
||||
knot_quic_table_new(quic_max_conns, quic_max_inbufs, quic_max_obufs,
|
||||
udp_pl, server->quic_creds);
|
||||
if (table != NULL && conf_get_bool(pconf, C_XDP, C_QUIC_LOG)) {
|
||||
if (table != NULL && log_enabled_quic_debug()) {
|
||||
table->log_cb = quic_log_cb;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue