From: Aurelien DARRAGON Date: Tue, 19 Sep 2023 15:39:25 +0000 (+0200) Subject: MINOR: backend/balance: "balance" requires TCP or HTTP mode X-Git-Tag: v2.9-dev7~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e0093a317;p=thirdparty%2Fhaproxy.git MINOR: backend/balance: "balance" requires TCP or HTTP mode Prevent the use of "balance" and associated keywords when proxy is neither in tcp or http mode. --- diff --git a/src/cfgparse-listen.c b/src/cfgparse-listen.c index 78ccd98a9a..f513207e61 100644 --- a/src/cfgparse-listen.c +++ b/src/cfgparse-listen.c @@ -2502,6 +2502,12 @@ stats_error_parsing: if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) err_code |= ERR_WARN; + if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) { + ha_alert("parsing [%s:%d] : '%s' requires TCP or HTTP mode.\n", file, linenum, args[0]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + if (backend_parse_balance((const char **)args + 1, &errmsg, curproxy) < 0) { ha_alert("parsing [%s:%d] : %s %s\n", file, linenum, args[0], errmsg); err_code |= ERR_ALERT | ERR_FATAL; @@ -2517,6 +2523,12 @@ stats_error_parsing: */ curproxy->lbprm.algo &= ~(BE_LB_HASH_TYPE | BE_LB_HASH_FUNC | BE_LB_HASH_MOD); + if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) { + ha_alert("parsing [%s:%d] : '%s' requires TCP or HTTP mode.\n", file, linenum, args[0]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + if (warnifnotcap(curproxy, PR_CAP_BE, file, linenum, args[0], NULL)) err_code |= ERR_WARN; @@ -2577,6 +2589,12 @@ stats_error_parsing: } } else if (strcmp(args[0], "hash-balance-factor") == 0) { + if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) { + ha_alert("parsing [%s:%d] : '%s' requires TCP or HTTP mode.\n", file, linenum, args[0]); + err_code |= ERR_ALERT | ERR_FATAL; + goto out; + } + if (*(args[1]) == 0) { ha_alert("parsing [%s:%d] : '%s' expects an integer argument.\n", file, linenum, args[0]); err_code |= ERR_ALERT | ERR_FATAL;