From: Hugo Landau Date: Tue, 18 Jul 2023 15:12:44 +0000 (+0100) Subject: QUIC APL: Add internal call to allow changing send buffer size X-Git-Tag: openssl-3.2.0-alpha1~351 X-Git-Url: https://git.openssl.org/gitweb/?a=commitdiff_plain;h=3415677eec8e0b474973115ad871430f11ced3fd;p=openssl.git QUIC APL: Add internal call to allow changing send buffer size Reviewed-by: Tomas Mraz Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/21484) --- diff --git a/include/internal/quic_ssl.h b/include/internal/quic_ssl.h index 37a29419c8..6bddc8a678 100644 --- a/include/internal/quic_ssl.h +++ b/include/internal/quic_ssl.h @@ -99,6 +99,9 @@ uint64_t ossl_quic_set_options(SSL *s, uint64_t opts); uint64_t ossl_quic_clear_options(SSL *s, uint64_t opts); uint64_t ossl_quic_get_options(const SSL *s); +/* Modifies write buffer size for a stream. */ +__owur int ossl_quic_set_write_buffer_size(SSL *s, size_t size); + /* * Used to override ossl_time_now() for debug purposes. While this may be * overridden at any time, expect strange results if you change it after diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index d9bdf74efe..2775a4b938 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -2898,6 +2898,41 @@ int ossl_quic_get_stream_write_error_code(SSL *ssl, uint64_t *app_error_code) return quic_get_stream_error_code(ssl, /*is_write=*/1, app_error_code); } +/* + * Write buffer size mutation + * -------------------------- + */ +int ossl_quic_set_write_buffer_size(SSL *ssl, size_t size) +{ + int ret = 0; + QCTX ctx; + + if (!expect_quic_with_stream_lock(ssl, /*remote_init=*/-1, &ctx)) + return 0; + + if (!ossl_quic_stream_has_send(ctx.xso->stream)) + /* Called on a unidirectional receive-only stream - error. */ + goto out; + + if (!ossl_quic_stream_has_send_buffer(ctx.xso->stream)) { + /* + * If the stream has a send part but we have disposed of it because we + * no longer need it, this is a no-op. + */ + ret = 1; + goto out; + } + + if (!ossl_quic_sstream_set_buffer_size(ctx.xso->stream->sstream, size)) + goto out; + + ret = 1; + +out: + quic_unlock(ctx.qc); + return ret; +} + /* * SSL_get_conn_close_info * -----------------------