]> git.kaiwu.me - haproxy.git/commitdiff
MINOR: flt-http-comp: Use compression options as filter config
authorChristopher Faulet <cfaulet@haproxy.com>
Mon, 5 Oct 2026 19:51:04 +0000 (21:51 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 9 Oct 2026 14:17:35 +0000 (16:17 +0200)
All comp filter configurations left their ->conf pointer NULL: the request
and response compression filters resolved the proxy options at runtime,
through strm_fe(s)->comp and s->be->comp, so the pointer was never used by
the stream callbacks.

Now store the proxy's compression configuration (px->comp) in the filter
configurations, for the explicit "filter compression", "filter comp-req" and
"filter comp-res" declarations as well as for the filters implicitly
declared by check_implicit_http_comp_flt(). The compression options become
the actual configuration of these filters, like the decompression filters
already do with their direction.

No stream callback is changed: the runtime resolution through the frontend
and backend proxies is preserved, since the options of both proxies are
combined to compress a message, with a priority to the backend ones. But the
attach callback can now rely on FLT_CONF() to know whether a filter can be
useful, and the http-comp filter instances will set the same pointer.

The configuration remains owned by the proxy and released with it: the
compression filters have no deinit callback freeing ->conf.

src/flt_http_comp.c

index 1d6ca1a9cf05df7c0b4d2ada08cf67016f489c49..f5c6ca13425f257352697b3a98fe834cfd3867d5 100644 (file)
@@ -1045,7 +1045,7 @@ parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px,
 
        fconf->id   = http_comp_req_flt_id;
        fconf->name = "comp-req";
-       fconf->conf = NULL;
+       fconf->conf = px->comp;
        fconf->ops  = &comp_req_ops;
 
        /* FILTER API prepared a single filter_conf struct as it is meant to
@@ -1061,7 +1061,7 @@ parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px,
        }
        fconf_res->id = http_comp_res_flt_id;
        fconf_res->name = "comp-res";
-       fconf_res->conf = NULL;
+       fconf_res->conf = px->comp;
        fconf_res->ops = &comp_res_ops;
 
        /* manually add the fconf_res to the list because filter API doesn't
@@ -1097,7 +1097,7 @@ parse_http_comp_req_flt(char **args, int *cur_arg, struct proxy *px,
        comp->flags |= COMP_FL_DIR_REQ;
 
        fconf->id   = http_comp_req_flt_id;
-       fconf->conf = NULL;
+       fconf->conf = px->comp;
        fconf->ops  = &comp_req_ops;
        (*cur_arg)++;
 
@@ -1126,7 +1126,7 @@ parse_http_comp_res_flt(char **args, int *cur_arg, struct proxy *px,
        comp->flags |= COMP_FL_DIR_RES;
 
        fconf->id   = http_comp_res_flt_id;
-       fconf->conf = NULL;
+       fconf->conf = px->comp;
        fconf->ops  = &comp_res_ops;
        (*cur_arg)++;
 
@@ -1190,12 +1190,12 @@ check_implicit_http_comp_flt(struct proxy *proxy)
                goto end;
        }
        fconf_req->id   = http_comp_req_flt_id;
-       fconf_req->conf = NULL;
+       fconf_req->conf = proxy->comp;
        fconf_req->ops  = &comp_req_ops;
        LIST_APPEND(&proxy->filter_configs, &fconf_req->list);
 
        fconf_res->id   = http_comp_res_flt_id;
-       fconf_res->conf = NULL;
+       fconf_res->conf = proxy->comp;
        fconf_res->ops  = &comp_res_ops;
        LIST_APPEND(&proxy->filter_configs, &fconf_res->list);
  end: