From 98ed11b0c5a8b92d2cfd876ca31e9fa6c4f5a9df Mon Sep 17 00:00:00 2001 From: Amaury Denoyelle Date: Thu, 23 May 2024 15:06:52 +0200 Subject: [PATCH] BUG/MINOR: rhttp: initialize session origin after preconnect reversal Since the following commit, session is initialized early for rhttp preconnect. 12c40c25a9520fe3365950184fe724a1f4e91d03 MEDIUM: rhttp: create session for active preconnect Session origin member was not set. However, this prevents several session fetches to not work as expected. Worst, this caused a regression as previously session was created after reversal with origin member defined. This was reported by user William Manley on the mailing-list which rely on set-dst. One possible fix would be to set origin on session_new(). However, as this is done before reversal, some session members may be incorrectly initialized, in particular source and destination address. Thus, session origin is only set after reversal is completed. This ensures that session fetches have the same behavior on standard connections and reversable ones. This does not need to be backported. --- src/connection.c | 3 +++ src/proto_rhttp.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/src/connection.c b/src/connection.c index d186c2f01..3fedad9a5 100644 --- a/src/connection.c +++ b/src/connection.c @@ -2798,6 +2798,9 @@ int conn_reverse(struct connection *conn) conn->target = &l->obj_type; conn->flags |= CO_FL_ACT_REVERSING; task_wakeup(l->rx.rhttp.task, TASK_WOKEN_RES); + + /* Initialize session origin after reversal. Mandatory for several fetches. */ + sess->origin = &conn->obj_type; } /* Invert source and destination addresses if already set. */ diff --git a/src/proto_rhttp.c b/src/proto_rhttp.c index 9bf02157c..a6fc95574 100644 --- a/src/proto_rhttp.c +++ b/src/proto_rhttp.c @@ -62,6 +62,9 @@ static struct connection *new_reverse_conn(struct listener *l, struct server *sr HA_ATOMIC_INC(&th_ctx->nb_rhttp_conns); + /* session origin is only set after reversal. This ensures fetches + * will be functional only after reversal, in particular src/dst. + */ sess = session_new(l->bind_conf->frontend, l, NULL); if (!sess) goto err;