Skip to content

Commit

Permalink
QUIC TSERVER: Provide a TSERVER's QUIC_CHANNEL with a currently unuse…
Browse files Browse the repository at this point in the history
…d QUIC_PORT

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #22674)
  • Loading branch information
hlandau committed Dec 21, 2023
1 parent f767101 commit 167e5f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 4 additions & 0 deletions include/internal/quic_channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
18 changes: 17 additions & 1 deletion ssl/quic/quic_tserver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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. */
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -143,6 +157,7 @@ QUIC_TSERVER *ossl_quic_tserver_new(const QUIC_TSERVER_ARGS *args,
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
Expand All @@ -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);
Expand Down

0 comments on commit 167e5f3

Please sign in to comment.