]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: config: verbosely reject peers sections with multiple local peers
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2013 10:12:27 +0000 (11:12 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2013 14:30:54 +0000 (15:30 +0100)
If a peers section contains several instances of the local peer name, only
the first one was considered and the next ones were silently ignored. This
can cause some trouble to debug such a configuration. Now the extra entries
are rejected with an error message indicating where the first occurrence was
found.

src/cfgparse.c

index 87fbcfff3e0386bf08688fe215b790682e18164c..bbf0da2899b799211614b1dfd154b56613043ebd 100644 (file)
@@ -1555,6 +1555,8 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                                curpeers->peers_fe->timeout.connect = 5000;
                                curpeers->peers_fe->accept = peer_accept;
                                curpeers->peers_fe->options2 |= PR_O2_INDEPSTR | PR_O2_SMARTCON | PR_O2_SMARTACC;
+                               curpeers->peers_fe->conf.file = strdup(file);
+                               curpeers->peers_fe->conf.line = linenum;
 
                                bind_conf = bind_conf_alloc(&curpeers->peers_fe->conf.bind, file, linenum, args[2]);
 
@@ -1582,6 +1584,13 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                                        global.maxsock += l->maxconn;
                                }
                        }
+                       else {
+                               Alert("parsing [%s:%d] : '%s %s' : local peer name already referenced at %s:%d.\n",
+                                     file, linenum, args[0], args[1],
+                                     curpeers->peers_fe->conf.file, curpeers->peers_fe->conf.line);
+                               err_code |= ERR_FATAL;
+                               goto out;
+                       }
                }
        } /* neither "peer" nor "peers" */
        else if (*args[0] != 0) {