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)
This commit is contained in:
Hugo Landau 2023-07-25 11:32:24 +01:00 committed by Matt Caswell
parent 7eb330ff7a
commit 371c29582a
7 changed files with 30 additions and 6 deletions

View File

@ -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,

View File

@ -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) {

View File

@ -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;

View File

@ -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;

View File

@ -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,

View File

@ -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))

View File

@ -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)))