]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MEDIUM: spoe: Set a specific name for the connection pool of SPOP servers
authorChristopher Faulet <cfaulet@haproxy.com>
Fri, 5 Jul 2024 13:27:23 +0000 (15:27 +0200)
committerChristopher Faulet <cfaulet@haproxy.com>
Fri, 12 Jul 2024 13:27:05 +0000 (15:27 +0200)
With this patch, we force the connection pool name of SPOP server to the
SPOE engine identifier. This way, SPOP idle connections cannot be shared
between diffrente engines.

The related issue is #2502.

src/flt_spoe.c

index c31bfb1924cec841a64f051fe5fbd91c9ecf0d1d..d91002730f5896b1e3b77daab8eca06ef723d189 100644 (file)
@@ -3009,6 +3009,37 @@ static int smp_fetch_spoe_engine_id(const struct arg *args, struct sample *smp,
        return 1;
 }
 
+static int spoe_postcheck_spop_proxy(struct proxy *px)
+{
+       struct server *srv;
+       int err_code = ERR_NONE;
+
+       if (!(px->cap & PR_CAP_BE) || px->mode != PR_MODE_SPOP)
+               goto out;
+
+       for (srv = px->srv; srv; srv = srv->next) {
+               if (srv->pool_conn_name) {
+                       ha_free(&srv->pool_conn_name);
+                       release_sample_expr(srv->pool_conn_name_expr);
+               }
+               srv->pool_conn_name = strdup("spoe.engine-id");
+               if (!srv->pool_conn_name) {
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+               srv->pool_conn_name_expr = _parse_srv_expr(srv->pool_conn_name, &px->conf.args, NULL, 0, NULL);
+               if (!srv->pool_conn_name_expr) {
+                       err_code |= ERR_ALERT | ERR_FATAL;
+                       goto out;
+               }
+       }
+
+  out:
+       return err_code;
+}
+
+REGISTER_POST_PROXY_CHECK(spoe_postcheck_spop_proxy);
+
 /* Declare the filter parser for "spoe" keyword */
 static struct flt_kw_list flt_kws = { "SPOE", { }, {
                { "spoe", parse_spoe_flt, NULL },