]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: config: fix stick table duplicate name check
authorPatrick Hemmer <phemmer@haproxy.com>
Mon, 26 Jun 2023 18:14:47 +0000 (14:14 -0400)
committerWilly Tarreau <w@1wt.eu>
Fri, 30 Jun 2023 08:27:16 +0000 (10:27 +0200)
When a stick-table is defined within a peers section, the name is
prefixed with the peers section name. However when checking for
duplicate table names, the check was using the table name without
the prefix, and would thus never match.

Must be backported as far as 2.6.

src/cfgparse.c

index 7409ab42b1d8aef122419a059d97f76937e9bd0a..a8d5f87fb51d83fdd37166d42c4f03ee3009f2be 100644 (file)
@@ -1016,17 +1016,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
-               other = stktable_find_by_name(args[1]);
-               if (other) {
-                       ha_alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n",
-                                file, linenum, args[1],
-                                other->proxy ? proxy_cap_str(other->proxy->cap) : "peers",
-                                other->proxy ? other->id : other->peers.p->id,
-                                other->conf.file, other->conf.line);
-                       err_code |= ERR_ALERT | ERR_FATAL;
-                       goto out;
-               }
-
                /* Build the stick-table name, concatenating the "peers" section name
                 * followed by a '/' character and the table name argument.
                 */
@@ -1057,6 +1046,18 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
+               other = stktable_find_by_name(trash.area);
+               if (other) {
+                       ha_alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n",
+                                file, linenum, args[1],
+                                other->proxy ? proxy_cap_str(other->proxy->cap) : "peers",
+                                other->proxy ? other->id : other->peers.p->id,
+                                other->conf.file, other->conf.line);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+
+
                err_code |= parse_stick_table(file, linenum, args, t, id, id + prefix_len, curpeers);
                if (err_code & ERR_FATAL) {
                        free(t);