diff options
author | Hugo Landau <hlandau@openssl.org> | 2023-09-08 12:17:27 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2024-02-02 11:49:34 +0000 |
commit | 2031c0e928f19d2fbdc88d4f5ac4424d700099d9 (patch) | |
tree | 7acc53db3fc6bc40537d13ac41cf107fa2c549f7 /ssl | |
parent | 00b27f33e6a2b7f5270f3a3e6edf69121a4dc209 (diff) |
QLOG: Wiring: QUIC CHANNEL
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22037)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_channel.c | 40 | ||||
-rw-r--r-- | ssl/quic/quic_channel_local.h | 6 | ||||
-rw-r--r-- | ssl/quic/quic_impl.c | 3 |
3 files changed, 49 insertions, 0 deletions
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c index b5f019f40e..eb731f2c53 100644 --- a/ssl/quic/quic_channel.c +++ b/ssl/quic/quic_channel.c @@ -103,6 +103,36 @@ static void ch_raise_version_neg_failure(QUIC_CHANNEL *ch); DEFINE_LHASH_OF_EX(QUIC_SRT_ELEM); +QUIC_NEEDS_LOCK +static QLOG *ch_get_qlog(QUIC_CHANNEL *ch) +{ +#ifndef OPENSSL_NO_QLOG + QLOG_TRACE_INFO qti = {0}; + + if (ch->qlog != NULL) + return ch->qlog; + + if (!ch->use_qlog) + return NULL; + + qti.odcid = ch->init_dcid; + qti.title = NULL; + qti.description = NULL; + qti.group_id = NULL; + qti.is_server = ch->is_server; + qti.now_cb = get_time; + qti.now_cb_arg = ch; + if ((ch->qlog = ossl_qlog_new_from_env(&qti)) == NULL) { + ch->use_qlog = 0; /* don't try again */ + return NULL; + } + + return ch->qlog; +#else + return NULL; +#endif +} + /* * QUIC Channel Initialization and Teardown * ======================================== @@ -364,6 +394,13 @@ static void ch_cleanup(QUIC_CHANNEL *ch) ossl_list_ch_remove(&ch->port->channel_list, ch); ch->on_port_list = 0; } + +#ifndef OPENSSL_NO_QLOG + if (ch->qlog != NULL) + ossl_qlog_flush(ch->qlog); /* best effort */ + + ossl_qlog_free(ch->qlog); +#endif } QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args) @@ -378,6 +415,9 @@ QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args) ch->tls = args->tls; ch->lcidm = args->lcidm; ch->srtm = args->srtm; +#ifndef OPENSSL_NO_QLOG + ch->use_qlog = args->use_qlog; +#endif if (!ch_init(ch)) { OPENSSL_free(ch); diff --git a/ssl/quic/quic_channel_local.h b/ssl/quic/quic_channel_local.h index cd9fe276a5..2a31848158 100644 --- a/ssl/quic/quic_channel_local.h +++ b/ssl/quic/quic_channel_local.h @@ -49,6 +49,9 @@ struct quic_channel_st { /* SRTM we register SRTs with. */ QUIC_SRTM *srtm; + /* Optional QLOG instance (or NULL). */ + QLOG *qlog; + /* * The transport parameter block we will send or have sent. * Freed after sending or when connection is freed. @@ -425,6 +428,9 @@ struct quic_channel_st { /* Are we on the QUIC_PORT linked list of channels? */ unsigned int on_port_list : 1; + /* Has QLOG been requested? */ + unsigned int use_qlog : 1; + /* Saved error stack in case permanent error was encountered */ ERR_STATE *err_state; diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index c7f35aba29..1248013a4b 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -1508,6 +1508,9 @@ static int create_channel(QUIC_CONNECTION *qc) QUIC_RAISE_NON_NORMAL_ERROR(NULL, ERR_R_INTERNAL_ERROR, NULL); return 0; } +#ifndef OPENSSL_NO_QLOG + args.use_qlog = 1; /* disabled if env not set */ +#endif port_args.channel_ctx = qc->ssl.ctx; qc->port = ossl_quic_engine_create_port(qc->engine, &port_args); |