]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: flt-decomp: Stop to explicitly loop on the proxy's filter_configs list
authorChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 Oct 2026 10:51:14 +0000 (11:51 +0100)
committerChristopher Faulet <cfaulet@haproxy.com>
Tue, 27 Oct 2026 13:08:45 +0000 (14:08 +0100)
The "decomp-req" and "decomp-res" filter keyword parsers scanned the
filter_configs list of the proxy by hand to detect an already declared
decompression filter configuration, matching on the filter id.

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. As a side effect, the message of the "decomp-res" duplicate
error now names the right filter.

src/flt_decomp.c

index 645b64ad17fd444eb57b2cfd8a35e355a5992d13..b0409342a8bd5b2c6998ff18077539388d9225f4 100644 (file)
@@ -1210,7 +1210,6 @@ static int
 parse_decomp_req_flt(char **args, int *cur_arg, struct proxy *px,
                      struct flt_conf *fconf, char **err, void *private)
 {
-       struct flt_conf *fc;
        struct decomp *decomp;
 
        if (!(px->cap & PR_CAP_FE)) {
@@ -1219,11 +1218,9 @@ parse_decomp_req_flt(char **args, int *cur_arg, struct proxy *px,
                return -1;
        }
 
-       list_for_each_entry(fc, &px->filter_configs, list) {
-               if (fc->id == decomp_req_flt_id) {
-                       memprintf(err, "%s: Proxy supports only one decomp-req filter\n", px->id);
-                       return -1;
-               }
+       if (flt_find_conf(px, decomp_req_flt_id, FLT_SIDE_GLOBAL, NULL, NULL)) {
+               memprintf(err, "%s: Proxy supports only one decomp-req filter\n", px->id);
+               return -1;
        }
 
        decomp = proxy_get_decomp(px, 0);
@@ -1245,7 +1242,6 @@ static int
 parse_decomp_res_flt(char **args, int *cur_arg, struct proxy *px,
                      struct flt_conf *fconf, char **err, void *private)
 {
-       struct flt_conf *fc;
        struct decomp *decomp;
 
        if (!(px->cap & PR_CAP_BE)) {
@@ -1254,11 +1250,9 @@ parse_decomp_res_flt(char **args, int *cur_arg, struct proxy *px,
                return -1;
        }
 
-       list_for_each_entry(fc, &px->filter_configs, list) {
-               if (fc->id == decomp_res_flt_id) {
-                       memprintf(err, "%s: Proxy supports only one decomp-res filter\n", px->id);
-                       return -1;
-               }
+       if (flt_find_conf(px, decomp_res_flt_id, FLT_SIDE_GLOBAL, NULL, NULL)) {
+               memprintf(err, "%s: Proxy supports only one decomp-req filter\n", px->id);
+               return -1;
        }
 
        decomp = proxy_get_decomp(px, 0);