summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Landau <hlandau@openssl.org>2023-07-25 12:32:24 +0200
committerMatt Caswell <matt@openssl.org>2023-08-08 15:33:42 +0200
commit371c29582aa683ab10d58ec448aef1bded208076 (patch)
tree92dcf1db469d3c9378cf000d84af720ec399ed82
parentQUIC: Echo PATH_CHALLENGE frames as PATH_RESPONSE frames (diff)
downloadopenssl-371c29582aa683ab10d58ec448aef1bded208076.tar.xz
openssl-371c29582aa683ab10d58ec448aef1bded208076.zip
QUIC CFQ: Unreliable transmission for PATH_RESPONSE
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21547)
-rw-r--r--include/internal/quic_cfq.h9
-rw-r--r--ssl/quic/quic_cfq.c16
-rw-r--r--ssl/quic/quic_channel.c2
-rw-r--r--ssl/quic/quic_rx_depack.c1
-rw-r--r--test/quic_cfq_test.c2
-rw-r--r--test/quic_fifd_test.c2
-rw-r--r--test/quic_txp_test.c4
7 files changed, 30 insertions, 6 deletions
diff --git a/include/internal/quic_cfq.h b/include/internal/quic_cfq.h
index 6ea69c22a1..2256f2f0a3 100644
--- a/include/internal/quic_cfq.h
+++ b/include/internal/quic_cfq.h
@@ -38,6 +38,9 @@ struct quic_cfq_item_st {
# define QUIC_CFQ_STATE_NEW 0
# define QUIC_CFQ_STATE_TX 1
+/* If set, do not retransmit on loss */
+#define QUIC_CFQ_ITEM_FLAG_UNRELIABLE (1U << 0)
+
/* Returns the frame type of a CFQ item. */
uint64_t ossl_quic_cfq_item_get_frame_type(const QUIC_CFQ_ITEM *item);
@@ -53,6 +56,9 @@ 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(const QUIC_CFQ_ITEM *item);
+/* Returns 1 if this is an unreliable frame. */
+int ossl_quic_cfq_item_is_unreliable(const QUIC_CFQ_ITEM *item);
+
/*
* QUIC Control Frame Queue
* ========================
@@ -88,6 +94,8 @@ void ossl_quic_cfq_free(QUIC_CFQ *cfq);
* The frame type is duplicated as the frame_type argument here, even though it
* is also encoded into the buffer. This allows the caller to determine the
* frame type if desired without having to decode the frame.
+ *
+ * flags is zero or more QUIC_CFQ_ITEM_FLAG values.
*/
typedef void (cfq_free_cb)(unsigned char *buf, size_t buf_len, void *arg);
@@ -95,6 +103,7 @@ QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq,
uint32_t priority,
uint32_t pn_space,
uint64_t frame_type,
+ uint32_t flags,
const unsigned char *encoded,
size_t encoded_len,
cfq_free_cb *free_cb,
diff --git a/ssl/quic/quic_cfq.c b/ssl/quic/quic_cfq.c
index 54acbedce8..25ac36e348 100644
--- a/ssl/quic/quic_cfq.c
+++ b/ssl/quic/quic_cfq.c
@@ -19,7 +19,7 @@ struct quic_cfq_item_ex_st {
void *free_cb_arg;
uint64_t frame_type;
size_t encoded_len;
- uint32_t priority, pn_space;
+ uint32_t priority, pn_space, flags;
int state;
};
@@ -58,6 +58,13 @@ uint32_t ossl_quic_cfq_item_get_pn_space(const QUIC_CFQ_ITEM *item)
return ex->pn_space;
}
+int ossl_quic_cfq_item_is_unreliable(const QUIC_CFQ_ITEM *item)
+{
+ QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
+
+ return (ex->flags & QUIC_CFQ_ITEM_FLAG_UNRELIABLE) != 0;
+}
+
typedef struct quic_cfq_item_list_st {
QUIC_CFQ_ITEM_EX *head, *tail;
} QUIC_CFQ_ITEM_LIST;
@@ -223,6 +230,7 @@ QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq,
uint32_t priority,
uint32_t pn_space,
uint64_t frame_type,
+ uint32_t flags,
const unsigned char *encoded,
size_t encoded_len,
cfq_free_cb *free_cb,
@@ -242,6 +250,7 @@ QUIC_CFQ_ITEM *ossl_quic_cfq_add_frame(QUIC_CFQ *cfq,
item->free_cb_arg = free_cb_arg;
item->state = QUIC_CFQ_STATE_NEW;
+ item->flags = flags;
list_remove(&cfq->free_list, item);
list_insert_sorted(&cfq->new_list, item, compare);
return &item->public;
@@ -270,6 +279,11 @@ void ossl_quic_cfq_mark_lost(QUIC_CFQ *cfq, QUIC_CFQ_ITEM *item,
{
QUIC_CFQ_ITEM_EX *ex = (QUIC_CFQ_ITEM_EX *)item;
+ if (ossl_quic_cfq_item_is_unreliable(item)) {
+ ossl_quic_cfq_release(cfq, item);
+ return;
+ }
+
switch (ex->state) {
case QUIC_CFQ_STATE_NEW:
if (priority != UINT32_MAX && priority != ex->priority) {
diff --git a/ssl/quic/quic_channel.c b/ssl/quic/quic_channel.c
index 091b94c099..220523d587 100644
--- a/ssl/quic/quic_channel.c
+++ b/ssl/quic/quic_channel.c
@@ -2713,7 +2713,7 @@ static int ch_enqueue_retire_conn_id(QUIC_CHANNEL *ch, uint64_t seq_num)
goto err;
if (ossl_quic_cfq_add_frame(ch->cfq, 1, QUIC_PN_SPACE_APP,
- OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID,
+ OSSL_QUIC_FRAME_TYPE_RETIRE_CONN_ID, 0,
(unsigned char *)buf_mem->data, l,
free_frame_data, NULL) == NULL)
goto err;
diff --git a/ssl/quic/quic_rx_depack.c b/ssl/quic/quic_rx_depack.c
index 74d84a1775..d58efb2af3 100644
--- a/ssl/quic/quic_rx_depack.c
+++ b/ssl/quic/quic_rx_depack.c
@@ -920,6 +920,7 @@ static int depack_do_frame_path_challenge(PACKET *pkt,
if (!ossl_quic_cfq_add_frame(ch->cfq, 0, QUIC_PN_SPACE_APP,
OSSL_QUIC_FRAME_TYPE_PATH_RESPONSE,
+ QUIC_CFQ_ITEM_FLAG_UNRELIABLE,
encoded, encoded_len,
free_path_response, NULL))
goto err;
diff --git a/test/quic_cfq_test.c b/test/quic_cfq_test.c
index dbc4eb4b7e..44705b3507 100644
--- a/test/quic_cfq_test.c
+++ b/test/quic_cfq_test.c
@@ -114,7 +114,7 @@ static int test_cfq(void)
for (i = 0; i < OSSL_NELEM(ref_buf); ++i) {
if (!TEST_ptr(item = ossl_quic_cfq_add_frame(cfq, ref_priority[i],
ref_pn_space[i],
- ref_frame_type[i],
+ ref_frame_type[i], 0,
ref_buf + i,
1,
free_cb,
diff --git a/test/quic_fifd_test.c b/test/quic_fifd_test.c
index bb0cd77105..de3188a929 100644
--- a/test/quic_fifd_test.c
+++ b/test/quic_fifd_test.c
@@ -162,7 +162,7 @@ static int test_generic(INFO *info, int kind)
cfq_freed = 0;
if (!TEST_ptr(cfq_item = ossl_quic_cfq_add_frame(info->cfq, 10,
pn_space,
- OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
+ OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID, 0,
placeholder_data,
sizeof(placeholder_data),
cfq_free_cb_, NULL))
diff --git a/test/quic_txp_test.c b/test/quic_txp_test.c
index fa311bfa09..d92fd26518 100644
--- a/test/quic_txp_test.c
+++ b/test/quic_txp_test.c
@@ -421,7 +421,7 @@ static int schedule_cfq_new_conn_id(struct helper *h)
if (!TEST_ptr(cfq_item = ossl_quic_cfq_add_frame(h->args.cfq, 1,
QUIC_PN_SPACE_APP,
- OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID,
+ OSSL_QUIC_FRAME_TYPE_NEW_CONN_ID, 0,
(unsigned char *)buf_mem->data, l,
free_buf_mem,
buf_mem)))
@@ -497,7 +497,7 @@ static int schedule_cfq_new_token(struct helper *h)
if (!TEST_ptr(cfq_item = ossl_quic_cfq_add_frame(h->args.cfq, 1,
QUIC_PN_SPACE_APP,
- OSSL_QUIC_FRAME_TYPE_NEW_TOKEN,
+ OSSL_QUIC_FRAME_TYPE_NEW_TOKEN, 0,
(unsigned char *)buf_mem->data, l,
free_buf_mem,
buf_mem)))