mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 07:37:02 +02:00
MINOR: quic: Add traces for RX frames (flow control related)
Add traces about important frame types to chunk_tx_frm_appendf() and call this function for any type of frame when parsing a packet. Move it to quic_frame.c
This commit is contained in:
parent
77bfa66124
commit
1ede823d6b
@ -1166,6 +1166,8 @@ static inline void qc_list_all_rx_pkts(struct quic_conn *qc)
|
||||
qc_list_qel_rx_pkts(&qc->els[QUIC_TLS_ENC_LEVEL_APP]);
|
||||
}
|
||||
|
||||
void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm);
|
||||
|
||||
void quic_set_tls_alert(struct quic_conn *qc, int alert);
|
||||
int quic_set_app_ops(struct quic_conn *qc, const unsigned char *alpn, size_t alpn_len);
|
||||
ssize_t quic_lstnr_dgram_read(struct buffer *buf, size_t len, void *owner,
|
||||
|
111
src/quic_frame.c
111
src/quic_frame.c
@ -86,6 +86,117 @@ const char *quic_frame_type_string(enum quic_frame_type ft)
|
||||
}
|
||||
}
|
||||
|
||||
/* Add traces to <buf> depending on <frm> frame type. */
|
||||
void chunk_frm_appendf(struct buffer *buf, const struct quic_frame *frm)
|
||||
{
|
||||
chunk_appendf(buf, " %s", quic_frame_type_string(frm->type));
|
||||
switch (frm->type) {
|
||||
case QUIC_FT_CRYPTO:
|
||||
{
|
||||
const struct quic_crypto *cf = &frm->crypto;
|
||||
chunk_appendf(buf, " cfoff=%llu cflen=%llu",
|
||||
(ull)cf->offset, (ull)cf->len);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_RESET_STREAM:
|
||||
{
|
||||
const struct quic_reset_stream *rs = &frm->reset_stream;
|
||||
chunk_appendf(buf, " id=%llu app_error_code=%llu final_size=%llu",
|
||||
(ull)rs->id, (ull)rs->app_error_code, (ull)rs->final_size);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STOP_SENDING:
|
||||
{
|
||||
const struct quic_stop_sending *s = &frm->stop_sending;
|
||||
chunk_appendf(&trace_buf, " id=%llu app_error_code=%llu",
|
||||
(ull)s->id, (ull)s->app_error_code);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F:
|
||||
{
|
||||
const struct quic_stream *s = &frm->stream;
|
||||
chunk_appendf(&trace_buf, " uni=%d fin=%d id=%llu off=%llu len=%llu",
|
||||
!!(s->id & QUIC_STREAM_FRAME_ID_DIR_BIT),
|
||||
!!(frm->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT),
|
||||
(ull)s->id, (ull)s->offset.key, (ull)s->len);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_MAX_DATA:
|
||||
{
|
||||
const struct quic_max_data *s = &frm->max_data;
|
||||
chunk_appendf(&trace_buf, " max_data=%llu", (ull)s->max_data);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_MAX_STREAM_DATA:
|
||||
{
|
||||
const struct quic_max_stream_data *s = &frm->max_stream_data;
|
||||
chunk_appendf(&trace_buf, " id=%llu max_stream_data=%llu",
|
||||
(ull)s->id, (ull)s->max_stream_data);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_MAX_STREAMS_BIDI:
|
||||
{
|
||||
const struct quic_max_streams *s = &frm->max_streams_bidi;
|
||||
chunk_appendf(&trace_buf, " max_streams=%llu", (ull)s->max_streams);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_MAX_STREAMS_UNI:
|
||||
{
|
||||
const struct quic_max_streams *s = &frm->max_streams_uni;
|
||||
chunk_appendf(&trace_buf, " max_streams=%llu", (ull)s->max_streams);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_DATA_BLOCKED:
|
||||
{
|
||||
const struct quic_data_blocked *s = &frm->data_blocked;
|
||||
chunk_appendf(&trace_buf, " limit=%llu", (ull)s->limit);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STREAM_DATA_BLOCKED:
|
||||
{
|
||||
const struct quic_stream_data_blocked *s = &frm->stream_data_blocked;
|
||||
chunk_appendf(&trace_buf, " id=%llu limit=%llu",
|
||||
(ull)s->id, (ull)s->limit);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STREAMS_BLOCKED_BIDI:
|
||||
{
|
||||
const struct quic_streams_blocked *s = &frm->streams_blocked_bidi;
|
||||
chunk_appendf(&trace_buf, " limit=%llu", (ull)s->limit);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STREAMS_BLOCKED_UNI:
|
||||
{
|
||||
const struct quic_streams_blocked *s = &frm->streams_blocked_uni;
|
||||
chunk_appendf(&trace_buf, " limit=%llu", (ull)s->limit);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_RETIRE_CONNECTION_ID:
|
||||
{
|
||||
const struct quic_retire_connection_id *rci = &frm->retire_connection_id;
|
||||
chunk_appendf(&trace_buf, " seq_num=%llu", (ull)rci->seq_num);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_CONNECTION_CLOSE:
|
||||
{
|
||||
const struct quic_connection_close *cc = &frm->connection_close;
|
||||
chunk_appendf(&trace_buf,
|
||||
" error_code=%llu frame_type=%llu reason_phrase_len=%llu",
|
||||
(ull)cc->error_code, (ull)cc->frame_type,
|
||||
(ull)cc->reason_phrase_len);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_CONNECTION_CLOSE_APP:
|
||||
{
|
||||
const struct quic_connection_close_app *cc = &frm->connection_close_app;
|
||||
chunk_appendf(&trace_buf,
|
||||
" error_code=%llu reason_phrase_len=%llu",
|
||||
(ull)cc->error_code, (ull)cc->reason_phrase_len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Encode <frm> PADDING frame into <buf> buffer.
|
||||
* Returns 1 if succeeded (enough room in <buf> to encode the frame), 0 if not.
|
||||
*/
|
||||
|
@ -170,38 +170,6 @@ static struct quic_tx_packet *qc_build_pkt(unsigned char **pos, const unsigned c
|
||||
struct quic_conn *qc, size_t dglen, int pkt_type,
|
||||
int padding, int ack, int nb_pto_dgrams, int cc, int *err);
|
||||
|
||||
/* Add traces to <buf> depending on <frm> TX frame type. */
|
||||
static inline void chunk_tx_frm_appendf(struct buffer *buf,
|
||||
const struct quic_frame *frm)
|
||||
{
|
||||
chunk_appendf(buf, " %s", quic_frame_type_string(frm->type));
|
||||
switch (frm->type) {
|
||||
case QUIC_FT_CRYPTO:
|
||||
{
|
||||
const struct quic_crypto *cf = &frm->crypto;
|
||||
chunk_appendf(buf, " cfoff=%llu cflen=%llu",
|
||||
(ull)cf->offset, (ull)cf->len);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STOP_SENDING:
|
||||
{
|
||||
const struct quic_stop_sending *s = &frm->stop_sending;
|
||||
chunk_appendf(&trace_buf, " id=%llu app_error_code=%llu",
|
||||
(ull)s->id, (ull)s->app_error_code);
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F:
|
||||
{
|
||||
const struct quic_stream *s = &frm->stream;
|
||||
chunk_appendf(&trace_buf, " uni=%d fin=%d id=%llu off=%llu len=%llu",
|
||||
!!(s->id & QUIC_STREAM_FRAME_ID_DIR_BIT),
|
||||
!!(frm->type & QUIC_STREAM_FRAME_TYPE_FIN_BIT),
|
||||
(ull)s->id, (ull)s->offset.key, (ull)s->len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Only for debug purpose */
|
||||
struct enc_debug_info {
|
||||
unsigned char *payload;
|
||||
@ -334,7 +302,7 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
|
||||
if (pkt->pn_node.key != (uint64_t)-1)
|
||||
chunk_appendf(&trace_buf, " pn=%llu",(ull)pkt->pn_node.key);
|
||||
list_for_each_entry(frm, &pkt->frms, list)
|
||||
chunk_tx_frm_appendf(&trace_buf, frm);
|
||||
chunk_frm_appendf(&trace_buf, frm);
|
||||
chunk_appendf(&trace_buf, " tx.bytes=%llu", (unsigned long long)qc->tx.bytes);
|
||||
}
|
||||
|
||||
@ -463,7 +431,7 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
|
||||
const unsigned long *val2 = a4;
|
||||
|
||||
if (frm)
|
||||
chunk_tx_frm_appendf(&trace_buf, frm);
|
||||
chunk_frm_appendf(&trace_buf, frm);
|
||||
if (val1)
|
||||
chunk_appendf(&trace_buf, " %lu", *val1);
|
||||
if (val2)
|
||||
@ -592,7 +560,7 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
|
||||
const struct quic_frame *frm = a2;
|
||||
|
||||
if (frm)
|
||||
chunk_tx_frm_appendf(&trace_buf, frm);
|
||||
chunk_frm_appendf(&trace_buf, frm);
|
||||
}
|
||||
}
|
||||
if (mask & QUIC_EV_CONN_LPKT) {
|
||||
@ -2222,6 +2190,7 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
|
||||
if (!qc_parse_frm(&frm, pkt, &pos, end, qc))
|
||||
goto err;
|
||||
|
||||
TRACE_PROTO("RX frame", QUIC_EV_CONN_PSTRM, qc, &frm);
|
||||
switch (frm.type) {
|
||||
case QUIC_FT_PADDING:
|
||||
break;
|
||||
@ -2245,7 +2214,6 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
|
||||
break;
|
||||
}
|
||||
case QUIC_FT_STOP_SENDING:
|
||||
TRACE_PROTO("RX frame", QUIC_EV_CONN_PSTRM, qc, &frm);
|
||||
break;
|
||||
case QUIC_FT_CRYPTO:
|
||||
{
|
||||
@ -2312,7 +2280,6 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
|
||||
{
|
||||
struct quic_stream *stream = &frm.stream;
|
||||
|
||||
TRACE_PROTO("RX frame", QUIC_EV_CONN_PSTRM, ctx->conn, &frm);
|
||||
if (objt_listener(ctx->conn->target)) {
|
||||
if (stream->id & QUIC_STREAM_FRAME_ID_INITIATOR_BIT)
|
||||
goto err;
|
||||
|
Loading…
Reference in New Issue
Block a user