From 7866e8e50d13f07c61a36b8d1cd99670f798dfe8 Mon Sep 17 00:00:00 2001 From: Willy Tarreau Date: Thu, 12 Jan 2023 18:39:42 +0100 Subject: [PATCH] MEDIUM: listener: move the analysers mask to the bind_conf 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 | 2 +- src/cfgparse.c | 4 +--- src/filters.c | 2 +- src/listener.c | 1 + src/log.c | 1 - src/proxy.c | 2 +- src/stream.c | 2 +- 7 files changed, 6 insertions(+), 8 deletions(-) diff --git a/include/haproxy/listener-t.h b/include/haproxy/listener-t.h index c3bc45c2c..17f468322 100644 --- a/include/haproxy/listener-t.h +++ b/include/haproxy/listener-t.h @@ -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 */ diff --git a/src/cfgparse.c b/src/cfgparse.c index 85cefb98d..cc5c96698 100644 --- a/src/cfgparse.c +++ b/src/cfgparse.c @@ -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 @@ int check_config_validity() 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 @@ int check_config_validity() } #endif - listener->analysers |= curproxy->fe_req_ana; listener->default_target = curproxy->default_target; if (!LIST_ISEMPTY(&curproxy->tcp_req.l4_rules)) diff --git a/src/filters.c b/src/filters.c index d91f4a7e9..0b98dcf5b 100644 --- a/src/filters.c +++ b/src/filters.c @@ -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; } diff --git a/src/listener.c b/src/listener.c index 4867566a6..717e8784b 100644 --- a/src/listener.c +++ b/src/listener.c @@ -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); diff --git a/src/log.c b/src/log.c index fc4cdd9cb..a3475ba2c 100644 --- 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++; } diff --git a/src/proxy.c b/src/proxy.c index 43a35f546..a021224d6 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -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 diff --git a/src/stream.c b/src/stream.c index a4b428cd8..ce90151bd 100644 --- a/src/stream.c +++ b/src/stream.c @@ -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