]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: quic-be: xprt ->init() adapatations
authorFrederic Lecaille <flecaille@haproxy.com>
Tue, 19 Dec 2023 06:58:48 +0000 (07:58 +0100)
committerAmaury Denoyelle <adenoyelle@haproxy.com>
Wed, 11 Jun 2025 16:37:34 +0000 (18:37 +0200)
Allocate a connection to connect to QUIC servers from qc_conn_init() which is the
->init() QUIC xprt callback.
Also initialize ->prepare_srv and ->destroy_srv callback as this done for TCP
servers.

src/quic_conn.c
src/xprt_quic.c

index 47cf5ad19b78543364b7467e88fabe7fae16a83d..d99a59d0efb50ce2599fa19964f6a63d437b2bcd 100644 (file)
@@ -1117,7 +1117,7 @@ struct quic_conn *qc_new_conn(const struct quic_version *qv, int ipv4,
        qc->idle_timer_task = NULL;
 
        qc->xprt_ctx = NULL;
-       qc->conn = NULL;
+       qc->conn = conn;
        qc->qcc = NULL;
        qc->app_ops = NULL;
        qc->path = NULL;
index dcca43509523c6afb5ab89c1877f84b37c41e0ee..1575f36455e61c1865560d5cad22b283a4b35051 100644 (file)
@@ -111,10 +111,25 @@ static int quic_conn_unsubscribe(struct connection *conn, void *xprt_ctx, int ev
  */
 static int qc_conn_init(struct connection *conn, void **xprt_ctx)
 {
-       struct quic_conn *qc = conn->handle.qc;
+       int ret = -1;
+       struct quic_conn *qc = NULL;
 
        TRACE_ENTER(QUIC_EV_CONN_NEW, qc);
 
+       if (objt_listener(conn->target)) {
+               qc = conn->handle.qc;
+       }
+       else {
+               int ipv4 = conn->dst->ss_family == AF_INET;
+               struct server *srv = objt_server(conn->target);
+               qc = qc_new_conn(quic_version_1, ipv4, NULL, NULL, NULL,
+                                NULL, NULL, &srv->addr, 0, 0, srv, conn);
+       }
+
+       if (!qc)
+               goto out;
+
+       ret = 0;
        /* Ensure thread connection migration is finalized ASAP. */
        if (qc->flags & QUIC_FL_CONN_TID_REBIND)
                qc_finalize_tid_rebind(qc);
@@ -128,7 +143,7 @@ static int qc_conn_init(struct connection *conn, void **xprt_ctx)
  out:
        TRACE_LEAVE(QUIC_EV_CONN_NEW, qc);
 
-       return 0;
+       return ret;
 }
 
 /* Start the QUIC transport layer */
@@ -178,6 +193,8 @@ static struct xprt_ops ssl_quic = {
        .start    = qc_xprt_start,
        .prepare_bind_conf = ssl_sock_prepare_bind_conf,
        .destroy_bind_conf = ssl_sock_destroy_bind_conf,
+       .prepare_srv = ssl_sock_prepare_srv_ctx,
+       .destroy_srv = ssl_sock_free_srv_ctx,
        .get_alpn = ssl_sock_get_alpn,
        .get_ssl_sock_ctx = qc_get_ssl_sock_ctx,
        .dump_info = qc_xprt_dump_info,