MEDIUM: config: clarify the conflicting modes detection for backend rules

We don't use findproxy_mode() anymore so we can check the conflicting
modes and report the anomalies accordingly with line numbers and more
explicit details.
This commit is contained in:
Willy Tarreau 2015-05-26 12:04:09 +02:00
parent 8f50b68879
commit afb3992d35
1 changed files with 28 additions and 4 deletions

View File

@ -6942,7 +6942,7 @@ int check_config_validity()
if (curproxy->defbe.name) {
struct proxy *target;
target = findproxy_mode(curproxy->defbe.name, curproxy->mode, PR_CAP_BE);
target = proxy_be_by_name(curproxy->defbe.name);
if (!target) {
Alert("Proxy '%s': unable to find required default_backend: '%s'.\n",
curproxy->id, curproxy->defbe.name);
@ -6951,6 +6951,15 @@ int check_config_validity()
Alert("Proxy '%s': loop detected for default_backend: '%s'.\n",
curproxy->id, curproxy->defbe.name);
cfgerr++;
} else if (target->mode != curproxy->mode &&
!(curproxy->mode == PR_MODE_TCP && target->mode == PR_MODE_HTTP)) {
Alert("%s %s '%s' (%s:%d) tries to use incompatible %s %s '%s' (%s:%d) as its default backend (see 'mode').\n",
proxy_mode_str(curproxy->mode), proxy_type_str(curproxy), curproxy->id,
curproxy->conf.file, curproxy->conf.line,
proxy_mode_str(target->mode), proxy_type_str(target), target->id,
target->conf.file, target->conf.line);
cfgerr++;
} else {
free(curproxy->defbe.name);
curproxy->defbe.be = target;
@ -6974,7 +6983,7 @@ int check_config_validity()
if (exp->action != ACT_SETBE)
continue;
target = findproxy_mode(exp->replace, PR_MODE_HTTP, PR_CAP_BE);
target = proxy_be_by_name(exp->replace);
if (!target) {
Alert("Proxy '%s': unable to find required setbe: '%s'.\n",
curproxy->id, exp->replace);
@ -6983,6 +6992,13 @@ int check_config_validity()
Alert("Proxy '%s': loop detected for setbe: '%s'.\n",
curproxy->id, exp->replace);
cfgerr++;
} else if (target->mode != PR_MODE_HTTP) {
Alert("%s %s '%s' (%s:%d) tries to use incompatible %s %s '%s' (%s:%d) in a 'reqsetbe' rule (see 'mode').\n",
proxy_mode_str(curproxy->mode), proxy_type_str(curproxy), curproxy->id,
curproxy->conf.file, curproxy->conf.line,
proxy_mode_str(target->mode), proxy_type_str(target), target->id,
target->conf.file, target->conf.line);
cfgerr++;
} else {
free((void *)exp->replace);
exp->replace = (const char *)target;
@ -7021,8 +7037,7 @@ int check_config_validity()
rule->dynamic = 0;
rule->be.name = pxname;
target = findproxy_mode(rule->be.name, curproxy->mode, PR_CAP_BE);
target = proxy_be_by_name(rule->be.name);
if (!target) {
Alert("Proxy '%s': unable to find required use_backend: '%s'.\n",
curproxy->id, rule->be.name);
@ -7031,6 +7046,15 @@ int check_config_validity()
Alert("Proxy '%s': loop detected for use_backend: '%s'.\n",
curproxy->id, rule->be.name);
cfgerr++;
} else if (target->mode != curproxy->mode &&
!(curproxy->mode == PR_MODE_TCP && target->mode == PR_MODE_HTTP)) {
Alert("%s %s '%s' (%s:%d) tries to use incompatible %s %s '%s' (%s:%d) in a 'use_backend' rule (see 'mode').\n",
proxy_mode_str(curproxy->mode), proxy_type_str(curproxy), curproxy->id,
curproxy->conf.file, curproxy->conf.line,
proxy_mode_str(target->mode), proxy_type_str(target), target->id,
target->conf.file, target->conf.line);
cfgerr++;
} else {
free((void *)rule->be.name);
rule->be.backend = target;