]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic-be: helper quic_reuse_srv_params() function to reuse server params (0...
authorFrederic Lecaille <flecaille@haproxy.com>
Thu, 31 Jul 2025 13:47:03 +0000 (15:47 +0200)
committerFrederic Lecaille <flecaille@haproxy.com>
Mon, 4 Aug 2025 16:48:09 +0000 (18:48 +0200)
Implement quic_reuse_srv_params() whose role it to reuse the ALPN used
from a first connection to a QUIC backend alongside its transport parameters
from a null terminated string <alpn> and a quic_early_transport_params struct
passed as parameters.

include/haproxy/quic_conn.h
src/quic_conn.c

index 599153ab06800af5e15c6780037867c973b1afd6..b6d2c317c534196b9367f0dce0a356ce21eb0453 100644 (file)
@@ -82,6 +82,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);
 
 /* Free the CIDs attached to <conn> QUIC connection. */
 static inline void free_quic_conn_cids(struct quic_conn *conn)
index 4beee74dc29911759bda7d937f425486d682b246..4acb384662b2953b90b53ff167591001e75ccc96 100644 (file)
@@ -285,6 +285,30 @@ int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alp
        return 1;
 }
 
+/* Try to reuse <alpn> ALPN and <etps> 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 <qc> if the MUX has been released
  * and all STREAM data are acknowledged. The MUX is responsible to have set
  * <qc.err> before as it is reused for the CONNECTION_CLOSE frame.