]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: filters: Extract proxy stuff from the struct filter
authorChristopher Faulet <cfaulet@qualys.com>
Thu, 4 Feb 2016 12:40:26 +0000 (13:40 +0100)
committerWilly Tarreau <w@1wt.eu>
Tue, 9 Feb 2016 13:53:15 +0000 (14:53 +0100)
Now, filter's configuration (.id, .conf and .ops fields) is stored in the
structure 'flt_conf'. So proxies own a flt_conf list instead of a filter
list. When a filter is attached to a stream, it gets a pointer on its
configuration. This avoids mixing the filter's context (owns by a stream) and
its configuration (owns by a proxy). It also saves 2 pointers per filter
instance.

include/proto/filters.h
include/types/filters.h
include/types/proxy.h
src/cfgparse.c
src/filters.c
src/flt_http_comp.c
src/flt_trace.c
src/proxy.c

index e4061a73d2d9df0bab94d4f53187c12c73f97772..f9b0fb0ec1b9269eef998ae5e347e959dc9719d9 100644 (file)
 
 #include <proto/channel.h>
 
+#define FLT_ID(flt)   (flt)->config->id
+#define FLT_CONF(flt) (flt)->config->conf
+#define FLT_OPS(flt)  (flt)->config->ops
+
 /* Useful macros to access per-channel values. It can be safely used inside
  * filters. */
 #define CHN_IDX(chn)     (((chn)->flags & CF_ISRESP) == CF_ISRESP)
index c433078bde49d566d2194187462d9d2a0f55b334..84469469a1156d621a8d61a27b3eccf4ade0dc72 100644 (file)
@@ -28,6 +28,7 @@ struct http_msg;
 struct proxy;
 struct stream;
 struct channel;
+struct flt_conf;
 struct filter;
 
 /* Descriptor for a "filter" keyword. The ->parse() function returns 0 in case
@@ -40,7 +41,7 @@ struct filter;
 struct flt_kw {
        const char *kw;
        int (*parse)(char **args, int *cur_arg, struct proxy *px,
-                    struct filter *filter, char **err);
+                    struct flt_conf *fconf, char **err);
 };
 
 /*
@@ -123,9 +124,9 @@ struct flt_ops {
        /*
         * Callbacks to manage the filter lifecycle
         */
