]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: stktable: "stick" requires TCP or HTTP mode
authorAurelien DARRAGON <adarragon@haproxy.com>
Tue, 19 Sep 2023 15:20:24 +0000 (17:20 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 6 Oct 2023 13:34:30 +0000 (15:34 +0200)
Prevent the use of "stick-table" and "stick *" when proxy is neither in
tcp or http mode.

src/cfgparse-listen.c

index 292f1626e4dfac225a78c7625d93a7f5a7207d7d..78ccd98a9af75aa77de9ae0d189a0a533d5b6c18 100644 (file)
@@ -1527,6 +1527,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
+               if (curproxy->mode != PR_MODE_TCP && curproxy->mode != PR_MODE_HTTP) {
+                       ha_alert("parsing [%s:%d] : 'stick-table' requires TCP or HTTP mode.\n",
+                                file, linenum);
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+
                other = stktable_find_by_name(curproxy->id);
                if (other) {
                        ha_alert("parsing [%s:%d] : stick-table name '%s' conflicts with table declared in %s '%s' at %s:%d.\n",
@@ -1579,6 +1586,13 @@ int cfg_parse_listen(const char *file, int linenum, char **args, int kwm)
                        goto out;
                }
 
+               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;
                        goto out;