QUIC APL: Provide the QUIC_CHANNEL with a currently unused QUIC_PORT
authorHugo Landau <hlandau@openssl.org>
Thu, 9 Nov 2023 10:27:13 +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)

ssl/quic/quic_impl.c
ssl/quic/quic_local.h

index 399d1d2afd15e468b8c6044db6e056aca7be3d58..adc954cafe80231943b3779820366e02e762c3a3 100644 (file)
@@ -15,6 +15,7 @@
 #include "internal/quic_tls.h"
 #include "internal/quic_rx_depack.h"
 #include "internal/quic_error.h"
+#include "internal/quic_port.h"
 #include "internal/time.h"
 
 typedef struct qctx_st QCTX;
@@ -543,6 +544,7 @@ void ossl_quic_free(SSL *s)
 #endif
 
     ossl_quic_channel_free(ctx.qc->ch);
+    ossl_quic_port_free(ctx.qc->port);
 
     BIO_free_all(ctx.qc->net_rbio);
     BIO_free_all(ctx.qc->net_wbio);
@@ -1487,19 +1489,34 @@ static int configure_channel(QUIC_CONNECTION *qc)
 QUIC_NEEDS_LOCK
 static int create_channel(QUIC_CONNECTION *qc)
 {
-    QUIC_CHANNEL_ARGS args = {0};
+    QUIC_PORT_ARGS port_args = {0};
+    QUIC_CHANNEL_ARGS ch_args = {0};
 
-    args.libctx     = qc->ssl.ctx->libctx;
-    args.propq      = qc->ssl.ctx->propq;
-    args.is_server  = qc->as_server;
-    args.tls        = qc->tls;
-    args.mutex      = qc->mutex;
-    args.now_cb     = get_time_cb;
-    args.now_cb_arg = qc;
+    port_args.libctx        = qc->ssl.ctx->libctx;
+    port_args.propq         = qc->ssl.ctx->propq;
+    port_args.mutex         = qc->mutex;
+    port_args.now_cb        = get_time_cb;
+    port_args.now_cb_arg    = qc;
 
-    qc->ch = ossl_quic_channel_new(&args);
+    qc->port = ossl_quic_port_new(&port_args);
+    if (qc->port == NULL) {
+        QUIC_RAISE_NON_NORMAL_ERROR(NULL, ERR_R_INTERNAL_ERROR, NULL);
+        return 0;
+    }
+
+    ch_args.port       = qc->port;
+    ch_args.libctx     = qc->ssl.ctx->libctx;
+    ch_args.propq      = qc->ssl.ctx->propq;
+    ch_args.is_server  = qc->as_server;
+    ch_args.tls        = qc->tls;
+    ch_args.mutex      = qc->mutex;
+    ch_args.now_cb     = get_time_cb;
+    ch_args.now_cb_arg = qc;
+
+    qc->ch = ossl_quic_channel_new(&ch_args);
     if (qc->ch == NULL) {
         QUIC_RAISE_NON_NORMAL_ERROR(NULL, ERR_R_INTERNAL_ERROR, NULL);
+        ossl_quic_port_free(qc->port);
         return 0;
     }
 
index 928ae4c6bf3f90c2889c9ed41a438f9aafefb738..ef074daf713b8b97bbcf3feb57b3b18061570800 100644 (file)
@@ -118,6 +118,9 @@ struct quic_conn_st {
 
     SSL                             *tls;
 
+    /* The QUIC port representing the QUIC listener and socket. */
+    QUIC_PORT                       *port;
+
     /*
      * The QUIC channel providing the core QUIC connection implementation. Note
      * that this is not instantiated until we actually start trying to do the