diff options
author | Tomas Mraz <tomas@openssl.org> | 2022-10-26 18:35:04 +0200 |
---|---|---|
committer | Hugo Landau <hlandau@openssl.org> | 2022-11-14 08:01:57 +0000 |
commit | a17c713a7ad394b08646bbb0f0ba1a16e1cc8799 (patch) | |
tree | 686651f91cdad0621bcad17f8647fa62f2af4aba /ssl | |
parent | e77396f6f508f604b69f795e624896c427fe8b06 (diff) |
Plug the QUIC_RSTREAM to the RX depacketizer
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Hugo Landau <hlandau@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19351)
Diffstat (limited to 'ssl')
-rw-r--r-- | ssl/quic/quic_impl.c | 4 | ||||
-rw-r--r-- | ssl/quic/quic_local.h | 33 | ||||
-rw-r--r-- | ssl/quic/quic_rstream.c | 8 | ||||
-rw-r--r-- | ssl/quic/quic_rx_depack.c | 46 | ||||
-rw-r--r-- | ssl/quic/quic_sf_list.c | 22 |
5 files changed, 49 insertions, 64 deletions
diff --git a/ssl/quic/quic_impl.c b/ssl/quic/quic_impl.c index ed3b07e63d..856fa5e188 100644 --- a/ssl/quic/quic_impl.c +++ b/ssl/quic/quic_impl.c @@ -21,7 +21,7 @@ SSL *ossl_quic_new(SSL_CTX *ctx) if (qc == NULL) goto err; - ssl = &qc->ssl; + ssl = &qc->stream.ssl; if (!ossl_ssl_init(ssl, ctx, SSL_TYPE_QUIC_CONNECTION)) { OPENSSL_free(qc); ssl = NULL; @@ -55,6 +55,7 @@ void ossl_quic_free(SSL *s) QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s); if (qc == NULL) { + /* TODO(QUIC): Temporarily needed to release the inner tls object */ SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL_ONLY(s); if (sc != NULL) @@ -71,6 +72,7 @@ int ossl_quic_reset(SSL *s) QUIC_CONNECTION *qc = QUIC_CONNECTION_FROM_SSL(s); if (qc == NULL) { + /* TODO(QUIC): Temporarily needed to reset the inner tls object */ SSL_CONNECTION *sc = SSL_CONNECTION_FROM_SSL_ONLY(s); return sc != NULL ? ossl_ssl_connection_reset(s) : 0; diff --git a/ssl/quic/quic_local.h b/ssl/quic/quic_local.h index 3305b03aec..33301c9a13 100644 --- a/ssl/quic/quic_local.h +++ b/ssl/quic/quic_local.h @@ -12,16 +12,32 @@ # include <openssl/ssl.h> # include "internal/quic_ssl.h" /* QUIC_CONNECTION */ +# include "internal/quic_fc.h" +# include "internal/quic_stream.h" # include "../ssl_local.h" -struct quic_conn_st { - /* type identifier and common data */ +struct quic_stream_st { + /* type identifier and common data for the public SSL object */ struct ssl_st ssl; + + /* QUIC_CONNECTION that this stream belongs to */ + QUIC_CONNECTION *conn; + /* receive flow controller */ + QUIC_RXFC *rxfc; + /* receive and send stream objects */ + QUIC_RSTREAM *rstream; + QUIC_SSTREAM *sstream; +}; + +struct quic_conn_st { + /* QUIC connection is always a stream (the stream id 0) */ + struct quic_stream_st stream; /* the associated tls-1.3 connection data */ SSL *tls; - /* For QUIC, diverse handlers */ + /* QUIC ack manager */ OSSL_ACKM *ackm; + /* QUIC receive record layer */ OSSL_QRX *qrx; }; @@ -31,6 +47,13 @@ struct quic_conn_st { ? (c QUIC_CONNECTION *)(ssl) \ : NULL)) +# define QUIC_STREAM_FROM_SSL_int(ssl, c) \ + ((ssl) == NULL ? NULL \ + : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ + || (ssl)->type == SSL_TYPE_QUIC_STREAM \ + ? (c QUIC_STREAM *)(ssl) \ + : NULL)) + # define SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, c) \ ((ssl) == NULL ? NULL \ : ((ssl)->type == SSL_TYPE_QUIC_CONNECTION \ @@ -41,6 +64,10 @@ struct quic_conn_st { QUIC_CONNECTION_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST) # define QUIC_CONNECTION_FROM_CONST_SSL(ssl) \ QUIC_CONNECTION_FROM_SSL_int(ssl, const) +# define QUIC_STREAM_FROM_SSL(ssl) \ + QUIC_STREAM_FROM_SSL_int(ssl, SSL_CONNECTION_NO_CONST) +# define QUIC_STREAM_FROM_CONST_SSL(ssl) \ + QUIC_STREAM_FROM_SSL_int(ssl, const) # define SSL_CONNECTION_FROM_QUIC_SSL(ssl) \ SSL_CONNECTION_FROM_QUIC_SSL_int(ssl, SSL_CONNECTION_NO_CONST) # define SSL_CONNECTION_FROM_CONST_QUIC_SSL(ssl) \ diff --git a/ssl/quic/quic_rstream.c b/ssl/quic/quic_rstream.c index 9b4e6a2c51..9c4b8b716b 100644 --- a/ssl/quic/quic_rstream.c +++ b/ssl/quic/quic_rstream.c @@ -10,8 +10,6 @@ #include "internal/time.h" #include "internal/quic_stream.h" #include "internal/quic_sf_list.h" -#include "internal/quic_fc.h" -#include "internal/quic_error.h" struct quic_rstream_st { SFRAME_LIST fl; @@ -49,12 +47,6 @@ int ossl_quic_rstream_queue_data(QUIC_RSTREAM *qrs, OSSL_QRX_PKT_WRAP *pkt_wrap, range.start = offset; range.end = offset + data_len; - if (qrs->rxfc != NULL - && (!ossl_quic_rxfc_on_rx_stream_frame(qrs->rxfc, range.end, fin) - || ossl_quic_rxfc_get_error(qrs->rxfc, 0) != QUIC_ERR_NO_ERROR)) - /* QUIC_ERR_FLOW_CONTROL_ERROR or QUIC_ERR_FINAL_SIZE detected */ - return 0; - return ossl_sframe_list_insert(&qrs->fl, &range, pkt_wrap, data, fin); } diff --git a/ssl/quic/quic_rx_depack.c b/ssl/quic/quic_rx_depack.c index 12a7b9c39e..66d2edaaae 100644 --- a/ssl/quic/quic_rx_depack.c +++ b/ssl/quic/quic_rx_depack.c @@ -14,6 +14,8 @@ #include "internal/quic_ackm.h" #include "internal/quic_rx_depack.h" #include "internal/quic_record_rx_wrap.h" +#include "internal/quic_error.h" +#include "internal/quic_fc.h" #include "internal/sockets.h" #include "quic_local.h" @@ -35,21 +37,12 @@ # define GET_CONN_ACK_DELAY_EXP(c) 3 #endif -/* TODO(QUIC): [BEGIN: TO BE REMOVED] placeholder macros and functions */ - -/* Diverse things that should be implemented elsewhere, bur currently aren't. */ - -typedef struct quic_stream_st QUIC_STREAM; - /* - * TODO(QUIC): ASSUMPTION: ssl_get_stream() gets a QUIC_STREAM from a connection - * by stream ID. For now, we simply return a fake stream. + * TODO(QUIC): In MVP the QUIC_CONNECTION is the only supported stream. */ static QUIC_STREAM *ssl_get_stream(QUIC_CONNECTION *conn, uint64_t stream_id) { - static uint64_t fake_stream = 0; - - return (QUIC_STREAM *)&fake_stream; + return stream_id == 0 ? &conn->stream : NULL; } /* @@ -68,9 +61,6 @@ static int ssl_get_stream_type(QUIC_STREAM *stream) } /* - * TODO(QUIC): ASSUMPTION: ssl_queue_data() adds data to a QUIC_STREAM, to be - * consumed by the application when doing an SSL_read(). - * * We assume that queuing of the data has to be done without copying, thus * we get the reference counting QRX packet wrapper so it can increment the * reference count. When the data is consumed (i.e. as a result of, say, @@ -80,23 +70,19 @@ static int ssl_queue_data(QUIC_STREAM *stream, OSSL_QRX_PKT_WRAP *pkt_wrap, const unsigned char *data, uint64_t data_len, uint64_t logical_offset, int is_fin) { - /* - * Since this function is just a placeholder that doesn't actually queue - * anything, we do nothing here, not even the reference count increment. - */ + /* Notify stream flow controller */ + if (stream->rxfc != NULL + && (!ossl_quic_rxfc_on_rx_stream_frame(stream->rxfc, + logical_offset + data_len, + is_fin) + || ossl_quic_rxfc_get_error(stream->rxfc, 0) != QUIC_ERR_NO_ERROR)) + /* QUIC_ERR_FLOW_CONTROL_ERROR or QUIC_ERR_FINAL_SIZE detected */ + return 0; - /* - * 1. Queuing the data and the parent packet wrapper should happen here, - * and this call with it: - * - * ossl_qrx_pkt_wrap_up_ref(pkt_wrap); - * - * 2. Dequeuing the data happens somewhere else, and this call with it - * (|pkt_wrap| replaced with the pointer from the queue): - * - * ossl_qrx_pkt_wrap_free(pkt_wrap); - */ - return 1; + return stream->rstream == NULL + || ossl_quic_rstream_queue_data(stream->rstream, pkt_wrap, + logical_offset, data, data_len, + is_fin); } /* diff --git a/ssl/quic/quic_sf_list.c b/ssl/quic/quic_sf_list.c index 43e6d3c5e8..d382bd0904 100644 --- a/ssl/quic/quic_sf_list.c +++ b/ssl/quic/quic_sf_list.c @@ -12,28 +12,6 @@ #include "internal/quic_record_rx_wrap.h" #include "internal/quic_sf_list.h" -/* - * Stream frame list - * ================= - * - * This data structure uses supports similar operations as uint64 set but - * it has slightly different invariants and also carries data associated with - * the ranges in the list. - * - * Operations: - * Insert frame (optimized insertion at the beginning and at the end). - * Iterated peek into the frame(s) from the beginning. - * Dropping frames from the beginning up to an offset (exclusive). - * - * Invariant: The frames in the list are sorted by the start and end bounds. - * Invariant: There are no fully overlapping frames or frames that would - * be fully encompassed by another frame in the list. - * Invariant: No frame has start > end. - * Invariant: The range start is inclusive the end is exclusive to be - * able to mark an empty frame. - * Invariant: The offset never points further than into the first frame. - */ - struct stream_frame_st { struct stream_frame_st *prev, *next; UINT_RANGE range; |