mirror of
https://github.com/openssl/openssl.git
synced 2024-12-09 05:51:54 +08:00
QUIC TXP: Refactor status output to use an extensible structure
Reviewed-by: Tomas Mraz <tomas@openssl.org> Reviewed-by: Matt Caswell <matt@openssl.org> Reviewed-by: Paul Dale <pauli@openssl.org> (Merged from https://github.com/openssl/openssl/pull/21029)
This commit is contained in:
parent
81b400cf90
commit
a3a51d6ec3
@ -84,15 +84,20 @@ void ossl_quic_tx_packetiser_free(OSSL_QUIC_TX_PACKETISER *txp);
|
||||
* TX_PACKETISER_RES_NO_PKT if no packets were sent (e.g. because nothing wants
|
||||
* to send anything), and TX_PACKETISER_RES_SENT_PKT if packets were sent.
|
||||
*
|
||||
* If an ACK-eliciting packet was sent, 1 is written to *sent_ack_eliciting,
|
||||
* otherwise *sent_ack_eliciting is unchanged.
|
||||
* *status is filled with status information about the generated packet, if any.
|
||||
* See QUIC_TXP_STATUS for details.
|
||||
*/
|
||||
#define TX_PACKETISER_RES_FAILURE 0
|
||||
#define TX_PACKETISER_RES_NO_PKT 1
|
||||
#define TX_PACKETISER_RES_SENT_PKT 2
|
||||
|
||||
typedef struct quic_txp_status_st {
|
||||
int sent_ack_eliciting; /* Was an ACK-eliciting packet sent? */
|
||||
} QUIC_TXP_STATUS;
|
||||
|
||||
int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
uint32_t archetype,
|
||||
int *sent_ack_eliciting);
|
||||
QUIC_TXP_STATUS *status);
|
||||
|
||||
/*
|
||||
* Returns 1 if one or more packets would be generated if
|
||||
|
@ -1640,7 +1640,7 @@ undesirable:
|
||||
/* Try to generate packets and if possible, flush them to the network. */
|
||||
static int ch_tx(QUIC_CHANNEL *ch)
|
||||
{
|
||||
int sent_ack_eliciting = 0;
|
||||
QUIC_TXP_STATUS status;
|
||||
|
||||
if (ch->state == QUIC_CHANNEL_STATE_TERMINATING_CLOSING) {
|
||||
/*
|
||||
@ -1664,7 +1664,7 @@ static int ch_tx(QUIC_CHANNEL *ch)
|
||||
*/
|
||||
switch (ossl_quic_tx_packetiser_generate(ch->txp,
|
||||
TX_PACKETISER_ARCHETYPE_NORMAL,
|
||||
&sent_ack_eliciting)) {
|
||||
&status)) {
|
||||
case TX_PACKETISER_RES_SENT_PKT:
|
||||
ch->have_sent_any_pkt = 1; /* Packet was sent */
|
||||
|
||||
@ -1673,7 +1673,7 @@ static int ch_tx(QUIC_CHANNEL *ch)
|
||||
* sending an ack-eliciting packet if no other ack-eliciting packets
|
||||
* have been sent since last receiving and processing a packet.'
|
||||
*/
|
||||
if (sent_ack_eliciting && !ch->have_sent_ack_eliciting_since_rx) {
|
||||
if (status.sent_ack_eliciting && !ch->have_sent_ack_eliciting_since_rx) {
|
||||
ch_update_idle(ch);
|
||||
ch->have_sent_ack_eliciting_since_rx = 1;
|
||||
}
|
||||
|
@ -352,7 +352,7 @@ static int txp_generate_for_el(OSSL_QUIC_TX_PACKETISER *txp, uint32_t enc_level,
|
||||
int is_last_in_dgram,
|
||||
int dgram_contains_initial,
|
||||
int chosen_for_conn_close,
|
||||
int *sent_ack_eliciting);
|
||||
QUIC_TXP_STATUS *status);
|
||||
static size_t txp_determine_pn_len(OSSL_QUIC_TX_PACKETISER *txp);
|
||||
static int txp_determine_ppl_from_pl(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
size_t pl,
|
||||
@ -368,7 +368,7 @@ static int txp_generate_for_el_actual(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
size_t pkt_overhead,
|
||||
QUIC_PKT_HDR *phdr,
|
||||
int chosen_for_conn_close,
|
||||
int *sent_ack_eliciting);
|
||||
QUIC_TXP_STATUS *status);
|
||||
|
||||
OSSL_QUIC_TX_PACKETISER *ossl_quic_tx_packetiser_new(const OSSL_QUIC_TX_PACKETISER_ARGS *args)
|
||||
{
|
||||
@ -538,13 +538,15 @@ int ossl_quic_tx_packetiser_has_pending(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
*/
|
||||
int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
uint32_t archetype,
|
||||
int *sent_ack_eliciting)
|
||||
QUIC_TXP_STATUS *status)
|
||||
{
|
||||
uint32_t enc_level, conn_close_enc_level = QUIC_ENC_LEVEL_NUM;
|
||||
int have_pkt_for_el[QUIC_ENC_LEVEL_NUM], is_last_in_dgram, cc_can_send;
|
||||
size_t num_el_in_dgram = 0, pkts_done = 0;
|
||||
int rc;
|
||||
|
||||
status->sent_ack_eliciting = 0;
|
||||
|
||||
/*
|
||||
* If CC says we cannot send we still may be able to send any queued probes.
|
||||
*/
|
||||
@ -580,7 +582,7 @@ int ossl_quic_tx_packetiser_generate(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
is_last_in_dgram,
|
||||
have_pkt_for_el[QUIC_ENC_LEVEL_INITIAL],
|
||||
enc_level == conn_close_enc_level,
|
||||
sent_ack_eliciting);
|
||||
status);
|
||||
|
||||
if (rc != TXP_ERR_SUCCESS) {
|
||||
/*
|
||||
@ -934,7 +936,7 @@ static int txp_generate_for_el(OSSL_QUIC_TX_PACKETISER *txp, uint32_t enc_level,
|
||||
int is_last_in_dgram,
|
||||
int dgram_contains_initial,
|
||||
int chosen_for_conn_close,
|
||||
int *sent_ack_eliciting)
|
||||
QUIC_TXP_STATUS *status)
|
||||
{
|
||||
int must_pad = dgram_contains_initial && is_last_in_dgram;
|
||||
size_t min_dpl, min_pl, min_ppl, cmpl, cmppl, running_total;
|
||||
@ -1047,7 +1049,7 @@ static int txp_generate_for_el(OSSL_QUIC_TX_PACKETISER *txp, uint32_t enc_level,
|
||||
return txp_generate_for_el_actual(txp, enc_level, archetype, min_ppl, cmppl,
|
||||
pkt_overhead, &phdr,
|
||||
chosen_for_conn_close,
|
||||
sent_ack_eliciting);
|
||||
status);
|
||||
}
|
||||
|
||||
/* Determine how many bytes we should use for the encoded PN. */
|
||||
@ -1896,7 +1898,7 @@ static int txp_generate_for_el_actual(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
size_t pkt_overhead,
|
||||
QUIC_PKT_HDR *phdr,
|
||||
int chosen_for_conn_close,
|
||||
int *sent_ack_eliciting)
|
||||
QUIC_TXP_STATUS *status)
|
||||
{
|
||||
int rc = TXP_ERR_SUCCESS;
|
||||
struct archetype_data a;
|
||||
@ -2314,8 +2316,7 @@ static int txp_generate_for_el_actual(OSSL_QUIC_TX_PACKETISER *txp,
|
||||
--probe_info->pto[pn_space];
|
||||
}
|
||||
|
||||
if (have_ack_eliciting)
|
||||
*sent_ack_eliciting = 1;
|
||||
status->sent_ack_eliciting = 1;
|
||||
|
||||
/* Done. */
|
||||
tx_helper_cleanup(&h);
|
||||
|
@ -1227,7 +1227,8 @@ static void skip_padding(struct helper *h)
|
||||
|
||||
static int run_script(const struct script_op *script)
|
||||
{
|
||||
int testresult = 0, have_helper = 0, sent_ack_eliciting = 0;
|
||||
int testresult = 0, have_helper = 0;
|
||||
QUIC_TXP_STATUS status;
|
||||
struct helper h;
|
||||
const struct script_op *op;
|
||||
|
||||
@ -1239,7 +1240,7 @@ static int run_script(const struct script_op *script)
|
||||
switch (op->opcode) {
|
||||
case OPK_TXP_GENERATE:
|
||||
if (!TEST_int_eq(ossl_quic_tx_packetiser_generate(h.txp, (int)op->arg0,
|
||||
&sent_ack_eliciting),
|
||||
&status),
|
||||
TX_PACKETISER_RES_SENT_PKT))
|
||||
goto err;
|
||||
|
||||
@ -1248,7 +1249,7 @@ static int run_script(const struct script_op *script)
|
||||
break;
|
||||
case OPK_TXP_GENERATE_NONE:
|
||||
if (!TEST_int_eq(ossl_quic_tx_packetiser_generate(h.txp, (int)op->arg0,
|
||||
&sent_ack_eliciting),
|
||||
&status),
|
||||
TX_PACKETISER_RES_NO_PKT))
|
||||
goto err;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user