]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: log/backend: prevent stick table and stick rules with LOG mode
authorAurelien DARRAGON <adarragon@haproxy.com>
Thu, 16 Nov 2023 10:29:58 +0000 (11:29 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 18 Nov 2023 10:16:21 +0000 (11:16 +0100)
Report a warning and prevent errors if user tries to declare a stick table
or use stick rules within a log backend.

include/haproxy/proxy.h
src/log.c
src/proxy.c

index 83c13bd128af34f2614a11ed410df4cf54dd2c9e..e67ea2c059d165ba04eada563e9d3872bbb697d8 100644 (file)
@@ -86,6 +86,7 @@ void proxy_adjust_all_maxconn(void);
 struct proxy *cli_find_frontend(struct appctx *appctx, const char *arg);
 struct proxy *cli_find_frontend(struct appctx *appctx, const char *arg);
 int resolve_stick_rule(struct proxy *curproxy, struct sticking_rule *mrule);
+void free_stick_rules(struct list *rules);
 
 /*
  * This function returns a string containing the type of the proxy in a format
index bd95c0b8e5ccfd9292e585429187fe4e8b191736..f9a4e26b2670b3a3dbacf1778555e037853202aa 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -898,6 +898,23 @@ static int _postcheck_log_backend_compat(struct proxy *be)
                err_code |= ERR_WARN;
                free_act_rules(&be->tcp_rep.inspect_rules);
        }
+       if (be->table) {
+               ha_warning("Cannot use stick table with 'mode log' in %s '%s'. It will be ignored.\n",
+                          proxy_type_str(be), be->id);
+
+               err_code |= ERR_WARN;
+               stktable_deinit(be->table);
+               ha_free(&be->table);
+       }
+       if (!LIST_ISEMPTY(&be->storersp_rules) ||
+           !LIST_ISEMPTY(&be->sticking_rules)) {
+               ha_warning("Cannot use sticking rules with 'mode log' in %s '%s'. They will be ignored.\n",
+                          proxy_type_str(be), be->id);
+
+               err_code |= ERR_WARN;
+               free_stick_rules(&be->storersp_rules);
+               free_stick_rules(&be->sticking_rules);
+       }
        return err_code;
 }
 
index fae11acccf3b75e154ace13f0e99a13d03e08a4c..0bac0898f1dce8ef944a1d7e5d603d473c2e5080 100644 (file)
@@ -165,7 +165,7 @@ int resolve_stick_rule(struct proxy *curproxy, struct sticking_rule *mrule)
        return 1;
 }
 
-static void free_stick_rules(struct list *rules)
+void free_stick_rules(struct list *rules)
 {
        struct sticking_rule *rule, *ruleb;