From: Hugo Landau Date: Mon, 5 Feb 2024 16:31:23 +0000 (+0000) Subject: QUIC PORT: Allow QUIC_PORT to throw away incoming connections X-Git-Tag: openssl-3.5.0-alpha1~445 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=99e4a1e3ce4713d8cc373de949e93490f3f39865;p=thirdparty%2Fopenssl.git QUIC PORT: Allow QUIC_PORT to throw away incoming connections Reviewed-by: Matt Caswell Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/23334) --- diff --git a/include/internal/quic_port.h b/include/internal/quic_port.h index eb060581e01..1f8997a1591 100644 --- a/include/internal/quic_port.h +++ b/include/internal/quic_port.h @@ -82,6 +82,11 @@ QUIC_CHANNEL *ossl_quic_port_create_incoming(QUIC_PORT *port, SSL *tls); */ QUIC_CHANNEL *ossl_quic_port_pop_incoming(QUIC_PORT *port); +/* + * Delete any channels which are pending acceptance. + */ +void ossl_quic_port_drop_incoming(QUIC_PORT *port); + /* * Queries and Accessors * ===================== diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 214227b8a74..6562a70492d 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -565,6 +565,7 @@ QUIC_TAKES_LOCK static void quic_free_listener(QCTX *ctx) { quic_unref_port_bios(ctx->ql->port); + ossl_quic_port_drop_incoming(ctx->ql->port); ossl_quic_port_free(ctx->ql->port); ossl_quic_engine_free(ctx->ql->engine); ossl_crypto_mutex_free(&ctx->ql->mutex); diff --git a/ssl/quic/quic_port.c b/ssl/quic/quic_port.c index f9e195902de..a33a7a33799 100644 --- a/ssl/quic/quic_port.c +++ b/ssl/quic/quic_port.c @@ -440,6 +440,22 @@ QUIC_CHANNEL *ossl_quic_port_pop_incoming(QUIC_PORT *port) return ch; } +void ossl_quic_port_drop_incoming(QUIC_PORT *port) +{ + QUIC_CHANNEL *ch; + SSL *tls; + + for (;;) { + ch = ossl_quic_port_pop_incoming(port); + if (ch == NULL) + break; + + tls = ossl_quic_channel_get0_tls(ch); + ossl_quic_channel_free(ch); + SSL_free(tls); + } +} + void ossl_quic_port_set_allow_incoming(QUIC_PORT *port, int allow_incoming) { port->allow_incoming = allow_incoming;