From e45288c0caae2595ed94b16743e3df72a19ca969 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Tue, 26 May 2015 10:49:46 +0200 Subject: [PATCH] MEDIUM: config: reject conflicts in table names 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/cfgparse.c b/src/cfgparse.c index c74638063f..d4fac8cdf9 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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; -- 2.47.3