From 2bf091e9da5feff725904e6a567be2284ec2a8bd Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Wed, 11 Feb 2026 14:43:58 +0100 Subject: [PATCH] MINOR: stconn: stream instantiation from proxy callback Add a pointer to function to proxies as ->stream_new_from_sc proxy struct member to instantiate stream from connection as this is done by all the muxes when they call sc_new_from_endp(). The default value for this pointer is obviously stream_new() which is exported by this patch. --- include/haproxy/proxy-t.h | 1 + include/haproxy/stream.h | 2 +- src/proxy.c | 2 ++ src/stconn.c | 2 +- src/stream.c | 2 +- 5 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/haproxy/proxy-t.h b/include/haproxy/proxy-t.h index 5f58bdb4c..21c9aae4f 100644 --- a/include/haproxy/proxy-t.h +++ b/include/haproxy/proxy-t.h @@ -413,6 +413,7 @@ struct proxy { int redispatch_after; /* number of retries before redispatch */ unsigned down_time; /* total time the proxy was down */ int (*accept)(struct stream *s); /* application layer's accept() */ + void *(*stream_new_from_sc)(struct session *sess, struct stconn *sc, struct buffer *in); /* stream instantiation callback for mux stream connector */ struct conn_src conn_src; /* connection source settings */ enum obj_type *default_target; /* default target to use for accepted streams or NULL */ struct proxy *next; diff --git a/include/haproxy/stream.h b/include/haproxy/stream.h index 78d828fb2..46464f860 100644 --- a/include/haproxy/stream.h +++ b/include/haproxy/stream.h @@ -59,7 +59,7 @@ extern struct pool_head *pool_head_uniqueid; extern struct data_cb sess_conn_cb; -struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer *input); +void *stream_new(struct session *sess, struct stconn *sc, struct buffer *input); void stream_free(struct stream *s); int stream_upgrade_from_sc(struct stconn *sc, struct buffer *input); int stream_set_http_mode(struct stream *s, const struct mux_proto_list *mux_proto); diff --git a/src/proxy.c b/src/proxy.c index 778c9d9e4..21de08acf 100644 --- a/src/proxy.c +++ b/src/proxy.c @@ -1578,6 +1578,7 @@ void init_new_proxy(struct proxy *p) /* Default to only allow L4 retries */ p->retry_type = PR_RE_CONN_FAILED; + p->stream_new_from_sc = stream_new; guid_init(&p->guid); p->extra_counters_fe = NULL; @@ -3343,6 +3344,7 @@ static int proxy_defproxy_cpy(struct proxy *curproxy, const struct proxy *defpro curproxy->clitcpka_cnt = defproxy->clitcpka_cnt; curproxy->clitcpka_idle = defproxy->clitcpka_idle; curproxy->clitcpka_intvl = defproxy->clitcpka_intvl; + curproxy->stream_new_from_sc = defproxy->stream_new_from_sc; } if (curproxy->cap & PR_CAP_BE) { diff --git a/src/stconn.c b/src/stconn.c index 770722d13..3f0c264af 100644 --- a/src/stconn.c +++ b/src/stconn.c @@ -244,7 +244,7 @@ struct stconn *sc_new_from_endp(struct sedesc *sd, struct session *sess, struct sc = sc_new(sd); if (unlikely(!sc)) return NULL; - if (unlikely(!stream_new(sess, sc, input))) { + if (unlikely(!sess->fe->stream_new_from_sc(sess, sc, input))) { sd->sc = NULL; if (sc->sedesc != sd) { /* none was provided so sc_new() allocated one */ diff --git a/src/stream.c b/src/stream.c index 63cbade0a..b2eef9187 100644 --- a/src/stream.c +++ b/src/stream.c @@ -344,7 +344,7 @@ int stream_buf_available(void *arg) * transfer to the stream and is set to BUF_NULL. On error, * buffer is unchanged and it is the caller responsibility to release it. */ -struct stream *stream_new(struct session *sess, struct stconn *sc, struct buffer *input) +void *stream_new(struct session *sess, struct stconn *sc, struct buffer *input) { struct stream *s; struct task *t; -- 2.47.3