diff options
author | Hugo Landau <hlandau@openssl.org> | 2024-02-14 09:44:36 +0100 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2024-03-09 09:56:59 +0100 |
commit | b317583f4ad8a8e742781381fa10db5bcd072585 (patch) | |
tree | 1e0910f353429ad59060636317bcfc6cd5ccf7fd /ssl | |
parent | Try to fix intermittent CI failures in sslapitest (diff) | |
download | openssl-b317583f4ad8a8e742781381fa10db5bcd072585.tar.xz openssl-b317583f4ad8a8e742781381fa10db5bcd072585.zip |
QUIC: Add stream write buffer queries
Reviewed-by: Tim Hudson <tjh@openssl.org>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23584)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_impl.c | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index 31548c1b1d..d24769bfc2 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -3371,11 +3371,50 @@ err: return ret; } +QUIC_TAKES_LOCK +static int qc_get_stream_write_buf_stat(QCTX *ctx, uint32_t class_, + uint64_t *p_value_out, + size_t (*getter)(QUIC_SSTREAM *sstream)) +{ + int ret = 0; + size_t value = 0; + + quic_lock(ctx->qc); + + if (class_ != SSL_VALUE_CLASS_GENERIC) { + QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE_CLASS, + NULL); + goto err; + } + + if (ctx->xso == NULL) { + QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_NO_STREAM, NULL); + goto err; + } + + if (!ossl_quic_stream_has_send(ctx->xso->stream)) { + QUIC_RAISE_NON_NORMAL_ERROR(ctx, SSL_R_STREAM_RECV_ONLY, NULL); + goto err; + } + + if (ossl_quic_stream_has_send_buffer(ctx->xso->stream)) + value = getter(ctx->xso->stream->sstream); + + ret = 1; +err: + quic_unlock(ctx->qc); + *p_value_out = (uint64_t)value; + return ret; +} + QUIC_NEEDS_LOCK static int expect_quic_for_value(SSL *s, QCTX *ctx, uint32_t id) { switch (id) { case SSL_VALUE_EVENT_HANDLING_MODE: + case SSL_VALUE_STREAM_WRITE_BUF_SIZE: + case SSL_VALUE_STREAM_WRITE_BUF_USED: + case SSL_VALUE_STREAM_WRITE_BUF_AVAIL: return expect_quic(s, ctx); default: return expect_quic_conn_only(s, ctx); @@ -3411,6 +3450,16 @@ int ossl_quic_get_value_uint(SSL *s, uint32_t class_, uint32_t id, case SSL_VALUE_EVENT_HANDLING_MODE: return qc_getset_event_handling(&ctx, class_, value, NULL); + case SSL_VALUE_STREAM_WRITE_BUF_SIZE: + return qc_get_stream_write_buf_stat(&ctx, class_, value, + ossl_quic_sstream_get_buffer_size); + case SSL_VALUE_STREAM_WRITE_BUF_USED: + return qc_get_stream_write_buf_stat(&ctx, class_, value, + ossl_quic_sstream_get_buffer_used); + case SSL_VALUE_STREAM_WRITE_BUF_AVAIL: + return qc_get_stream_write_buf_stat(&ctx, class_, value, + ossl_quic_sstream_get_buffer_avail); + default: return QUIC_RAISE_NON_NORMAL_ERROR(&ctx, SSL_R_UNSUPPORTED_CONFIG_VALUE, NULL); |