Skip to content

Commit

Permalink
QUIC: Avoid ticking before a connection is established
Browse files Browse the repository at this point in the history
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from #23995)
  • Loading branch information
hlandau authored and t8m committed Apr 4, 2024
1 parent e34e3f0 commit f202a68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ssl/quic/quic_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -1800,7 +1800,6 @@ static int ch_generate_transport_params(QUIC_CHANNEL *ch)
ch->local_transport_params = (unsigned char *)buf_mem->data;
buf_mem->data = NULL;


if (!ossl_quic_tls_set_transport_params(ch->qtls, ch->local_transport_params,
buf_len))
goto err;
Expand Down Expand Up @@ -1870,6 +1869,10 @@ void ossl_quic_channel_subtick(QUIC_CHANNEL *ch, QUIC_TICK_RESULT *res,
* - determine the time at which we should next be ticked.
*/

/* Nothing to do yet if connection has not been started. */
if (ch->state == QUIC_CHANNEL_STATE_IDLE)
return;

/* If we are in the TERMINATED state, there is nothing to do. */
if (ossl_quic_channel_is_terminated(ch)) {
res->net_read_desired = 0;
Expand Down
4 changes: 4 additions & 0 deletions ssl/quic/quic_impl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2577,6 +2577,10 @@ static int quic_write_nonblocking_epw(QCTX *ctx, const void *buf, size_t len,

quic_post_write(xso, *written > 0, *written == len, flags,
qctx_should_autotick(ctx));
if (*written == 0)
/* SSL_write_ex returns 0 if it didn't read anything .*/
return QUIC_RAISE_NORMAL_ERROR(ctx, SSL_ERROR_WANT_READ);

return 1;
}

Expand Down
7 changes: 7 additions & 0 deletions ssl/quic/quic_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ struct quic_tls_st {

/* Set if the handshake has completed */
unsigned int complete : 1;

/* Set if we have consumed the local transport parameters yet. */
unsigned int local_transport_params_consumed : 1;
};

struct ossl_record_layer_st {
Expand Down Expand Up @@ -606,6 +609,7 @@ static int add_transport_params_cb(SSL *s, unsigned int ext_type,

*out = qtls->local_transport_params;
*outlen = qtls->local_transport_params_len;
qtls->local_transport_params_consumed = 1;
return 1;
}

Expand Down Expand Up @@ -833,6 +837,9 @@ int ossl_quic_tls_set_transport_params(QUIC_TLS *qtls,
const unsigned char *transport_params,
size_t transport_params_len)
{
if (qtls->local_transport_params_consumed)
return 0;

qtls->local_transport_params = transport_params;
qtls->local_transport_params_len = transport_params_len;
return 1;
Expand Down

0 comments on commit f202a68

Please sign in to comment.