From 629a5ae5310b26f6e47f4614f924bccce2ffe85f Mon Sep 17 00:00:00 2001 From: Aurelien DARRAGON Date: Tue, 31 Mar 2026 14:44:34 +0200 Subject: [PATCH] MINOR: filters: add filter name to flt_conf struct flt_conf struct stores the filter id, which is used internally to check match the filter against static pointer identifier, and also used as descriptive text to describe the filter. But the id is not consistent with the public name as used in the configuration (for instance when selecting filter through the 'filter' directive). What we do in this patch is that we add flt_conf->name member, which stores the real filter name as seen in the configuration. This will allow to select filters by their name from other directives in the configuration. --- include/haproxy/filters-t.h | 1 + src/filters.c | 2 ++ src/flt_http_comp.c | 2 ++ 3 files changed, 5 insertions(+) diff --git a/include/haproxy/filters-t.h b/include/haproxy/filters-t.h index 19658d847..f5a49856b 100644 --- a/include/haproxy/filters-t.h +++ b/include/haproxy/filters-t.h @@ -207,6 +207,7 @@ struct flt_ops { * accessible from a filter when instantiated in a stream */ struct flt_conf { + const char *name; /* The filter name (same name used to select the filter from config) */ const char *id; /* The filter id */ struct flt_ops *ops; /* The filter callbacks */ void *conf; /* The filter configuration */ diff --git a/src/filters.c b/src/filters.c index 20f965e06..61fcc8fe2 100644 --- a/src/filters.c +++ b/src/filters.c @@ -249,6 +249,8 @@ parse_filter(char **args, int section_type, struct proxy *curpx, cur_arg = 1; kw = flt_find_kw(args[cur_arg]); if (kw) { + /* default name is keyword name, unless overriden by parse func */ + fconf->name = kw->kw; if (!kw->parse) { memprintf(err, "parsing [%s:%d] : '%s' : " "'%s' option is not implemented in this version (check build options).", diff --git a/src/flt_http_comp.c b/src/flt_http_comp.c index ea9adddc9..6e15cb7e9 100644 --- a/src/flt_http_comp.c +++ b/src/flt_http_comp.c @@ -1033,6 +1033,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->ops = &comp_req_ops; @@ -1048,6 +1049,7 @@ parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px, return -1; } fconf_res->id = http_comp_res_flt_id; + fconf_res->name = "comp-res"; fconf_res->conf = NULL; fconf_res->ops = &comp_res_ops;