QUIC CHANNEL: Keep a reference to our LCIDM
authorHugo Landau <hlandau@openssl.org>
Thu, 9 Nov 2023 10:27:14 +0000 (10:27 +0000)
committerHugo Landau <hlandau@openssl.org>
Thu, 21 Dec 2023 08:11:59 +0000 (08:11 +0000)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22674)

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

index 91366ec7cc067e747aedcbcace4f89f3f3c81b41..61683aff6c74e79567ddb5141132e5afe657addc 100644 (file)
@@ -111,6 +111,8 @@ typedef struct quic_channel_args_st {
      * QUIC_PORT must exceed that of the created channel.
      */
     QUIC_PORT       *port;
+    /* LCIDM to register LCIDs with. */
+    QUIC_LCIDM      *lcidm;
 
     int             is_server;
     SSL             *tls;
index ebbc3e86a19ae19b3a7ff016a417d1d97cb2a61c..c366a087b78e86c70c88958d0adabb951b1951db 100644 (file)
@@ -12,6 +12,7 @@
 #include "internal/quic_channel.h"
 #include "internal/quic_error.h"
 #include "internal/quic_rx_depack.h"
+#include "internal/quic_lcidm.h"
 #include "../ssl_local.h"
 #include "quic_channel_local.h"
 #include "quic_port_local.h"
@@ -227,7 +228,7 @@ static int ch_init(QUIC_CHANNEL *ch)
     size_t rx_short_dcid_len = ossl_quic_port_get_rx_short_dcid_len(ch->port);
     size_t tx_init_dcid_len = ossl_quic_port_get_tx_init_dcid_len(ch->port);
 
-    if (ch->port == NULL)
+    if (ch->port == NULL || ch->lcidm == NULL)
         goto err;
 
     ossl_list_stateless_reset_tokens_init(&ch->srt_list_seq);
@@ -441,6 +442,7 @@ static void ch_cleanup(QUIC_CHANNEL *ch)
              ++pn_space)
             ossl_ackm_on_pkt_space_discarded(ch->ackm, pn_space);
 
+    ossl_quic_lcidm_cull(ch->lcidm, ch);
     ossl_quic_tx_packetiser_free(ch->txp);
     ossl_quic_txpim_free(ch->txpim);
     ossl_quic_cfq_free(ch->cfq);
@@ -495,6 +497,7 @@ QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args)
     ch->port        = args->port;
     ch->is_server   = args->is_server;
     ch->tls         = args->tls;
+    ch->lcidm       = args->lcidm;
 
     if (!ch_init(ch)) {
         OPENSSL_free(ch);
index dafe03fe8a299146824a93abd5cc4ac649481eb8..8c8688aac2aca09f319db48a6e634641f1bbef9b 100644 (file)
@@ -52,6 +52,9 @@ struct quic_channel_st {
     QUIC_TLS                        *qtls;
     SSL                             *tls;
 
+    /* Port LCIDM we use to register LCIDs. */
+    QUIC_LCIDM                      *lcidm;
+
     /*
      * The transport parameter block we will send or have sent.
      * Freed after sending or when connection is freed.
index b99089e42bc3caa46fc210a2f3b5c2d3a9a00d10..9be20c3f7b65d7103db293f0c21bd88b5d1ca469 100644 (file)
@@ -280,6 +280,7 @@ static QUIC_CHANNEL *port_make_channel(QUIC_PORT *port, SSL *tls, int is_server)
     args.port       = port;
     args.is_server  = is_server;
     args.tls        = (tls != NULL ? tls : port_new_handshake_layer(port));
+    args.lcidm      = port->lcidm;
     if (args.tls == NULL)
         return NULL;