Skip to content

Commit

Permalink
QUIC PORT: Keep a list of all child channels
Browse files Browse the repository at this point in the history
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from #22674)
  • Loading branch information
hlandau committed Dec 21, 2023
1 parent f98bc5c commit ce503f5
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 9 additions & 0 deletions ssl/quic/quic_channel_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ DEFINE_LIST_OF(stateless_reset_tokens, QUIC_SRT_ELEM);
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
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 3 additions & 0 deletions ssl/quic/quic_port.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -82,6 +84,7 @@ static int port_init(QUIC_PORT *port)

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;
}
Expand Down
6 changes: 6 additions & 0 deletions ssl/quic/quic_port_local.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# include "internal/quic_port.h"
# include "internal/quic_reactor.h"
# include "internal/list.h"

# ifndef OPENSSL_NO_QUIC

Expand All @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit ce503f5

Please sign in to comment.