summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-11-09 11:27:13 +0100
committerHugo Landau <hlandau@openssl.org>2023-12-21 09:11:59 +0100
commitce503f5c85bff7521eefa023d6f865fd2074de37 (patch)
tree16741b3c2b5a603101b3b955861ceb0629358159
parentQUIC CHANNEL, PORT: Abstract time retrieval (diff)
downloadopenssl-ce503f5c85bff7521eefa023d6f865fd2074de37.tar.xz
openssl-ce503f5c85bff7521eefa023d6f865fd2074de37.zip
QUIC PORT: Keep a list of all child channels
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/22674)
-rw-r--r--ssl/quic/quic_channel.c8
-rw-r--r--ssl/quic/quic_channel_local.h9
-rw-r--r--ssl/quic/quic_port.c3
-rw-r--r--ssl/quic/quic_port_local.h6
4 files changed, 26 insertions, 0 deletions
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c
index 02ef845496..1ea69584c5 100644
--- a/ssl/quic/quic_channel.c
+++ b/ssl/quic/quic_channel.c
@@ -46,6 +46,8 @@
*/
#define DEFAULT_MAX_ACK_DELAY QUIC_DEFAULT_MAX_ACK_DELAY
+DEFINE_LIST_OF_IMPL(ch, QUIC_CHANNEL);
+
static void ch_save_err_state(QUIC_CHANNEL *ch);
static void ch_rx_pre(QUIC_CHANNEL *ch);
static int ch_rx(QUIC_CHANNEL *ch, int channel_only);
@@ -486,6 +488,8 @@ static int ch_init(QUIC_CHANNEL *ch)
ch_update_idle(ch);
ossl_quic_reactor_init(&ch->rtor, ch_tick, ch,
ch_determine_next_tick_deadline(ch));
+ ossl_list_ch_insert_tail(&ch->port->channel_list, ch);
+ ch->on_port_list = 1;
return 1;
err:
@@ -543,6 +547,10 @@ static void ch_cleanup(QUIC_CHANNEL *ch)
OPENSSL_free(srte);
}
lh_QUIC_SRT_ELEM_free(ch->srt_hash_tok);
+ if (ch->on_port_list) {
+ ossl_list_ch_remove(&ch->port->channel_list, ch);
+ ch->on_port_list = 0;
+ }
}
QUIC_CHANNEL *ossl_quic_channel_new(const QUIC_CHANNEL_ARGS *args)
diff --git a/ssl/quic/quic_channel_local.h b/ssl/quic/quic_channel_local.h
index af35a6326b..37cf73c67a 100644
--- a/ssl/quic/quic_channel_local.h
+++ b/ssl/quic/quic_channel_local.h
@@ -39,6 +39,12 @@ struct quic_channel_st {
QUIC_PORT *port;
/*
+ * QUIC_PORT keeps the channels which belong to it on a list for bookkeeping
+ * purposes.
+ */
+ OSSL_LIST_MEMBER(ch, struct quic_channel_st);
+
+ /*
* The associated TLS 1.3 connection data. Used to provide the handshake
* layer; its 'network' side is plugged into the crypto stream for each EL
* (other than the 0-RTT EL).
@@ -449,6 +455,9 @@ struct quic_channel_st {
/* Are we using addressed mode? */
unsigned int addressed_mode : 1;
+ /* Are we on the QUIC_PORT linked list of channels? */
+ unsigned int on_port_list : 1;
+
/* Saved error stack in case permanent error was encountered */
ERR_STATE *err_state;
diff --git a/ssl/quic/quic_port.c b/ssl/quic/quic_port.c
index 0beb69835b..8b727d2f12 100644
--- a/ssl/quic/quic_port.c
+++ b/ssl/quic/quic_port.c
@@ -23,6 +23,8 @@ static OSSL_TIME get_time(void *arg);
static void port_tick(QUIC_TICK_RESULT *res, void *arg, uint32_t flags);
//static void port_default_packet_handler(QUIC_URXE *e, void *arg);
+DEFINE_LIST_OF_IMPL(ch, QUIC_CHANNEL);
+
QUIC_PORT *ossl_quic_port_new(const QUIC_PORT_ARGS *args)
{
QUIC_PORT *port;
@@ -82,6 +84,7 @@ err:
static void port_cleanup(QUIC_PORT *port)
{
+ assert(ossl_list_ch_num(&port->channel_list) == 0);
ossl_quic_demux_free(port->demux);
port->demux = NULL;
}
diff --git a/ssl/quic/quic_port_local.h b/ssl/quic/quic_port_local.h
index 60216bb1b5..7aaf4d6a42 100644
--- a/ssl/quic/quic_port_local.h
+++ b/ssl/quic/quic_port_local.h
@@ -3,6 +3,7 @@
# include "internal/quic_port.h"
# include "internal/quic_reactor.h"
+# include "internal/list.h"
# ifndef OPENSSL_NO_QUIC
@@ -15,6 +16,8 @@
*
* Other components should not include this header.
*/
+DECLARE_LIST_OF(ch, QUIC_CHANNEL);
+
struct quic_port_st {
OSSL_LIB_CTX *libctx;
const char *propq;
@@ -39,6 +42,9 @@ struct quic_port_st {
/* RX demuxer. We register incoming DCIDs with this. */
QUIC_DEMUX *demux;
+
+ /* List of all child channels. */
+ OSSL_LIST(ch) channel_list;
};
# endif