From 41e40eb431676dd99c88398c5742442dcb4791fe Mon Sep 17 00:00:00 2001 From: Frederic Lecaille Date: Thu, 31 Jul 2025 15:47:03 +0200 Subject: [PATCH] MINOR: quic-be: helper quic_reuse_srv_params() function to reuse server params (0-RTT) Implement quic_reuse_srv_params() whose role is to reuse the ALPN negotiated during a first connection to a QUIC backend alongside its transport parameters. --- include/haproxy/quic_conn.h | 3 +++ src/quic_conn.c | 24 ++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/include/haproxy/quic_conn.h b/include/haproxy/quic_conn.h index 2fcb81dcd..c2dfa9df0 100644 --- a/include/haproxy/quic_conn.h +++ b/include/haproxy/quic_conn.h @@ -81,6 +81,9 @@ void qc_idle_timer_rearm(struct quic_conn *qc, int read, int arm_ack); void qc_check_close_on_released_mux(struct quic_conn *qc); int quic_stateless_reset_token_cpy(unsigned char *pos, size_t len, const unsigned char *salt, size_t saltlen); +int quic_reuse_srv_params(struct quic_conn *qc, + const unsigned char *alpn, + const struct quic_early_transport_params *etps); /* Returns true if is used on the backed side (as a client). */ static inline int qc_is_back(const struct quic_conn *qc) diff --git a/src/quic_conn.c b/src/quic_conn.c index 83ee33bdc..59176f396 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -284,6 +284,30 @@ int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alp return 1; } +/* Try to reuse ALPN and early transport parameters. + * Return 1 if succeeded, 0 if not. + */ +int quic_reuse_srv_params(struct quic_conn *qc, + const unsigned char *alpn, + const struct quic_early_transport_params *etps) +{ + int ret = 0; + + TRACE_ENTER(QUIC_EV_CONN_NEW, qc); + + if (!alpn || !quic_set_app_ops(qc, alpn, strlen((char *)alpn))) + goto err; + + qc_early_transport_params_reuse(qc, &qc->tx.params, etps); + ret = 1; + leave: + TRACE_LEAVE(QUIC_EV_CONN_NEW, qc); + return ret; + err: + TRACE_DEVEL("leaving on error", QUIC_EV_CONN_NEW, qc); + goto leave; +} + /* Schedule a CONNECTION_CLOSE emission on if the MUX has been released * and all STREAM data are acknowledged. The MUX is responsible to have set * before as it is reused for the CONNECTION_CLOSE frame. -- 2.47.3