MINOR: quic: Flag RX packet as ack-eliciting from the generic parser.
Add ->flags to the QUIC frame parser as this has been done for the builder so
that to flag RX packets as ack-eliciting at low level. This should also be
helpful to maintain the code if we have to add new flags to RX packets.
Remove the statements which does the same thing as higher level in
qc_parse_pkt_frms().
diff --git a/src/quic_frame.c b/src/quic_frame.c
index e82f588..7b320ce 100644
--- a/src/quic_frame.c
+++ b/src/quic_frame.c
@@ -887,41 +887,42 @@
struct quic_frame_parser {
int (*func)(struct quic_frame *frm,
const unsigned char **, const unsigned char *);
+ unsigned char flags;
unsigned char mask;
};
struct quic_frame_parser quic_frame_parsers[] = {
- [QUIC_FT_PADDING] = { .func = quic_parse_padding_frame, .mask = QUIC_FT_PKT_TYPE_IH01_BITMASK, },
- [QUIC_FT_PING] = { .func = quic_parse_ping_frame, .mask = QUIC_FT_PKT_TYPE_IH01_BITMASK, },
- [QUIC_FT_ACK] = { .func = quic_parse_ack_frame_header, .mask = QUIC_FT_PKT_TYPE_IH_1_BITMASK, },
- [QUIC_FT_ACK_ECN] = { .func = quic_parse_ack_ecn_frame, .mask = QUIC_FT_PKT_TYPE_IH_1_BITMASK, },
- [QUIC_FT_RESET_STREAM] = { .func = quic_parse_reset_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STOP_SENDING] = { .func = quic_parse_stop_sending_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_CRYPTO] = { .func = quic_parse_crypto_frame, .mask = QUIC_FT_PKT_TYPE_IH_1_BITMASK, },
- [QUIC_FT_NEW_TOKEN] = { .func = quic_parse_new_token_frame, .mask = QUIC_FT_PKT_TYPE____1_BITMASK, },
- [QUIC_FT_STREAM_8] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_9] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_A] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_B] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_C] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_D] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_E] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_F] = { .func = quic_parse_stream_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_MAX_DATA] = { .func = quic_parse_max_data_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_MAX_STREAM_DATA] = { .func = quic_parse_max_stream_data_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_MAX_STREAMS_BIDI] = { .func = quic_parse_max_streams_bidi_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_MAX_STREAMS_UNI] = { .func = quic_parse_max_streams_uni_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_DATA_BLOCKED] = { .func = quic_parse_data_blocked_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAM_DATA_BLOCKED] = { .func = quic_parse_stream_data_blocked_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAMS_BLOCKED_BIDI] = { .func = quic_parse_streams_blocked_bidi_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_STREAMS_BLOCKED_UNI] = { .func = quic_parse_streams_blocked_uni_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_NEW_CONNECTION_ID] = { .func = quic_parse_new_connection_id_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_RETIRE_CONNECTION_ID] = { .func = quic_parse_retire_connection_id_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_PATH_CHALLENGE] = { .func = quic_parse_path_challenge_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_PATH_RESPONSE] = { .func = quic_parse_path_response_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_CONNECTION_CLOSE] = { .func = quic_parse_connection_close_frame, .mask = QUIC_FT_PKT_TYPE_IH01_BITMASK, },
- [QUIC_FT_CONNECTION_CLOSE_APP] = { .func = quic_parse_connection_close_app_frame, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
- [QUIC_FT_HANDSHAKE_DONE] = { .func = quic_parse_handshake_done_frame, .mask = QUIC_FT_PKT_TYPE____1_BITMASK, },
+ [QUIC_FT_PADDING] = { .func = quic_parse_padding_frame, .flags = 0, .mask = QUIC_FT_PKT_TYPE_IH01_BITMASK, },
+ [QUIC_FT_PING] = { .func = quic_parse_ping_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE_IH01_BITMASK, },
+ [QUIC_FT_ACK] = { .func = quic_parse_ack_frame_header, .flags = 0, .mask = QUIC_FT_PKT_TYPE_IH_1_BITMASK, },
+ [QUIC_FT_ACK_ECN] = { .func = quic_parse_ack_ecn_frame, .flags = 0, .mask = QUIC_FT_PKT_TYPE_IH_1_BITMASK, },
+ [QUIC_FT_RESET_STREAM] = { .func = quic_parse_reset_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STOP_SENDING] = { .func = quic_parse_stop_sending_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_CRYPTO] = { .func = quic_parse_crypto_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE_IH_1_BITMASK, },
+ [QUIC_FT_NEW_TOKEN] = { .func = quic_parse_new_token_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE____1_BITMASK, },
+ [QUIC_FT_STREAM_8] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_9] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_A] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_B] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_C] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_D] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_E] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_F] = { .func = quic_parse_stream_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_MAX_DATA] = { .func = quic_parse_max_data_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_MAX_STREAM_DATA] = { .func = quic_parse_max_stream_data_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_MAX_STREAMS_BIDI] = { .func = quic_parse_max_streams_bidi_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_MAX_STREAMS_UNI] = { .func = quic_parse_max_streams_uni_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_DATA_BLOCKED] = { .func = quic_parse_data_blocked_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAM_DATA_BLOCKED] = { .func = quic_parse_stream_data_blocked_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAMS_BLOCKED_BIDI] = { .func = quic_parse_streams_blocked_bidi_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_STREAMS_BLOCKED_UNI] = { .func = quic_parse_streams_blocked_uni_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_NEW_CONNECTION_ID] = { .func = quic_parse_new_connection_id_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_RETIRE_CONNECTION_ID] = { .func = quic_parse_retire_connection_id_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_PATH_CHALLENGE] = { .func = quic_parse_path_challenge_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_PATH_RESPONSE] = { .func = quic_parse_path_response_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_CONNECTION_CLOSE] = { .func = quic_parse_connection_close_frame, .flags = 0, .mask = QUIC_FT_PKT_TYPE_IH01_BITMASK, },
+ [QUIC_FT_CONNECTION_CLOSE_APP] = { .func = quic_parse_connection_close_app_frame, .flags = 0, .mask = QUIC_FT_PKT_TYPE___01_BITMASK, },
+ [QUIC_FT_HANDSHAKE_DONE] = { .func = quic_parse_handshake_done_frame, .flags = QUIC_FL_RX_PACKET_ACK_ELICITING, .mask = QUIC_FT_PKT_TYPE____1_BITMASK, },
};
/* Decode a QUIC frame from <buf> buffer into <frm> frame.
@@ -951,11 +952,13 @@
}
TRACE_PROTO("frame", QUIC_EV_CONN_PRSFRM, conn->conn, frm);
- if (!quic_frame_parsers[frm->type].func(frm, buf, end)) {
+ if (!parser->func(frm, buf, end)) {
TRACE_DEVEL("parsing error", QUIC_EV_CONN_PRSFRM, conn->conn, frm);
return 0;
}
+ pkt->flags |= parser->flags;
+
return 1;
}
@@ -966,6 +969,8 @@
struct quic_frame *frm, struct quic_tx_packet *pkt,
struct quic_conn *conn)
{
+ struct quic_frame_builder *builder;
+
if (end <= *buf) {
TRACE_DEVEL("not enough room", QUIC_EV_CONN_BFRM, conn->conn, frm);
return 0;
@@ -973,12 +978,13 @@
TRACE_PROTO("frame", QUIC_EV_CONN_BFRM, conn->conn, frm);
*(*buf)++ = frm->type;
+ builder = &quic_frame_builders[frm->type];
if (!quic_frame_builders[frm->type].func(buf, end, frm, conn)) {
TRACE_DEVEL("frame building error", QUIC_EV_CONN_BFRM, conn->conn, frm);
return 0;
}
- pkt->flags |= quic_frame_builders[frm->type].flags;
+ pkt->flags |= builder[frm->type].flags;
return 1;
}
diff --git a/src/xprt_quic.c b/src/xprt_quic.c
index bb8322f..9c8ab29 100644
--- a/src/xprt_quic.c
+++ b/src/xprt_quic.c
@@ -1548,8 +1548,6 @@
pkt, &cf))
goto err;
}
- /* ack-eliciting frame. */
- pkt->flags |= QUIC_FL_RX_PACKET_ACK_ELICITING;
break;
case QUIC_FT_PADDING:
if (pos != end) {
@@ -1576,7 +1574,6 @@
break;
}
case QUIC_FT_PING:
- pkt->flags |= QUIC_FL_RX_PACKET_ACK_ELICITING;
break;
case QUIC_FT_CONNECTION_CLOSE:
case QUIC_FT_CONNECTION_CLOSE_APP:
@@ -1584,7 +1581,6 @@
case QUIC_FT_NEW_CONNECTION_ID:
case QUIC_FT_STREAM_A:
case QUIC_FT_STREAM_B:
- pkt->flags |= QUIC_FL_RX_PACKET_ACK_ELICITING;
break;
case QUIC_FT_HANDSHAKE_DONE:
if (objt_listener(ctx->conn->target))