aboutsummaryrefslogtreecommitdiffstats
path: root/ssl
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2022-08-25 17:34:48 +0100
committerMatt Caswell <matt@openssl.org>2022-09-23 14:54:49 +0100
commite7694c69b5fed37f5cdf72b70f507c7188db7e3d (patch)
tree2dc779f844ad25f6314147197b54c515cc727b29 /ssl
parent151f313e53c1515f2730b3b36e3fc966e1a8010b (diff)
downloadopenssl-e7694c69b5fed37f5cdf72b70f507c7188db7e3d.tar.gz
Move numwpipes in the write record layer
We retain a numwpipes for now in the old record layer structure for use by DTLS. This will eventually be removed when DTLS moves over to the new way of doing things. Reviewed-by: Hugo Landau <hlandau@openssl.org> Reviewed-by: Richard Levitte <levitte@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19198)
Diffstat (limited to 'ssl')
-rw-r--r--ssl/record/methods/recmethod_local.h3
-rw-r--r--ssl/record/methods/tls_common.c24
-rw-r--r--ssl/record/rec_layer_d1.c8
-rw-r--r--ssl/record/record.h4
4 files changed, 18 insertions, 21 deletions
diff --git a/ssl/record/methods/recmethod_local.h b/ssl/record/methods/recmethod_local.h
index 475fb7c047..289f2e8333 100644
--- a/ssl/record/methods/recmethod_local.h
+++ b/ssl/record/methods/recmethod_local.h
@@ -102,6 +102,9 @@ struct ossl_record_layer_st
/* Next wbuf with pending data still to write */
size_t nextwbuf;
+ /* How many pipelines can be used to write data */
+ size_t numwpipes;
+
/* read IO goes into here */
SSL3_BUFFER rbuf;
/* each decoded record goes in here */
diff --git a/ssl/record/methods/tls_common.c b/ssl/record/methods/tls_common.c
index 5e1f1bb01b..d56184f816 100644
--- a/ssl/record/methods/tls_common.c
+++ b/ssl/record/methods/tls_common.c
@@ -103,7 +103,7 @@ static int tls_setup_write_buffer(OSSL_RECORD_LAYER *rl, size_t numwpipes,
size_t currpipe;
SSL_CONNECTION *s = (SSL_CONNECTION *)rl->cbarg;
- s->rlayer.numwpipes = numwpipes;
+ rl->numwpipes = numwpipes;
if (len == 0) {
if (SSL_CONNECTION_IS_DTLS(s))
@@ -138,7 +138,7 @@ static int tls_setup_write_buffer(OSSL_RECORD_LAYER *rl, size_t numwpipes,
if (s->wbio == NULL || !BIO_get_ktls_send(s->wbio)) {
p = OPENSSL_malloc(len);
if (p == NULL) {
- s->rlayer.numwpipes = currpipe;
+ rl->numwpipes = currpipe;
/*
* We've got a malloc failure, and we're still initialising
* buffers. We assume we're so doomed that we won't even be able
@@ -163,9 +163,8 @@ static void tls_release_write_buffer(OSSL_RECORD_LAYER *rl)
{
SSL3_BUFFER *wb;
size_t pipes;
- SSL_CONNECTION *s = (SSL_CONNECTION *)rl->cbarg;
- pipes = (s == NULL) ? 0 : s->rlayer.numwpipes;
+ pipes = rl->numwpipes;
while (pipes > 0) {
wb = &rl->wbuf[pipes - 1];
@@ -177,9 +176,8 @@ static void tls_release_write_buffer(OSSL_RECORD_LAYER *rl)
wb->buf = NULL;
pipes--;
}
- /* TODO(RECLAYER): REMOVE ME */
- if (rl->direction == OSSL_RECORD_DIRECTION_WRITE)
- s->rlayer.numwpipes = 0;
+
+ rl->numwpipes = 0;
}
int tls_setup_read_buffer(OSSL_RECORD_LAYER *rl)
@@ -1415,7 +1413,7 @@ int tls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
OSSL_RECORD_TEMPLATE *thistempl;
/* Check we don't have pending data waiting to write */
- if (!ossl_assert(rl->nextwbuf >= s->rlayer.numwpipes
+ if (!ossl_assert(rl->nextwbuf >= rl->numwpipes
|| SSL3_BUFFER_get_left(&rl->wbuf[rl->nextwbuf]) == 0)) {
SSLfatal(s, SSL_AD_INTERNAL_ERROR, ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED);
goto err;
@@ -1446,7 +1444,7 @@ int tls_write_records(OSSL_RECORD_LAYER *rl, OSSL_RECORD_TEMPLATE *templates,
&& !s->s3.empty_fragment_done
&& templates[0].type == SSL3_RT_APPLICATION_DATA;
- if (s->rlayer.numwpipes < numtempl + prefix) {
+ if (rl->numwpipes < numtempl + prefix) {
/*
* TODO(RECLAYER): In the prefix case the first buffer can be a lot
* smaller. It is wasteful to allocate a full sized buffer here
@@ -1864,7 +1862,7 @@ int tls_retry_write_records(OSSL_RECORD_LAYER *rl)
size_t tmpwrit = 0;
SSL_CONNECTION *s = rl->cbarg;
- if (rl->nextwbuf >= s->rlayer.numwpipes)
+ if (rl->nextwbuf >= rl->numwpipes)
return 1;
for (;;) {
@@ -1906,7 +1904,7 @@ int tls_retry_write_records(OSSL_RECORD_LAYER *rl)
if (i >= 0 && tmpwrit == SSL3_BUFFER_get_left(thiswb)) {
SSL3_BUFFER_set_left(thiswb, 0);
SSL3_BUFFER_add_offset(thiswb, tmpwrit);
- if (++(rl->nextwbuf) < s->rlayer.numwpipes)
+ if (++(rl->nextwbuf) < rl->numwpipes)
continue;
s->rwstate = SSL_NOTHING;
/*
@@ -1915,7 +1913,7 @@ int tls_retry_write_records(OSSL_RECORD_LAYER *rl)
*/
s->s3.empty_fragment_done = 0;
- if (rl->nextwbuf == s->rlayer.numwpipes
+ if (rl->nextwbuf == rl->numwpipes
&& (rl->mode & SSL_MODE_RELEASE_BUFFERS) != 0)
tls_release_write_buffer(rl);
@@ -1927,7 +1925,7 @@ int tls_retry_write_records(OSSL_RECORD_LAYER *rl)
* using a datagram service
*/
SSL3_BUFFER_set_left(thiswb, 0);
- if (++(rl->nextwbuf) == s->rlayer.numwpipes
+ if (++(rl->nextwbuf) == rl->numwpipes
&& (rl->mode & SSL_MODE_RELEASE_BUFFERS) != 0)
tls_release_write_buffer(rl);
diff --git a/ssl/record/rec_layer_d1.c b/ssl/record/rec_layer_d1.c
index b72fab0fc7..cad2ddda2d 100644
--- a/ssl/record/rec_layer_d1.c
+++ b/ssl/record/rec_layer_d1.c
@@ -662,12 +662,6 @@ static int ssl3_write_pending(SSL_CONNECTION *s, int type,
}
for (;;) {
- /* Loop until we find a buffer we haven't written out yet */
- if (SSL3_BUFFER_get_left(&wb[currbuf]) == 0
- && currbuf < s->rlayer.numwpipes - 1) {
- currbuf++;
- continue;
- }
clear_sys_error();
if (s->wbio != NULL) {
s->rwstate = SSL_WRITING;
@@ -703,8 +697,6 @@ static int ssl3_write_pending(SSL_CONNECTION *s, int type,
if (i >= 0 && tmpwrit == SSL3_BUFFER_get_left(&wb[currbuf])) {
SSL3_BUFFER_set_left(&wb[currbuf], 0);
SSL3_BUFFER_add_offset(&wb[currbuf], tmpwrit);
- if (currbuf + 1 < s->rlayer.numwpipes)
- continue;
s->rwstate = SSL_NOTHING;
*written = s->rlayer.wpend_ret;
return 1;
diff --git a/ssl/record/record.h b/ssl/record/record.h
index 1442b8cb67..a5d8fd3670 100644
--- a/ssl/record/record.h
+++ b/ssl/record/record.h
@@ -149,6 +149,10 @@ typedef struct record_layer_st {
* non-blocking reads)
*/
int read_ahead;
+ /*
+ * TODO(RECLAYER): These next 2 fields can be removed when DTLS is moved to
+ * the new write record layer architecture.
+ */
/* How many pipelines can be used to write data */
size_t numwpipes;
/* write IO goes into here */