From ffbfe3a2d6aaf4e847a1848c29fc8ce2997ed260 Mon Sep 17 00:00:00 2001 From: Aloys Augustin Date: Thu, 5 Sep 2019 17:58:21 +0200 Subject: quic: fix server opening stream immediately Previously, if the first thing a server did was to open a stream and send data, this could trigger a crash on the clilent side VPP as the quic session wouldn't be allocated. Change-Id: I43990ce2a71217d6719ecae4da60111d05fbcfc0 Type: fix Signed-off-by: Aloys Augustin --- src/plugins/quic/quic.c | 21 ++++++++++++++++++--- src/plugins/quic/quic.h | 2 +- 2 files changed, 19 insertions(+), 4 deletions(-) (limited to 'src/plugins/quic') diff --git a/src/plugins/quic/quic.c b/src/plugins/quic/quic.c index 866aaadb6a8..42a839db515 100644 --- a/src/plugins/quic/quic.c +++ b/src/plugins/quic/quic.c @@ -33,6 +33,7 @@ static quic_main_t quic_main; static void quic_update_timer (quic_ctx_t * ctx); +static int quic_on_client_connected (quic_ctx_t * ctx); static u32 quic_ctx_alloc (u32 thread_index) @@ -595,6 +596,22 @@ quic_accept_stream (void *s) qctx = quic_get_conn_ctx (stream->conn); + /* Might need to signal that the connection is ready if the first thing the + * server does is open a stream */ + if (qctx->conn_state == QUIC_CONN_STATE_HANDSHAKE) + { + if (quicly_connection_is_ready (qctx->conn)) + { + qctx->conn_state = QUIC_CONN_STATE_READY; + if (quicly_is_client (qctx->conn)) + { + quic_on_client_connected (qctx); + /* ctx might be invalidated */ + qctx = quic_get_conn_ctx (stream->conn); + } + } + } + stream_session = session_alloc (qctx->c_thread_index); QUIC_DBG (2, "ACCEPTED stream_session 0x%lx ctx %u", session_handle (stream_session), sctx_id); @@ -652,9 +669,7 @@ quic_on_stream_open (quicly_stream_open_t * self, quicly_stream_t * stream) /* Notify accept on parent qsession, but only if this is not a locally * initiated stream */ if (!quicly_stream_is_self_initiated (stream)) - { - quic_accept_stream (stream); - } + quic_accept_stream (stream); return 0; } diff --git a/src/plugins/quic/quic.h b/src/plugins/quic/quic.h index f44bae29c47..5b821d77bae 100644 --- a/src/plugins/quic/quic.h +++ b/src/plugins/quic/quic.h @@ -158,7 +158,7 @@ typedef struct quic_main_ u32 app_index; quic_ctx_t **ctx_pool; quic_worker_ctx_t *wrk_ctx; - clib_bihash_16_8_t connection_hash; /* quicly connection id -> conn handle */ + clib_bihash_16_8_t connection_hash; /* quic connection id -> conn handle */ f64 tstamp_ticks_per_clock; ptls_cipher_suite_t ***quic_ciphers; /* available ciphers by crypto engine */ -- cgit 1.2.3-korg