]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: config: reject conflicts in table names
authorWilly Tarreau <w@1wt.eu>
Tue, 26 May 2015 08:49:46 +0000 (10:49 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 26 May 2015 08:49:46 +0000 (10:49 +0200)
A nasty situation happens when two tables have the same name. Since it
is possible to declare a table in a frontend and another one in a backend,
this situation may happen and result in a random behaviour each time a
table is designated in a "stick" or "track" rule. Let's make sure this
is properly detected and stopped. Such a config will now report :

[ALERT] 145/104933 (31571) : parsing [prx.cfg:36] : stick-table name 't' conflicts with table declared in frontend 't' at prx.cfg:30.
[ALERT] 145/104933 (31571) : Error(s) found in configuration file : prx.cfg
[ALERT] 145/104933 (31571) : Fatal errors found in configuration.

src/cfgparse.c

index c74638063f8086f6d7c021355878a0551e507091..d4fac8cdf9ef7a5e0a592f7c3315fab33f9a8a37 100644 (file)
@@ -3479,6 +3479,15 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
        }
        else if (!strcmp(args[0], "stick-table")) {
                int myidx = 1;
+               struct proxy *other;
+
+               other = find_stktable(curproxy->id);
+               if (other) {
+                       Alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n",
+                             file, linenum, curproxy->id, proxy_type_str(other), other->id, other->conf.file, other->conf.line);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
 
                curproxy->table.id =  curproxy->id;
                curproxy->table.type = (unsigned int)-1;