summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2022-10-12 17:44:40 +0100
committerHugo Landau <hlandau@openssl.org>2022-11-07 18:18:34 +0000
commit6db5cb844852f8f13753caf26dea7750f701e4d9 (patch)
tree4dd847f22365ca6e7313739fd734849d7a1e6643
parent0ede517cfa73fd3566d2ecd32215b4b12dd1d3b5 (diff)
QUIC CFQ Fixes
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19206)
-rw-r--r--include/internal/quic_cfq.h15
-rw-r--r--include/internal/quic_txpim.h6
-rw-r--r--ssl/quic/quic_cfq.c21
-rw-r--r--ssl/quic/quic_txpim.c7
-rw-r--r--test/quic_cfq_test.c6
5 files changed, 30 insertions, 25 deletions
diff --git a/include/internal/quic_cfq.h b/include/internal/quic_cfq.h
index d5ac37ae43..c7239d87df 100644
--- a/include/internal/quic_cfq.h
+++ b/include/internal/quic_cfq.h
@@ -37,19 +37,19 @@ struct quic_cfq_item_st {
#define QUIC_CFQ_STATE_TX 1
/* Returns the frame type of a CFQ item. */
-uint64_t ossl_quic_cfq_item_get_frame_type(QUIC_CFQ_ITEM *item);
+uint64_t ossl_quic_cfq_item_get_frame_type(const QUIC_CFQ_ITEM *item);
/* Returns a pointer to the encoded buffer of a CFQ item. */
-const unsigned char *ossl_quic_cfq_item_get_encoded(QUIC_CFQ_ITEM *item);
+const unsigned char *ossl_quic_cfq_item_get_encoded(const QUIC_CFQ_ITEM *item);
/* Returns the length of the encoded buffer in bytes. */
-size_t ossl_quic_cfq_item_get_encoded_len(QUIC_CFQ_ITEM *item);
+size_t ossl_quic_cfq_item_get_encoded_len(const QUIC_CFQ_ITEM *item);
/* Returns the CFQ item state, a QUIC_CFQ_STATE_* value. */
-int ossl_quic_cfq_item_get_state(QUIC_CFQ_ITEM *item);
+int ossl_quic_cfq_item_get_state(const QUIC_CFQ_ITEM *item);
/* Returns the PN space for the CFQ item. */
-uint32_t ossl_quic_cfq_item_get_pn_space(QUIC_CFQ_ITEM *item);
+uint32_t ossl_quic_cfq_item_get_pn_space(const QUIC_CFQ_ITEM *item);
/*
* QUIC Control Frame Queue
@@ -126,7 +126,8 @@ void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item);
* Gets the highest priority CFQ item in the given PN space awaiting
* transmission. If there are none, returns NULL.
*/
-QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(QUIC_CFQ *cfq, uint32_t pn_space);
+QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq,
+ uint32_t pn_space);
/*
* Given a CFQ item, gets the next CFQ item awaiting transmission in priority
@@ -134,7 +135,7 @@ QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(QUIC_CFQ *cfq, uint32_t pn_space)
* ossl_quic_cfq_get_priority_head(), returns the next-lower priority item.
* Returns NULL if the given item is the last item in priority order.
*/
-QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(QUIC_CFQ_ITEM *item,
+QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(const QUIC_CFQ_ITEM *item,
uint32_t pn_space);
#endif
diff --git a/include/internal/quic_txpim.h b/include/internal/quic_txpim.h
index 087d13363f..bcc6494394 100644
--- a/include/internal/quic_txpim.h
+++ b/include/internal/quic_txpim.h
@@ -99,18 +99,18 @@ void ossl_quic_txpim_pkt_add_cfq_item(QUIC_TXPIM_PKT *fpkt,
*
* The chunks are sorted by (stream_id, start) in ascending order.
*/
-const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(QUIC_TXPIM_PKT *fpkt);
+const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(const QUIC_TXPIM_PKT *fpkt);
/*
* Returns the number of entries in the array returned by
* ossl_quic_txpim_pkt_get_chunks().
*/
-size_t ossl_quic_txpim_pkt_get_num_chunks(QUIC_TXPIM_PKT *fpkt);
+size_t ossl_quic_txpim_pkt_get_num_chunks(const QUIC_TXPIM_PKT *fpkt);
/*
* Returns the number of QUIC_TXPIM_PKTs allocated by the given TXPIM that have
* yet to be returned to the TXPIM.
*/
-size_t ossl_quic_txpim_get_in_use(QUIC_TXPIM *txpim);
+size_t ossl_quic_txpim_get_in_use(const QUIC_TXPIM *txpim);
#endif
diff --git a/ssl/quic/quic_cfq.c b/ssl/quic/quic_cfq.c
index 0b0651289a..54acbedce8 100644
--- a/ssl/quic/quic_cfq.c
+++ b/ssl/quic/quic_cfq.c
@@ -20,38 +20,38 @@ struct quic_cfq_item_ex_st {
uint64_t frame_type;
size_t encoded_len;
uint32_t priority, pn_space;
- char state;
+ int state;
};
-uint64_t ossl_quic_cfq_item_get_frame_type(QUIC_CFQ_ITEM *item)
+uint64_t ossl_quic_cfq_item_get_frame_type(const QUIC_CFQ_ITEM *item)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
return ex->frame_type;
}
-const unsigned char *ossl_quic_cfq_item_get_encoded(QUIC_CFQ_ITEM *item)
+const unsigned char *ossl_quic_cfq_item_get_encoded(const QUIC_CFQ_ITEM *item)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
return ex->encoded;
}
-size_t ossl_quic_cfq_item_get_encoded_len(QUIC_CFQ_ITEM *item)
+size_t ossl_quic_cfq_item_get_encoded_len(const QUIC_CFQ_ITEM *item)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
return ex->encoded_len;
}
-int ossl_quic_cfq_item_get_state(QUIC_CFQ_ITEM *item)
+int ossl_quic_cfq_item_get_state(const QUIC_CFQ_ITEM *item)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
return ex->state;
}
-uint32_t ossl_quic_cfq_item_get_pn_space(QUIC_CFQ_ITEM *item)
+uint32_t ossl_quic_cfq_item_get_pn_space(const QUIC_CFQ_ITEM *item)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
@@ -161,6 +161,7 @@ static void list_insert_sorted(QUIC_CFQ_ITEM_LIST *l, QUIC_CFQ_ITEM_EX *n,
QUIC_CFQ *ossl_quic_cfq_new(void)
{
QUIC_CFQ *cfq = OPENSSL_zalloc(sizeof(*cfq));
+
if (cfq == NULL)
return NULL;
@@ -297,6 +298,7 @@ void ossl_quic_cfq_mark_lost(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item,
void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
+
switch (ex->state) {
case QUIC_CFQ_STATE_NEW:
list_remove(&cfq->new_list, ex);
@@ -314,19 +316,20 @@ void ossl_quic_cfq_release(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item)
}
}
-QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(QUIC_CFQ *cfq, uint32_t pn_space)
+QUIC_CFQ_ITEM *ossl_quic_cfq_get_priority_head(const QUIC_CFQ *cfq,
+ uint32_t pn_space)
{
QUIC_CFQ_ITEM_EX *item = cfq->new_list.head;
for (; item != NULL && item->pn_space != pn_space; item = item->next);
if (item == NULL)
- return NULL; /* ubsan */
+ return NULL;
return &item->public;
}
-QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(QUIC_CFQ_ITEM *item,
+QUIC_CFQ_ITEM *ossl_quic_cfq_item_get_priority_next(const QUIC_CFQ_ITEM *item,
uint32_t pn_space)
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
diff --git a/ssl/quic/quic_txpim.c b/ssl/quic/quic_txpim.c
index 9693758769..3a7662292b 100644
--- a/ssl/quic/quic_txpim.c
+++ b/ssl/quic/quic_txpim.c
@@ -34,6 +34,7 @@ struct quic_txpim_st {
QUIC_TXPIM *ossl_quic_txpim_new(void)
{
QUIC_TXPIM *txpim = OPENSSL_zalloc(sizeof(*txpim));
+
if (txpim == NULL)
return NULL;
@@ -198,7 +199,7 @@ static int compare(const void *a, const void *b)
return 0;
}
-const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(QUIC_TXPIM_PKT *fpkt)
+const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(const QUIC_TXPIM_PKT *fpkt)
{
QUIC_TXPIM_PKT_EX *ex = (QUIC_TXPIM_PKT_EX *)fpkt;
@@ -214,14 +215,14 @@ const QUIC_TXPIM_CHUNK *ossl_quic_txpim_pkt_get_chunks(QUIC_TXPIM_PKT *fpkt)
return ex->chunks;
}
-size_t ossl_quic_txpim_pkt_get_num_chunks(QUIC_TXPIM_PKT *fpkt)
+size_t ossl_quic_txpim_pkt_get_num_chunks(const QUIC_TXPIM_PKT *fpkt)
{
QUIC_TXPIM_PKT_EX *ex = (QUIC_TXPIM_PKT_EX *)fpkt;
return ex->num_chunks;
}
-size_t ossl_quic_txpim_get_in_use(QUIC_TXPIM *txpim)
+size_t ossl_quic_txpim_get_in_use(const QUIC_TXPIM *txpim)
{
return txpim->in_use;
}
diff --git a/test/quic_cfq_test.c b/test/quic_cfq_test.c
index 76a1091fd2..dbc4eb4b7e 100644
--- a/test/quic_cfq_test.c
+++ b/test/quic_cfq_test.c
@@ -43,7 +43,7 @@ static const uint64_t ref_frame_type[] = {
OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
- OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
+ OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID,
};
static const uint32_t expect[QUIC_PN_SPACE_NUM][11] = {
@@ -123,8 +123,8 @@ static int test_cfq(void)
QUIC_CFQ_STATE_NEW)
|| !TEST_uint_eq(ossl_quic_cfq_item_get_pn_space(item),
ref_pn_space[i])
- || !TEST_uint_eq(ossl_quic_cfq_item_get_frame_type(item),
- ref_frame_type[i])
+ || !TEST_uint64_t_eq(ossl_quic_cfq_item_get_frame_type(item),
+ ref_frame_type[i])
|| !TEST_ptr_eq(ossl_quic_cfq_item_get_encoded(item),
ref_buf + i)
|| !TEST_size_t_eq(ossl_quic_cfq_item_get_encoded_len(item),