From: Hugo Landau Date: Thu, 9 Nov 2023 10:27:13 +0000 (+0000) Subject: QUIC TSERVER: Provide a TSERVER's QUIC_CHANNEL with a currently unused QUIC_PORT X-Git-Tag: openssl-3.3.0-alpha1~442 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=167e5f34c8f4e7c414c6e48376987160bc23c7df;p=thirdparty%2Fopenssl.git QUIC TSERVER: Provide a TSERVER's QUIC_CHANNEL with a currently unused QUIC_PORT Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/22674) --- diff --git a/include/internal/quic_channel.h b/include/internal/quic_channel.h index d4f3018cc47..f4bee6bf468 100644 --- a/include/internal/quic_channel.h +++ b/include/internal/quic_channel.h @@ -106,6 +106,10 @@ # define QUIC_CHANNEL_STATE_TERMINATED 4 typedef struct quic_channel_args_st { + /* + * The QUIC_PORT which the channel is to belong to. The lifetime of the + * QUIC_PORT must exceed that of the created channel. + */ QUIC_PORT *port; OSSL_LIB_CTX *libctx; diff --git a/ssl/quic/quic_tserver.c b/ssl/quic/quic_tserver.c index 130733821cf..e5cc31ba821 100644 --- a/ssl/quic/quic_tserver.c +++ b/ssl/quic/quic_tserver.c @@ -10,6 +10,7 @@ #include "internal/quic_tserver.h" #include "internal/quic_channel.h" #include "internal/quic_statm.h" +#include "internal/quic_port.h" #include "internal/common.h" #include "internal/time.h" #include "quic_local.h" @@ -25,8 +26,10 @@ struct quic_tserver_st { SSL *ssl; /* - * The QUIC channel providing the core QUIC connection implementation. + * The QUIC port and channel providing the core QUIC connection + * implementation. */ + QUIC_PORT *port; QUIC_CHANNEL *ch; /* The mutex we give to the QUIC channel. */ @@ -75,6 +78,7 @@ QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args, const char *certfile, const char *keyfile) { QUIC_TSERVER *srv = NULL; + QUIC_PORT_ARGS port_args = {0}; QUIC_CHANNEL_ARGS ch_args = {0}; QUIC_CONNECTION *qc = NULL; @@ -113,6 +117,16 @@ QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args, if (srv->tls == NULL) goto err; + port_args.libctx = srv->args.libctx; + port_args.propq = srv->args.propq; + port_args.mutex = srv->mutex; + port_args.now_cb = srv->args.now_cb; + port_args.now_cb_arg = srv->args.now_cb_arg; + + if ((srv->port = ossl_quic_port_new(&port_args)) == NULL) + goto err; + + ch_args.port = srv->port; ch_args.libctx = srv->args.libctx; ch_args.propq = srv->args.propq; ch_args.tls = srv->tls; @@ -143,6 +157,7 @@ err: SSL_CTX_free(srv->ctx); SSL_free(srv->tls); ossl_quic_channel_free(srv->ch); + ossl_quic_port_free(srv->port); #if defined(OPENSSL_THREADS) ossl_crypto_mutex_free(&srv->mutex); #endif @@ -159,6 +174,7 @@ void ossl_quic_tserver_free(QUIC_TSERVER *srv) return; ossl_quic_channel_free(srv->ch); + ossl_quic_port_free(srv->port); BIO_free_all(srv->args.net_rbio); BIO_free_all(srv->args.net_wbio); OPENSSL_free(srv->ssl);