From: Frederic Lecaille Date: Tue, 19 Dec 2023 06:58:48 +0000 (+0100) Subject: MINOR: quic-be: xprt ->init() adapatations X-Git-Tag: v3.3-dev2~97 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f7c0f5ac1be807dc80c4c69f51c7f586dc20194d;p=thirdparty%2Fhaproxy.git MINOR: quic-be: xprt ->init() adapatations 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. --- diff --git a/src/quic_conn.c b/src/quic_conn.c index 47cf5ad19..d99a59d0e 100644 --- a/src/quic_conn.c +++ b/src/quic_conn.c @@ -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; diff --git a/src/xprt_quic.c b/src/xprt_quic.c index dcca43509..1575f3645 100644 --- a/src/xprt_quic.c +++ b/src/xprt_quic.c @@ -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,