QLOG: QUIC CHANNEL: Allow a log title to be specified
authorHugo Landau <hlandau@openssl.org>
Fri, 8 Sep 2023 12:37:18 +0000 (13:37 +0100)
committerHugo Landau <hlandau@openssl.org>
Fri, 2 Feb 2024 11:49:34 +0000 (11:49 +0000)
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22037)

include/internal/quic_channel.h
ssl/quic/quic_channel.c
ssl/quic/quic_channel_local.h

index 20d2ca86c427e3625249b6136d271574c3f54f55..aafdeca3d2a8ccb3eb8983920c1135995c03e4ed 100644 (file)
@@ -122,6 +122,9 @@ typedef struct quic_channel_args_st {
 
     /* Whether to use QLOG. */
     int             use_qlog;
+
+    /* Title to use for the QLOG session, or NULL. */
+    const char      *qlog_title;
 } QUIC_CHANNEL_ARGS;
 
 /* Represents the cause for a connection's termination. */
index 2b1838bb912b994f17776a51cb7212d0f65f048f..0311e9a7120a31c22478637545270a5a1b88a2d0 100644 (file)
@@ -118,7 +118,7 @@ static QLOG *ch_get_qlog(QUIC_CHANNEL *ch)
         return NULL;
 
     qti.odcid       = ch->init_dcid;
-    qti.title       = NULL;
+    qti.title       = ch->qlog_title;
     qti.description = NULL;
     qti.group_id    = NULL;
     qti.is_server   = ch->is_server;
@@ -402,6 +402,7 @@ static void ch_cleanup(QUIC_CHANNEL *ch)
     if (ch->qlog != NULL)
         ossl_qlog_flush(ch->qlog); /* best effort */
 
+    OPENSSL_free(ch->qlog_title);
     ossl_qlog_free(ch->qlog);
 #endif
 }
@@ -420,6 +421,13 @@ QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args)
     ch->srtm        = args->srtm;
 #ifndef OPENSSL_NO_QLOG
     ch->use_qlog    = args->use_qlog;
+
+    if (ch->use_qlog && args->qlog_title != NULL) {
+        if ((ch->qlog_title = OPENSSL_strdup(args->qlog_title)) == NULL) {
+            OPENSSL_free(ch);
+            return NULL;
+        }
+    }
 #endif
 
     if (!ch_init(ch)) {
index 2a31848158c3063d9f2e74bd83d424b39054144b..4cd4dd84b70cda84d936a9207ba4edb65ad146db 100644 (file)
@@ -437,6 +437,9 @@ struct quic_channel_st {
     /* Scratch area for use by RXDP to store decoded ACK ranges. */
     OSSL_QUIC_ACK_RANGE             *ack_range_scratch;
     size_t                          num_ack_range_scratch;
+
+    /* Title for QLOG purposes. We own this copy. */
+    char                            *quic_channel_local;
 };
 
 # endif