tcp: BOOL
quic: BOOL
quic\-port: INT
- quic\-log: BOOL
tcp\-max\-clients: INT
tcp\-inbuf\-max\-size: SIZE
tcp\-outbuf\-max\-size: SIZE
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.
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
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
tcp: BOOL
quic: BOOL
quic-port: INT
- quic-log: BOOL
tcp-max-clients: INT
tcp-inbuf-max-size: SIZE
tcp-outbuf-max-size: SIZE
*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
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:
*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
-/* 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
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. */
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);
}
}
}
// 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);
}
}
}
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);
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;
+}
-/* 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
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. */
/*!
* \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);
* 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);
* \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, ...)
* \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.
*
* \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, ...)
* \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);
{ 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 } },
{ 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 }
};
{ 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 }
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 {
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;
}
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)
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;
}