]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log/sink: detect when log maxlen exceeds sink size
authorAurelien DARRAGON <adarragon@haproxy.com>
Fri, 23 Jun 2023 13:56:58 +0000 (15:56 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Wed, 6 Sep 2023 14:06:39 +0000 (16:06 +0200)
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"

src/sink.c

index 0a5670bf2cf1539690311fa5cc8f7b21c8d8efde..33824633ed6d5a3f7bbe7f4a9518261573d42124 100644 (file)
@@ -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;
                }