From: Christopher Faulet Date: Tue, 27 Oct 2026 10:54:35 +0000 (+0100) Subject: MINOR: flt-http-comp: Stop to explicitly loop on the proxy's filter_configs list X-Git-Tag: v3.5-dev10~30 X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=479eccf7ff79fac43650eb98c4ec310b640fb733;p=haproxy.git MINOR: flt-http-comp: Stop to explicitly loop on the proxy's filter_configs list The "compression", "comp-req" and "comp-res" filter keyword parsers scanned the filter_configs list of the proxy by hand to detect an already declared compression filter configuration, matching on the filter ids. The parsers now use flt_find_conf(), the supported way to find a filter configuration, which walks the right list depending on the filter mode of the proxy. The "compression" duplicate check resolves the two possible configurations with two successive lookups, one per direction. --- diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index 15aa16610..4e577bd3b 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -1071,15 +1071,13 @@ static int parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px, struct flt_conf *fconf, char **err, void *private) { - struct flt_conf *fc, *back; struct flt_conf *fconf_res; struct comp *comp; - list_for_each_entry_safe(fc, back, &px->filter_configs, list) { - if (fc->id == http_comp_req_flt_id || fc->id == http_comp_res_flt_id) { - memprintf(err, "%s: Proxy supports only one compression filter\n", px->id); - return -1; - } + if (flt_find_conf(px, http_comp_req_flt_id, FLT_SIDE_GLOBAL, NULL, NULL) || + flt_find_conf(px, http_comp_res_flt_id, FLT_SIDE_GLOBAL, NULL, NULL)) { + memprintf(err, "%s: Proxy supports only one compression filter\n", px->id); + return -1; } /* Allocate the compression options now, they will be filled by the @@ -1130,14 +1128,11 @@ static int parse_http_comp_req_flt(char **args, int *cur_arg, struct proxy *px, struct flt_conf *fconf, char **err, void *private) { - struct flt_conf *fc, *back; struct comp *comp; - list_for_each_entry_safe(fc, back, &px->filter_configs, list) { - if (fc->id == http_comp_req_flt_id) { - memprintf(err, "%s: Proxy supports only one comp-req filter\n", px->id); - return -1; - } + if (flt_find_conf(px, http_comp_req_flt_id, FLT_SIDE_GLOBAL, NULL, NULL)) { + memprintf(err, "%s: Proxy supports only one comp-req filter\n", px->id); + return -1; } comp = proxy_get_comp(px, 0); @@ -1159,14 +1154,11 @@ static int parse_http_comp_res_flt(char **args, int *cur_arg, struct proxy *px, struct flt_conf *fconf, char **err, void *private) { - struct flt_conf *fc, *back; struct comp *comp; - list_for_each_entry_safe(fc, back, &px->filter_configs, list) { - if (fc->id == http_comp_res_flt_id) { - memprintf(err, "%s: Proxy supports only one comp-res filter\n", px->id); - return -1; - } + if (flt_find_conf(px, http_comp_res_flt_id, FLT_SIDE_GLOBAL, NULL, NULL)) { + memprintf(err, "%s: Proxy supports only one comp-res filter\n", px->id); + return -1; } comp = proxy_get_comp(px, 0);