BUG/MINOR: logs: fix log-steps extra log origins selection
authorAurelien DARRAGON <adarragon@haproxy.com>
Mon, 21 Jul 2025 13:18:37 +0000 (15:18 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 26 Aug 2025 06:39:05 +0000 (08:39 +0200)
Willy noticed that it was not possible to select extra log origins using
log-steps directive. Extra origins are the one registered using
log_orig_register() such as http-req.

Reason was the error path was always executed during extra log origin
matching for log-steps parser, while it should only be executed if no
match was found.

It should be backported to 3.1.

(cherry picked from commit 563b4fafc26f20ff0e799811f7cea7dca01f2c9e)
Signed-off-by: Amaury Denoyelle <adenoyelle@haproxy.com>
(cherry picked from commit 54dee5bb5da5e23496dbd5ae86807a31a07bd7a6)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>

src/log.c

index c2c605c..b78e5c3 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -6721,7 +6721,7 @@ static int px_parse_log_steps(char **args, int section_type, struct proxy *curpx
 
        while (str[0]) {
                struct eb32_node *cur_step;
-               enum log_orig_id cur_id;
+               enum log_orig_id cur_id = LOG_ORIG_UNSPEC;
 
                cur_sep = strcspn(str, ",");
 
@@ -6746,14 +6746,16 @@ static int px_parse_log_steps(char **args, int section_type, struct proxy *curpx
                                }
                        }
 
-                       memprintf(err,
-                                 "invalid log step name (%.*s). Expected values are: "
-                                 "accept, request, connect, response, close",
-                                 (int)cur_sep, str);
-                        list_for_each_entry(cur, &log_origins, list)
-                               memprintf(err, "%s, %s", *err, cur->name);
+                       if (cur_id == LOG_ORIG_UNSPEC) {
+                               memprintf(err,
+                                         "invalid log step name (%.*s). Expected values are: "
+                                         "accept, request, connect, response, close",
+                                         (int)cur_sep, str);
+                               list_for_each_entry(cur, &log_origins, list)
+                                       memprintf(err, "%s, %s", *err, cur->name);
 
-                       goto end;
+                               goto end;
+                       }
                }
 
                cur_step = malloc(sizeof(*cur_step));