diff options
author | Matt Caswell <matt@openssl.org> | 2022-10-04 16:32:02 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2022-10-12 15:53:31 +0100 |
commit | ace3819506d8d6bd298dd8448fefcbd62b63580c (patch) | |
tree | 4943dd8c4027fe5980214b65aff44e014943ed68 /ssl/record/methods/ktls_meth.c | |
parent | 5bc226ab3217525584a553ff1729567219d00e78 (diff) |
Introduce a step to prepare the BIO before writing
This removes some KTLS specific code from tls_retry_write_records().
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19343)
Diffstat (limited to 'ssl/record/methods/ktls_meth.c')
-rw-r--r-- | ssl/record/methods/ktls_meth.c | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/ssl/record/methods/ktls_meth.c b/ssl/record/methods/ktls_meth.c index 6715e1c65d..14db12ad5b 100644 --- a/ssl/record/methods/ktls_meth.c +++ b/ssl/record/methods/ktls_meth.c @@ -511,6 +511,28 @@ static int ktls_post_encryption_processing(OSSL_RECORD_LAYER *rl, return 1; } +static int ktls_prepare_write_bio(OSSL_RECORD_LAYER *rl, int type) +{ + /* + * To prevent coalescing of control and data messages, + * such as in buffer_write, we flush the BIO + */ + if (type != SSL3_RT_APPLICATION_DATA) { + int ret, i = BIO_flush(rl->bio); + + if (i <= 0) { + if (BIO_should_retry(rl->bio)) + ret = OSSL_RECORD_RETURN_RETRY; + else + ret = OSSL_RECORD_RETURN_FATAL; + return ret; + } + BIO_set_ktls_ctrl_msg(rl->bio, type); + } + + return OSSL_RECORD_RETURN_SUCCESS; +} + static struct record_functions_st ossl_ktls_funcs = { ktls_set_crypto_state, ktls_cipher, @@ -528,7 +550,8 @@ static struct record_functions_st ossl_ktls_funcs = { ktls_prepare_record_header, NULL, ktls_prepare_for_encryption, - ktls_post_encryption_processing + ktls_post_encryption_processing, + ktls_prepare_write_bio }; const OSSL_RECORD_METHOD ossl_ktls_record_method = { |