From: Aurelien DARRAGON Date: Fri, 23 Jun 2023 13:56:58 +0000 (+0200) Subject: MINOR: log/sink: detect when log maxlen exceeds sink size X-Git-Tag: v2.9-dev5~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ceaa1ddb06a584e0c93d194e7b3653d73eb008ca;p=thirdparty%2Fhaproxy.git MINOR: log/sink: detect when log maxlen exceeds sink size To prevent logs from being silently (and unexpectly droppped) at runtime, we check that the maxlen parameter from the log directives are strictly inferior to the targeted ring size. |global | tune.bufsize 16384 | log tcp@127.0.0.1:514 len 32768 | log myring@127.0.0.1:514 len 32768 |ring myring | # no explicit size On such configs, a diag warning will be reported. This commit depends on: - "MINOR: sink: simplify post_sink_resolve function" - "MINOR: ring: add a function to compute max ring payload" --- diff --git a/src/sink.c b/src/sink.c index 0a5670bf2c..33824633ed 100644 --- a/src/sink.c +++ b/src/sink.c @@ -1299,6 +1299,12 @@ int sink_postresolve_logsrvs(struct list *logsrvs, const char *section, const ch logsrv->conf.file, logsrv->conf.line, logsrv->ring_name); err_code |= ERR_ALERT | ERR_FATAL; } + if (sink && logsrv->maxlen > ring_max_payload(sink->ctx.ring)) { + _e_sink_postresolve_logsrvs(ha_diag_warning, "log server", "uses a max length which exceeds ring capacity ('%s' supports %lu bytes at most).", + section, section_name, + logsrv->conf.file, logsrv->conf.line, + logsrv->ring_name, (unsigned long)ring_max_payload(sink->ctx.ring)); + } logsrv->sink = sink; }