MINOR: quic: Add traces for STOP_SENDING frame and modify others

If not handled by qc_parse_pkt_frms(), the packet which contains it is dropped.
Add only a trace when parsing this frame at this time.
Also modify others to reduce the traces size and have more information about streams.
This commit is contained in:
Frédéric Lécaille 2021-12-10 15:18:36 +01:00 committed by Amaury Denoyelle
parent 1d2faa24d2
commit d8b8443047

View File

@ -174,14 +174,31 @@ static struct quic_tx_packet *qc_build_pkt(unsigned char **pos, const unsigned c
static inline void chunk_tx_frm_appendf(struct buffer *buf, static inline void chunk_tx_frm_appendf(struct buffer *buf,
const struct quic_frame *frm) const struct quic_frame *frm)
{ {
chunk_appendf(buf, " %s", quic_frame_type_string(frm->type));
switch (frm->type) { switch (frm->type) {
case QUIC_FT_CRYPTO: case QUIC_FT_CRYPTO:
{
const struct quic_crypto *cf = &frm->crypto;
chunk_appendf(buf, " cfoff=%llu cflen=%llu", chunk_appendf(buf, " cfoff=%llu cflen=%llu",
(unsigned long long)frm->crypto.offset, (ull)cf->offset, (ull)cf->len);
(unsigned long long)frm->crypto.len);
break; break;
default: }
chunk_appendf(buf, " %s", quic_frame_type_string(frm->type)); 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;
}
} }
} }
@ -583,16 +600,8 @@ static void quic_trace(enum trace_level level, uint64_t mask, const struct trace
if (mask & QUIC_EV_CONN_PSTRM) { if (mask & QUIC_EV_CONN_PSTRM) {
const struct quic_frame *frm = a2; const struct quic_frame *frm = a2;
if (a2) { if (frm)
const struct quic_stream *s = &frm->stream; chunk_tx_frm_appendf(&trace_buf, frm);
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),
(unsigned long long)s->id,
(unsigned long long)s->offset.key,
(unsigned long long)s->len);
}
} }
} }
if (mask & QUIC_EV_CONN_LPKT) { if (mask & QUIC_EV_CONN_LPKT) {
@ -2072,8 +2081,9 @@ static int qc_handle_bidi_strm_frm(struct quic_rx_packet *pkt,
if (strm_frm->offset.key == strm->rx.offset) { if (strm_frm->offset.key == strm->rx.offset) {
int ret; int ret;
if (!qc_get_buf(strm, &strm->rx.buf)) if (!qc_get_buf(strm, &strm->rx.buf)) {
goto store_frm; goto store_frm;
}
ret = qc_strm_cpy(&strm->rx.buf, strm_frm); ret = qc_strm_cpy(&strm->rx.buf, strm_frm);
if (ret && qc->qcc->app_ops->decode_qcs(strm, strm_frm->fin, qc->qcc->ctx) < 0) { if (ret && qc->qcc->app_ops->decode_qcs(strm, strm_frm->fin, qc->qcc->ctx) < 0) {
@ -2229,6 +2239,9 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
} }
break; break;
} }
case QUIC_FT_STOP_SENDING:
TRACE_PROTO("RX frame", QUIC_EV_CONN_PSTRM, ctx->conn, &frm);
break;
case QUIC_FT_CRYPTO: case QUIC_FT_CRYPTO:
{ {
struct quic_rx_crypto_frm *cf; struct quic_rx_crypto_frm *cf;
@ -2290,18 +2303,11 @@ static int qc_parse_pkt_frms(struct quic_rx_packet *pkt, struct ssl_sock_ctx *ct
quic_rx_packet_refinc(pkt); quic_rx_packet_refinc(pkt);
break; break;
} }
case QUIC_FT_STREAM_8: case QUIC_FT_STREAM_8 ... QUIC_FT_STREAM_F:
case QUIC_FT_STREAM_9:
case QUIC_FT_STREAM_A:
case QUIC_FT_STREAM_B:
case QUIC_FT_STREAM_C:
case QUIC_FT_STREAM_D:
case QUIC_FT_STREAM_E:
case QUIC_FT_STREAM_F:
{ {
struct quic_stream *stream = &frm.stream; struct quic_stream *stream = &frm.stream;
TRACE_PROTO("STREAM frame", QUIC_EV_CONN_PSTRM, ctx->conn, &frm); TRACE_PROTO("RX frame", QUIC_EV_CONN_PSTRM, ctx->conn, &frm);
if (objt_listener(ctx->conn->target)) { if (objt_listener(ctx->conn->target)) {
if (stream->id & QUIC_STREAM_FRAME_ID_INITIATOR_BIT) if (stream->id & QUIC_STREAM_FRAME_ID_INITIATOR_BIT)
goto err; goto err;
@ -2961,7 +2967,6 @@ static inline int qc_treat_rx_crypto_frms(struct quic_enc_level *el,
{ {
struct eb64_node *node; struct eb64_node *node;
TRACE_ENTER(QUIC_EV_CONN_RXCDATA, ctx->conn);
node = eb64_first(&el->rx.crypto.frms); node = eb64_first(&el->rx.crypto.frms);
while (node) { while (node) {
struct quic_rx_crypto_frm *cf; struct quic_rx_crypto_frm *cf;
@ -2978,7 +2983,6 @@ static inline int qc_treat_rx_crypto_frms(struct quic_enc_level *el,
eb64_delete(&cf->offset_node); eb64_delete(&cf->offset_node);
pool_free(pool_head_quic_rx_crypto_frm, cf); pool_free(pool_head_quic_rx_crypto_frm, cf);
} }
TRACE_LEAVE(QUIC_EV_CONN_RXCDATA, ctx->conn);
return 1; return 1;
err: err:
@ -4369,10 +4373,8 @@ static inline int qc_build_frms(struct quic_tx_packet *pkt,
/* Note that these frames are accepted in short packets only without /* Note that these frames are accepted in short packets only without
* "Length" packet field. Here, <*len> is used only to compute the * "Length" packet field. Here, <*len> is used only to compute the
* sum of the lengths of the already built frames for this packet. * sum of the lengths of the already built frames for this packet.
*/ *
TRACE_PROTO(" New STREAM frame build (room, len)", * Compute the length of this STREAM frame "header" made a all the field
QUIC_EV_CONN_BCFRMS, conn->conn, &room, len);
/* Compute the length of this STREAM frame "header" made a all the field
* excepting the variable ones. Note that +1 is for the type of this frame. * excepting the variable ones. Note that +1 is for the type of this frame.
*/ */
hlen = 1 + quic_int_getsize(cf->stream.id) + hlen = 1 + quic_int_getsize(cf->stream.id) +
@ -4382,6 +4384,8 @@ static inline int qc_build_frms(struct quic_tx_packet *pkt,
if ((ssize_t)avail_room <= 0) if ((ssize_t)avail_room <= 0)
break; break;
TRACE_PROTO(" New STREAM frame build (room, len)",
QUIC_EV_CONN_BCFRMS, conn->conn, &room, len);
if (cf->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT) { if (cf->type & QUIC_STREAM_FRAME_TYPE_LEN_BIT) {
dlen = max_available_room(avail_room, &dlen_sz); dlen = max_available_room(avail_room, &dlen_sz);
if (dlen > cf->stream.len) { if (dlen > cf->stream.len) {
@ -4615,6 +4619,7 @@ static int qc_do_build_pkt(unsigned char *pos, const unsigned char *end,
if (!LIST_ISEMPTY(&pkt->frms)) { if (!LIST_ISEMPTY(&pkt->frms)) {
struct quic_frame *cf; struct quic_frame *cf;
TRACE_PROTO("Ack eliciting frame", QUIC_EV_CONN_HPKT, conn->conn, pkt);
list_for_each_entry(cf, &pkt->frms, list) { list_for_each_entry(cf, &pkt->frms, list) {
if (!qc_build_frm(&pos, end, cf, pkt, conn)) { if (!qc_build_frm(&pos, end, cf, pkt, conn)) {
ssize_t room = end - pos; ssize_t room = end - pos;