]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: listener: move the analysers mask to the bind_conf
authorWilly Tarreau <w@1wt.eu>
Thu, 12 Jan 2023 17:39:42 +0000 (18:39 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 3 Feb 2023 17:00:20 +0000 (18:00 +0100)
When bind_conf were created, some elements such as the analysers mask
ought to have moved there but that wasn't the case. Now that it's
getting clearer that bind_conf provides all binding parameters and
the listener is essentially a listener on an address, it's starting
to get really confusing to keep such parameters in the listener, so
let's move the mask to the bind_conf. We also take this opportunity
for pre-setting the mask to the frontend's upon initalization. Now
several loops have one less argument to take care of.

include/haproxy/listener-t.h
src/cfgparse.c
src/filters.c
src/listener.c
src/log.c
src/proxy.c
src/stream.c

index c3bc45c2c1e11824fcd1894fcd44e1754bf08938..17f4683225d8d2df545b9bfc5f4bae3815f0477b 100644 (file)
@@ -197,6 +197,7 @@ struct bind_conf {
        const struct mux_proto_list *mux_proto; /* the mux to use for all incoming connections (specified by the "proto" keyword) */
        struct xprt_ops *xprt;     /* transport-layer operations for all listeners */
        uint options;              /* set of BC_O_* flags */
+       unsigned int analysers;    /* bitmap of required protocol analysers */
        int level;                 /* stats access level (ACCESS_LVL_*) */
        int severity_output;       /* default severity output format in cli feedback messages */
        struct list listeners;     /* list of listeners using this bind config */
@@ -246,7 +247,6 @@ struct listener {
        /* cache line boundary */
        struct mt_list wait_queue;      /* link element to make the listener wait for something (LI_LIMITED)  */
        unsigned int thr_idx;           /* thread indexes for queue distribution : (t2<<16)+t1 */
-       unsigned int analysers;         /* bitmap of required protocol analysers */
        int maxseg;                     /* for TCP, advertised MSS */
        int tcp_ut;                     /* for TCP, user timeout */
        char *name;                     /* listener's name */
index 85cefb98d62e6faf1aef381d57944d4b2b9f0b32..cc5c96698ec91a765bd0ffe7ad64b7dd4854284a 100644 (file)
@@ -745,7 +745,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                        l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
                        l->maxaccept = 1;
                        l->accept = session_accept_fd;
-                       l->analysers |=  curpeers->peers_fe->fe_req_ana;
                        l->default_target = curpeers->peers_fe->default_target;
                        l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
                        global.maxsock++; /* for the listening socket */
@@ -970,7 +969,6 @@ int cfg_parse_peers(const char *file, int linenum, char **args, int kwm)
                l = LIST_ELEM(bind_conf->listeners.p, typeof(l), by_bind);
                l->maxaccept = 1;
                l->accept = session_accept_fd;
-               l->analysers |=  curpeers->peers_fe->fe_req_ana;
                l->default_target = curpeers->peers_fe->default_target;
                l->options |= LI_O_UNLIMITED; /* don't make the peers subject to global limits */
                global.maxsock++; /* for the listening socket */
@@ -4285,6 +4283,7 @@ init_proxies_list_stage2:
                        if (bind_conf->xprt->prepare_bind_conf &&
                            bind_conf->xprt->prepare_bind_conf(bind_conf) < 0)
                                cfgerr++;
+                       bind_conf->analysers |= curproxy->fe_req_ana;
                }
 
                /* adjust this proxy's listeners */
@@ -4329,7 +4328,6 @@ init_proxies_list_stage2:
                        }
 #endif
 
-                       listener->analysers |= curproxy->fe_req_ana;
                        listener->default_target = curproxy->default_target;
 
                        if (!LIST_ISEMPTY(&curproxy->tcp_req.l4_rules))
index d91f4a7e9bbb6208830706dcbf1cb6a660f305a6..0b98dcf5b99880a8a5caf3aed48e7354b4ad4fef 100644 (file)
@@ -489,7 +489,7 @@ flt_stream_start(struct stream *s)
                if (FLT_OPS(filter)->stream_start && FLT_OPS(filter)->stream_start(s, filter) < 0)
                        return -1;
        }
-       if (strm_li(s) && (strm_li(s)->analysers & AN_REQ_FLT_START_FE)) {
+       if (strm_li(s) && (strm_li(s)->bind_conf->analysers & AN_REQ_FLT_START_FE)) {
                s->req.flags |= CF_FLT_ANALYZE;
                s->req.analysers |= AN_REQ_FLT_END;
        }
index 4867566a6f549a2c07c30b9063d908dbacef1bb6..717e8784b6040f9b25dc79977164fca6912f1049 100644 (file)
@@ -1436,6 +1436,7 @@ struct bind_conf *bind_conf_alloc(struct proxy *fe, const char *file,
        bind_conf->settings.shards = 1;
        bind_conf->xprt = xprt;
        bind_conf->frontend = fe;
+       bind_conf->analysers = fe->fe_req_ana;
        bind_conf->severity_output = CLI_SEVERITY_NONE;
 #ifdef USE_OPENSSL
        HA_RWLOCK_INIT(&bind_conf->sni_lock);
index fc4cdd9cbac97c70f55a40b8a1d7827c7486a41d..a3475ba2ce43ca0e3d362bccc31cf8d195437f4e 100644 (file)
--- a/src/log.c
+++ b/src/log.c
@@ -3825,7 +3825,6 @@ int cfg_parse_log_forward(const char *file, int linenum, char **args, int kwm)
                list_for_each_entry(l, &bind_conf->listeners, by_bind) {
                        l->maxaccept = global.tune.maxaccept ? global.tune.maxaccept : MAX_ACCEPT;
                        l->accept = session_accept_fd;
-                       l->analysers |=  cfg_log_forward->fe_req_ana;
                        l->default_target = cfg_log_forward->default_target;
                        global.maxsock++;
                }
index 43a35f54633f79b6e4b8f25b6335f635a736063a..a021224d6373208594c488b95c5641a50589305f 100644 (file)
@@ -2425,7 +2425,7 @@ int stream_set_backend(struct stream *s, struct proxy *be)
                 */
                req_ana &= ~(AN_REQ_WAIT_HTTP|AN_REQ_HTTP_PROCESS_FE);
        }
-       s->req.analysers |= req_ana & ~(strm_li(s) ? strm_li(s)->analysers : 0);
+       s->req.analysers |= req_ana & ~(strm_li(s) ? strm_li(s)->bind_conf->analysers : 0);
 
        if (!IS_HTX_STRM(s) && be->mode == PR_MODE_HTTP) {
                /* If we chain a TCP frontend to an HTX backend, we must upgrade
index a4b428cd827e0a7c5534ba8e2a13be2fb7fd7c6f..ce90151bdfb008b874cfa014165b0b8af299b911 100644 (file)
@@ -502,7 +502,7 @@ struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer
 
        channel_init(&s->req);
        s->req.flags |= CF_READ_EVENT; /* the producer is already connected */
-       s->req.analysers = sess->listener ? sess->listener->analysers : sess->fe->fe_req_ana;
+       s->req.analysers = sess->listener ? sess->listener->bind_conf->analysers : sess->fe->fe_req_ana;
 
        if (IS_HTX_STRM(s)) {
                /* Be sure to have HTTP analysers because in case of