From: Aurelien DARRAGON Date: Thu, 16 Nov 2023 10:29:58 +0000 (+0100) Subject: MINOR: log/backend: prevent stick table and stick rules with LOG mode X-Git-Tag: v2.9-dev10~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=4b2616f78400fac5ca7202b28b3f101d984c2a2b;p=thirdparty%2Fhaproxy.git MINOR: log/backend: prevent stick table and stick rules with LOG mode Report a warning and prevent errors if user tries to declare a stick table or use stick rules within a log backend. --- diff --git a/include/haproxy/proxy.h b/include/haproxy/proxy.h index 83c13bd128..e67ea2c059 100644 --- a/include/haproxy/proxy.h +++ b/include/haproxy/proxy.h @@ -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 diff --git a/src/log.c b/src/log.c index bd95c0b8e5..f9a4e26b26 100644 --- 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; } diff --git a/src/proxy.c b/src/proxy.c index fae11acccf..0bac0898f1 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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;