]> git.ipfire.org Git - thirdparty/haproxy.git/commit
BUG/MINOR: log: fix global lf_expr node options behavior
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 29 Apr 2024 09:55:27 +0000 (11:55 +0200)
committerAurelien DARRAGON <adarragon@haproxy.com>
Mon, 29 Apr 2024 12:47:37 +0000 (14:47 +0200)
commit98b44e8edb439ef54d021de03efec1e8fd019fd0
tree4bba762bc84315a7210b15f3cda2c0f35c3ed17b
parent9bdea51d7e2e5b2d3a0066190fea5c0a2c0cbb6b
BUG/MINOR: log: fix global lf_expr node options behavior

In 507223d5 ("MINOR: log: global lf_expr node options"), a mistake was
made because it was assumed that only the last occurence of %o
(LOG_FMT_GLOBAL) should be kept as global node options.

However, although not documented, it is possible to have multiple %o
within a single logformat expression to change the global settings on the
fly.

For instance, consider this example:

  log-format "%{+X}o test1=%ms %{-X}o test2=%ms %{+X}o test3=%ms"

Prior to 3f2e8d0ed ("MEDIUM: log: lf_* build helpers now take a ctx
argument"), this would output something like this:

  test1=18B test2=395 test3=18B

This is because global options is properly updated as the lf_expr string
is parsed. But now due to 507223d5 and 3f2e8d0ed, only the last %o
occurence is considered. With the above example, this gives:

  test1=18B test2=18B test3=18B

To restore historical behavior, let's partially revert 507223d5: to
compute global node options, we now start with all options enabled and
then for each configurable node in lf_expr_postcheck(), we keep options
common to the current node and previous nodes using AND masking, this way
we really end up with options common to all nodes.

No backport needed.
src/log.c