-       int  (*init)  (struct proxy *p, struct filter *f);
-       void (*deinit)(struct proxy *p, struct filter *f);
-       int  (*check) (struct proxy *p, struct filter *f);
+       int  (*init)  (struct proxy *p, struct flt_conf *fconf);
+       void (*deinit)(struct proxy *p, struct flt_conf *fconf);
+       int  (*check) (struct proxy *p, struct flt_conf *fconf);
 
        /*
         * Stream callbacks
@@ -171,9 +172,18 @@ struct flt_ops {
 #define STRM_FLT_FL_HAS_FILTERS          0x0001 /* The stream has at least one filter */
 
 /*
- * Structure representing the state of a filter. When attached to a proxy, only
- * <ops> and <conf> field (and optionnaly <id>) are set. All other fields are
- * used when the filter is attached to a stream.
+ * Structure representing the filter configuration, attached to a proxy and
+ * accessible from a filter when instantiated in a stream
+ */
+struct flt_conf {
+       const char     *id;   /* The filter id */
+       struct flt_ops *ops;  /* The filter callbacks */
+       void           *conf; /* The filter configuration */
+       struct list     list; /* Next filter for the same proxy */
+};
+
+/*
+ * Structure reprensenting a filter instance attached to a stream
  *
  * 2D-Array fields are used to store info per channel. The first index stands
  * for the request channel, and the second one for the response channel.
@@ -182,9 +192,7 @@ struct flt_ops {
  * access these values using FLT_NXT and FLT_FWD macros.
  */
 struct filter {
-       const char     *id;                /* The filter id */
-       struct flt_ops *ops;               /* The filter callbacks */
-       void           *conf;              /* The filter configuration */
+       struct flt_conf *config;           /* the filter's configuration */
        void           *ctx;               /* The filter context (opaque) */
        unsigned short  flags;             /* FLT_FL_* */
        unsigned int    next[2];           /* Offset, relative to buf->p, to the next byte to parse for a specific channel
index 71fd35dd6334caee35f056ef9e6625b7aa7c26e4..79a34117f8e58b2219aaf40413de63f58819c4a2 100644 (file)
@@ -432,8 +432,7 @@ struct proxy {
                                                 * this backend. If not specified or void, then the backend
                                                 * name is used
                                                 */
-
-       struct list filters;
+       struct list filter_configs;             /* list of the filters that are declared on this proxy */
 };
 
 struct switching_rule {
index 55622a4255402275e6fdec38e954eb0ab1b6f1b8..68cee2629bc2eb914a662dc0f31db10865ce99f3 100644 (file)
@@ -8435,7 +8435,7 @@ out_uri_auth_compat:
                        curproxy->fe_req_ana |= AN_REQ_SWITCHING_RULES;
 
                        /* Add filters analyzers if needed */
-                       if (!LIST_ISEMPTY(&curproxy->filters)) {
+                       if (!LIST_ISEMPTY(&curproxy->filter_configs)) {
                                curproxy->fe_req_ana |= AN_FLT_ALL_FE;
                                curproxy->fe_rsp_ana |= AN_FLT_ALL_FE;
                                if (curproxy->mode == PR_MODE_HTTP) {
@@ -8465,7 +8465,7 @@ out_uri_auth_compat:
                                curproxy->be_req_ana |= AN_REQ_PRST_RDP_COOKIE;
 
                        /* Add filters analyzers if needed */
-                       if (!LIST_ISEMPTY(&curproxy->filters)) {
+                       if (!LIST_ISEMPTY(&curproxy->filter_configs)) {
                                curproxy->be_req_ana |= AN_FLT_ALL_BE;
                                curproxy->be_rsp_ana |= AN_FLT_ALL_BE;
                                if (curproxy->mode == PR_MODE_HTTP) {
index 1ab2b376df169b9a02b6fe42a1c8adbdb8d76d69..420ad8029a00710982b1efd094849299fb3bacc5 100644 (file)
@@ -158,7 +158,7 @@ static int
 parse_filter(char **args, int section_type, struct proxy *curpx,
             struct proxy *defpx, const char *file, int line, char **err)
 {
-       struct filter *filter = NULL;
+       struct flt_conf *fconf = NULL;
 
        /* Filter cannot be defined on a default proxy */
        if (curpx == defpx) {
@@ -176,12 +176,11 @@ parse_filter(char **args, int section_type, struct proxy *curpx,
                                  file, line, args[0], proxy_type_str(curpx), curpx->id);
                        goto error;
                }
-               filter = pool_alloc2(pool2_filter);
-               if (!filter) {
+               fconf = calloc(1, sizeof(*fconf));
+               if (!fconf) {
                        memprintf(err, "'%s' : out of memory", args[0]);
                        goto error;
                }
-               memset(filter, 0, sizeof(*filter));
 
                cur_arg = 1;
                kw = flt_find_kw(args[cur_arg]);
@@ -192,7 +191,7 @@ parse_filter(char **args, int section_type, struct proxy *curpx,
                                          file, line, args[0], args[cur_arg]);
                                goto error;
                        }
-                       if (kw->parse(args, &cur_arg, curpx, filter, err) != 0) {
+                       if (kw->parse(args, &cur_arg, curpx, fconf, err) != 0) {
                                if (err && *err)
                                        memprintf(err, "'%s' : '%s'",
                                                  args[0], *err);
@@ -216,13 +215,12 @@ parse_filter(char **args, int section_type, struct proxy *curpx,
                        goto error;
                }
 
-               LIST_ADDQ(&curpx->filters, &filter->list);
+               LIST_ADDQ(&curpx->filter_configs, &fconf->list);
        }
        return 0;
 
   error:
-       if (filter)
-               pool_free2(pool2_filter, filter);
+       free(fconf);
        return -1;
 
 
@@ -236,10 +234,10 @@ parse_filter(char **args, int section_type, struct proxy *curpx,
 int
 flt_init(struct proxy *proxy)
 {
-       struct filter *filter;
+       struct flt_conf *fconf;
 
-       list_for_each_entry(filter, &proxy->filters, list) {
-               if (filter->ops->init && filter->ops->init(proxy, filter) < 0)
+       list_for_each_entry(fconf, &proxy->filter_configs, list) {
+               if (fconf->ops->init && fconf->ops->init(proxy, fconf) < 0)
                        return ERR_ALERT|ERR_FATAL;
        }
        return 0;
@@ -253,12 +251,12 @@ flt_init(struct proxy *proxy)
 int
 flt_check(struct proxy *proxy)
 {
-       struct filter *filter;
-       int            err = 0;
+       struct flt_conf *fconf;
+       int err = 0;
 
-       list_for_each_entry(filter, &proxy->filters, list) {
-               if (filter->ops->check)
-                       err += filter->ops->check(proxy, filter);
+       list_for_each_entry(fconf, &proxy->filter_configs, list) {
+               if (fconf->ops->check)
+                       err += fconf->ops->check(proxy, fconf);
        }
        err += check_legacy_http_comp_flt(proxy);
        return err;
@@ -271,27 +269,25 @@ flt_check(struct proxy *proxy)
 void
 flt_deinit(struct proxy *proxy)
 {
-       struct filter *filter, *back;
+       struct flt_conf *fconf, *back;
 
-       list_for_each_entry_safe(filter, back, &proxy->filters, list) {
-               if (filter->ops->deinit)
-                       filter->ops->deinit(proxy, filter);
-               LIST_DEL(&filter->list);
-               pool_free2(pool2_filter, filter);
+       list_for_each_entry_safe(fconf, back, &proxy->filter_configs, list) {
+               if (fconf->ops->deinit)
+                       fconf->ops->deinit(proxy, fconf);
+               LIST_DEL(&fconf->list);
+               free(fconf);
        }
 }
 
 /* Attaches a filter to a stream. Returns -1 if an error occurs, 0 otherwise. */
 static int
-flt_stream_add_filter(struct stream *s, struct filter *filter, unsigned int flags)
+flt_stream_add_filter(struct stream *s, struct flt_conf *fconf, unsigned int flags)
 {
        struct filter *f = pool_alloc2(pool2_filter);
        if (!f) /* not enough memory */
                return -1;
        memset(f, 0, sizeof(*f));
-       f->id    = filter->id;
-       f->ops   = filter->ops;
-       f->conf  = filter->conf;
+       f->config = fconf;
        f->flags |= flags;
        LIST_ADDQ(&strm_flt(s)->filters, &f->list);
        strm_flt(s)->flags |= STRM_FLT_FL_HAS_FILTERS;
@@ -305,12 +301,12 @@ flt_stream_add_filter(struct stream *s, struct filter *filter, unsigned int flag
 int
 flt_stream_init(struct stream *s)
 {
-       struct filter *filter;
+       struct flt_conf *fconf;
 
        memset(strm_flt(s), 0, sizeof(*strm_flt(s)));
        LIST_INIT(&strm_flt(s)->filters);
-       list_for_each_entry(filter, &strm_fe(s)->filters, list) {
-               if (flt_stream_add_filter(s, filter, 0) < 0)
+       list_for_each_entry(fconf, &strm_fe(s)->filter_configs, list) {
+               if (flt_stream_add_filter(s, fconf, 0) < 0)
                        return -1;
        }
        return 0;
@@ -348,7 +344,7 @@ flt_stream_start(struct stream *s)
        struct filter *filter;
 
        list_for_each_entry(filter, &strm_flt(s)->filters, list) {
-               if (filter->ops->stream_start && filter->ops->stream_start(s, filter) < 0)
+               if (FLT_OPS(filter)->stream_start && FLT_OPS(filter)->stream_start(s, filter) < 0)
                        return -1;
        }
        return 0;
@@ -364,8 +360,8 @@ flt_stream_stop(struct stream *s)
        struct filter *filter;
 
        list_for_each_entry(filter, &strm_flt(s)->filters, list) {
-               if (filter->ops->stream_stop)
-                       filter->ops->stream_stop(s, filter);
+               if (FLT_OPS(filter)->stream_stop)
+                       FLT_OPS(filter)->stream_stop(s, filter);
        }
 }
 
@@ -377,13 +373,13 @@ flt_stream_stop(struct stream *s)
 int
 flt_set_stream_backend(struct stream *s, struct proxy *be)
 {
-       struct filter *filter;
+       struct flt_conf *fconf;
 
        if (strm_fe(s) == be)
                return 0;
 
-       list_for_each_entry(filter, &be->filters, list) {
-               if (flt_stream_add_filter(s, filter, FLT_FL_IS_BACKEND_FILTER) < 0)
+       list_for_each_entry(fconf, &be->filter_configs, list) {
+               if (flt_stream_add_filter(s, fconf, FLT_FL_IS_BACKEND_FILTER) < 0)
                        return -1;
        }
        return 0;
@@ -423,8 +419,8 @@ flt_http_data(struct stream *s, struct http_msg *msg)
                if (msg->next > *nxt)
                        *nxt = msg->next;
 
-               if (filter->ops->http_data) {
-                       ret = filter->ops->http_data(s, filter, msg);
+               if (FLT_OPS(filter)->http_data) {
+                       ret = FLT_OPS(filter)->http_data(s, filter, msg);
                        if (ret < 0)
                                break;
 
@@ -477,8 +473,8 @@ flt_http_chunk_trailers(struct stream *s, struct http_msg *msg)
                nxt = &FLT_NXT(filter, msg->chn);
                *nxt = msg->next;
 
-               if (filter->ops->http_chunk_trailers) {
-                       ret = filter->ops->http_chunk_trailers(s, filter, msg);
+               if (FLT_OPS(filter)->http_chunk_trailers) {
+                       ret = FLT_OPS(filter)->http_chunk_trailers(s, filter, msg);
                        if (ret < 0)
                                break;
                }
@@ -502,8 +498,8 @@ flt_http_end(struct stream *s, struct http_msg *msg)
        int ret = 1;
 
        RESUME_FILTER_LOOP(s, msg->chn) {
-               if (filter->ops->http_end) {
-                       ret = filter->ops->http_end(s, filter, msg);
+               if (FLT_OPS(filter)->http_end) {
+                       ret = FLT_OPS(filter)->http_end(s, filter, msg);
                        if (ret <= 0)
                                BREAK_EXECUTION(s, msg->chn, end);
                }
@@ -522,8 +518,8 @@ flt_http_reset(struct stream *s, struct http_msg *msg)
        struct filter *filter;
 
        list_for_each_entry(filter, &strm_flt(s)->filters, list) {
-               if (filter->ops->http_reset)
-                       filter->ops->http_reset(s, filter, msg);
+               if (FLT_OPS(filter)->http_reset)
+                       FLT_OPS(filter)->http_reset(s, filter, msg);
        }
 }
 
@@ -537,8 +533,8 @@ flt_http_reply(struct stream *s, short status, const struct chunk *msg)
        struct filter *filter;
 
        list_for_each_entry(filter, &strm_flt(s)->filters, list) {
-               if (filter->ops->http_reply)
-                       filter->ops->http_reply(s, filter, status, msg);
+               if (FLT_OPS(filter)->http_reply)
+                       FLT_OPS(filter)->http_reply(s, filter, status, msg);
        }
 }
 
@@ -572,10 +568,10 @@ flt_http_forward_data(struct stream *s, struct http_msg *msg, unsigned int len)
                if (msg->next > *nxt)
                        *nxt = msg->next;
 
-               if (filter->ops->http_forward_data) {
+               if (FLT_OPS(filter)->http_forward_data) {
                        /* Remove bytes that the current filter considered as
                         * forwarded */
-                       ret = filter->ops->http_forward_data(s, filter, msg, ret - *fwd);
+                       ret = FLT_OPS(filter)->http_forward_data(s, filter, msg, ret - *fwd);
                        if (ret < 0)
                                goto end;
                }
@@ -628,8 +624,8 @@ flt_start_analyze(struct stream *s, struct channel *chn, unsigned int an_bit)
                FLT_NXT(filter, chn) = 0;
                FLT_FWD(filter, chn) = 0;
 
-               if (filter->ops->channel_start_analyze) {
-                       ret = filter->ops->channel_start_analyze(s, filter, chn);
+               if (FLT_OPS(filter)->channel_start_analyze) {
+                       ret = FLT_OPS(filter)->channel_start_analyze(s, filter, chn);
                        if (ret <= 0)
                                BREAK_EXECUTION(s, chn, end);
                }
@@ -652,8 +648,8 @@ flt_analyze(struct stream *s, struct channel *chn, unsigned int an_bit)
        int ret = 1;
 
        RESUME_FILTER_LOOP(s, chn) {
-               if (filter->ops->channel_analyze) {
-                       ret = filter->ops->channel_analyze(s, filter, chn, an_bit);
+               if (FLT_OPS(filter)->channel_analyze) {
+                       ret = FLT_OPS(filter)->channel_analyze(s, filter, chn, an_bit);
                        if (ret <= 0)
                                BREAK_EXECUTION(s, chn, check_result);
                }
@@ -676,8 +672,8 @@ flt_analyze_http_headers(struct stream *s, struct channel *chn, unsigned int an_
        int            ret = 1;
 
        RESUME_FILTER_LOOP(s, chn) {
-               if (filter->ops->channel_analyze) {
-                       ret = filter->ops->channel_analyze(s, filter, chn, an_bit);
+               if (FLT_OPS(filter)->channel_analyze) {
+                       ret = FLT_OPS(filter)->channel_analyze(s, filter, chn, an_bit);
                        if (ret <= 0)
                                BREAK_EXECUTION(s, chn, check_result);
                }
@@ -717,8 +713,8 @@ flt_end_analyze(struct stream *s, struct channel *chn, unsigned int an_bit)
                FLT_FWD(filter, chn) = 0;
                unregister_data_filter(s, chn, filter);
 
-               if (filter->ops->channel_end_analyze) {
-                       ret = filter->ops->channel_end_analyze(s, filter, chn);
+               if (FLT_OPS(filter)->channel_end_analyze) {
+                       ret = FLT_OPS(filter)->channel_end_analyze(s, filter, chn);
                        if (ret <= 0)
                                BREAK_EXECUTION(s, chn, end);
                }
@@ -778,8 +774,8 @@ flt_data(struct stream *s, struct channel *chn)
                        continue;
 
                nxt = &FLT_NXT(filter, chn);
-               if (filter->ops->tcp_data) {
-                       ret = filter->ops->tcp_data(s, filter, chn);
+               if (FLT_OPS(filter)->tcp_data) {
+                       ret = FLT_OPS(filter)->tcp_data(s, filter, chn);
                        if (ret < 0)
                                break;
 
@@ -830,10 +826,10 @@ flt_forward_data(struct stream *s, struct channel *chn, unsigned int len)
                        continue;
 
                fwd = &FLT_FWD(filter, chn);
-               if (filter->ops->tcp_forward_data) {
+               if (FLT_OPS(filter)->tcp_forward_data) {
                        /* Remove bytes that the current filter considered as
                         * forwarded */
-                       ret = filter->ops->tcp_forward_data(s, filter, chn, ret - *fwd);
+                       ret = FLT_OPS(filter)->tcp_forward_data(s, filter, chn, ret - *fwd);
                        if (ret < 0)
                                goto end;
                }
index d9a13389e68d91ed87fd3fc79deda0190e266756..46abe5277eee09bf291966c3a1fd714c5a60ef6a 100644 (file)
@@ -62,7 +62,7 @@ static int http_compression_buffer_end(struct comp_state *st, struct stream *s,
 
 /***********************************************************************/
 static int
-comp_flt_init(struct proxy *px, struct filter *filter)
+comp_flt_init(struct proxy *px, struct flt_conf *fconf)
 {
 
        if (!tmpbuf->size && b_alloc(&tmpbuf) == NULL)
@@ -73,7 +73,7 @@ comp_flt_init(struct proxy *px, struct filter *filter)
 }
 
 static void
-comp_flt_deinit(struct proxy *px, struct filter *filter)
+comp_flt_deinit(struct proxy *px, struct flt_conf *fconf)
 {
        if (tmpbuf->size)
                b_free(&tmpbuf);
@@ -830,20 +830,20 @@ parse_compression_options(char **args, int section, struct proxy *proxy,
 
 static int
 parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px,
-                                        struct filter *filter, char **err)
+                        struct flt_conf *fconf, char **err)
 {
-       struct filter *flt, *back;
+       struct flt_conf *fc, *back;
 
-       list_for_each_entry_safe(flt, back, &px->filters, list) {
-               if (flt->id == http_comp_flt_id) {
+       list_for_each_entry_safe(fc, back, &px->filter_configs, list) {
+               if (fc->id == http_comp_flt_id) {
                        memprintf(err, "%s: Proxy supports only one compression filter\n", px->id);
                        return -1;
                }
        }
 
-       filter->id   = http_comp_flt_id;
-       filter->conf = NULL;
-       filter->ops  = &comp_ops;
+       fconf->id   = http_comp_flt_id;
+       fconf->conf = NULL;
+       fconf->ops  = &comp_ops;
        (*cur_arg)++;
 
        return 0;
@@ -853,14 +853,14 @@ parse_http_comp_flt(char **args, int *cur_arg, struct proxy *px,
 int
 check_legacy_http_comp_flt(struct proxy *proxy)
 {
-       struct filter *filter;
+       struct flt_conf *fconf;
        int err = 0;
 
        if (proxy->comp == NULL)
                goto end;
-       if (!LIST_ISEMPTY(&proxy->filters)) {
-               list_for_each_entry(filter, &proxy->filters, list) {
-                       if (filter->id == http_comp_flt_id)
+       if (!LIST_ISEMPTY(&proxy->filter_configs)) {
+               list_for_each_entry(fconf, &proxy->filter_configs, list) {
+                       if (fconf->id == http_comp_flt_id)
                                goto end;
                }
                Alert("config: %s '%s': require an explicit filter declaration to use HTTP compression\n",
@@ -869,18 +869,17 @@ check_legacy_http_comp_flt(struct proxy *proxy)
                goto end;
        }
 
-       filter = pool_alloc2(pool2_filter);
-       if (!filter) {
+       fconf = calloc(1, sizeof(*fconf));
+       if (!fconf) {
                Alert("config: %s '%s': out of memory\n",
                      proxy_type_str(proxy), proxy->id);
                err++;
                goto end;
        }
-       memset(filter, 0, sizeof(*filter));
-       filter->id   = http_comp_flt_id;
-       filter->conf = NULL;
-       filter->ops  = &comp_ops;
-       LIST_ADDQ(&proxy->filters, &filter->list);
+       fconf->id   = http_comp_flt_id;
+       fconf->conf = NULL;
+       fconf->ops  = &comp_ops;
+       LIST_ADDQ(&proxy->filter_configs, &fconf->list);
 
  end:
        return err;
@@ -916,7 +915,7 @@ smp_fetch_res_comp_algo(const struct arg *args, struct sample *smp,
                return 0;
 
        list_for_each_entry(filter, &strm_flt(smp->strm)->filters, list) {
-               if (filter->id != http_comp_flt_id)
+               if (FLT_ID(filter) != http_comp_flt_id)
                        continue;
 
                if (!(st = filter->ctx))
index 94664eb73bd29c7b4303c7d442f1d17e691109c5..a45f4a089fdeb6b3ea61638917ee4a34de2cc1cc 100644 (file)
@@ -70,15 +70,15 @@ stream_pos(const struct stream *s)
  **************************************************************************/
 /* Initialize the filter. Returns -1 on error, else 0. */
 static int
-trace_init(struct proxy *px, struct filter *filter)
+trace_init(struct proxy *px, struct flt_conf *fconf)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = fconf->conf;
 
        if (conf->name)
                memprintf(&conf->name, "%s/%s", conf->name, px->id);
        else
                memprintf(&conf->name, "TRACE/%s", px->id);
-       filter->conf = conf;
+       fconf->conf = conf;
        TRACE(conf, "filter initialized [read random=%s - fwd random=%s]",
              (conf->rand_parsing ? "true" : "false"),
              (conf->rand_forwarding ? "true" : "false"));
@@ -87,22 +87,22 @@ trace_init(struct proxy *px, struct filter *filter)
 
 /* Free ressources allocated by the trace filter. */
 static void
-trace_deinit(struct proxy *px, struct filter *filter)
+trace_deinit(struct proxy *px, struct flt_conf *fconf)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = fconf->conf;
 
        if (conf) {
                TRACE(conf, "filter deinitialized");
                free(conf->name);
                free(conf);
        }
-       filter->conf = NULL;
+       fconf->conf = NULL;
 }
 
 /* Check configuration of a trace filter for a specified proxy.
  * Return 1 on error, else 0. */
 static int
-trace_check(struct proxy *px, struct filter *filter)
+trace_check(struct proxy *px, struct flt_conf *fconf)
 {
        return 0;
 }
@@ -114,7 +114,7 @@ trace_check(struct proxy *px, struct filter *filter)
 static int
 trace_stream_start(struct stream *s, struct filter *filter)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s",
                   __FUNCTION__);
@@ -125,7 +125,7 @@ trace_stream_start(struct stream *s, struct filter *filter)
 static void
 trace_stream_stop(struct stream *s, struct filter *filter)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s",
                   __FUNCTION__);
@@ -139,7 +139,7 @@ static int
 trace_chn_start_analyze(struct stream *s, struct filter *filter,
                        struct channel *chn)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
                   __FUNCTION__,
@@ -153,7 +153,7 @@ static int
 trace_chn_analyze(struct stream *s, struct filter *filter,
                  struct channel *chn, unsigned an_bit)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
        char                *ana;
 
        switch (an_bit) {
@@ -236,7 +236,7 @@ static int
 trace_chn_end_analyze(struct stream *s, struct filter *filter,
                      struct channel *chn)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
                   __FUNCTION__,
@@ -251,7 +251,7 @@ static int
 trace_http_data(struct stream *s, struct filter *filter,
                      struct http_msg *msg)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
        int avail = MIN(msg->chunk_len + msg->next, msg->chn->buf->i) - FLT_NXT(filter, msg->chn);
        int ret   = avail;
 
@@ -273,7 +273,7 @@ static int
 trace_http_chunk_trailers(struct stream *s, struct filter *filter,
                          struct http_msg *msg)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
                   __FUNCTION__,
@@ -285,7 +285,7 @@ static int
 trace_http_end(struct stream *s, struct filter *filter,
               struct http_msg *msg)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
                   __FUNCTION__,
@@ -297,7 +297,7 @@ static void
 trace_http_reset(struct stream *s, struct filter *filter,
                 struct http_msg *msg)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
                   __FUNCTION__,
@@ -308,7 +308,7 @@ static void
 trace_http_reply(struct stream *s, struct filter *filter, short status,
                 const struct chunk *msg)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
 
        STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s)",
                   __FUNCTION__, "-", proxy_mode(s), stream_pos(s));
@@ -318,7 +318,7 @@ static int
 trace_http_forward_data(struct stream *s, struct filter *filter,
                        struct http_msg *msg, unsigned int len)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
        int                  ret  = len;
 
        if (ret && conf->rand_forwarding)
@@ -342,7 +342,7 @@ trace_http_forward_data(struct stream *s, struct filter *filter,
 static int
 trace_tcp_data(struct stream *s, struct filter *filter, struct channel *chn)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
        int                  avail = chn->buf->i - FLT_NXT(filter, chn);
        int                  ret  = avail;
 
@@ -363,7 +363,7 @@ static int
 trace_tcp_forward_data(struct stream *s, struct filter *filter, struct channel *chn,
                 unsigned int len)
 {
-       struct trace_config *conf = filter->conf;
+       struct trace_config *conf = FLT_CONF(filter);
        int                  ret  = len;
 
        if (ret && conf->rand_forwarding)
@@ -414,7 +414,7 @@ struct flt_ops trace_ops = {
 /* Return -1 on error, else 0 */
 static int
 parse_trace_flt(char **args, int *cur_arg, struct proxy *px,
-               struct filter *filter, char **err)
+               struct flt_conf *fconf, char **err)
 {
        struct trace_config *conf;
        int                  pos = *cur_arg;
@@ -452,10 +452,10 @@ parse_trace_flt(char **args, int *cur_arg, struct proxy *px,
                        pos++;
                }
                *cur_arg = pos;
-               filter->ops  = &trace_ops;
+               fconf->ops  = &trace_ops;
        }
 
-       filter->conf = conf;
+       fconf->conf = conf;
        return 0;
 
  error:
index 1c92e91f8d58c3297cff4dc0acd9bdeeefc0cc7b..5fb5b931710e650984adc6028141a41211da2cf9 100644 (file)
@@ -748,7 +748,7 @@ void init_new_proxy(struct proxy *p)
        LIST_INIT(&p->conf.listeners);
        LIST_INIT(&p->conf.args.list);
        LIST_INIT(&p->tcpcheck_rules);
-       LIST_INIT(&p->filters);
+       LIST_INIT(&p->filter_configs);
 
        /* Timeouts are defined as -1 */
        proxy_reset_timeouts(p);