MINOR: h2/trace: report the frame type when known

In state match error cases, we don't know what frame type was received
because we don't reach the frame parsers. Let's add the demuxed frame
type and flags in the trace when it's known. For this we make sure to
always reset h2c->dsi when switching back to FRAME_H. Only one location
was missing. The state transitions were not always clear (sometimes
reported before, sometimes after), these were clarified by being
reported only before switching.
This commit is contained in:
Willy Tarreau 2019-09-25 07:28:44 +02:00
parent 2d22144559
commit 73db434f7f

View File

@ -502,12 +502,18 @@ static void h2_trace(enum trace_level level, uint64_t mask, const struct trace_s
return;
if (src->verbosity > H2_VERB_CLEAN) {
if (!h2s || h2c->st0 < H2_CS_FRAME_H)
chunk_appendf(&trace_buf, " : h2c=%p(%c,%s)", h2c, conn_is_back(conn) ? 'B' : 'F', h2c_st_to_str(h2c->st0));
else if (h2s->id <= 0)
chunk_appendf(&trace_buf, " : h2c=%p(%c,%s) dsi=%d h2s=%p(%d,%s)", h2c, conn_is_back(conn) ? 'B' : 'F', h2c_st_to_str(h2c->st0), h2c->dsi, h2s, h2s->id, h2s_st_to_str(h2s->st));
else
chunk_appendf(&trace_buf, " : h2c=%p(%c,%s) h2s=%p(%d,%s)", h2c, conn_is_back(conn) ? 'B' : 'F', h2c_st_to_str(h2c->st0), h2s, h2s->id, h2s_st_to_str(h2s->st));
chunk_appendf(&trace_buf, " : h2c=%p(%c,%s)", h2c, conn_is_back(conn) ? 'B' : 'F', h2c_st_to_str(h2c->st0));
if (h2c->dsi >= 0 &&
(mask & (H2_EV_RX_FRAME|H2_EV_RX_FHDR)) == (H2_EV_RX_FRAME|H2_EV_RX_FHDR)) {
chunk_appendf(&trace_buf, " dft=%s/%02x", h2_ft_str(h2c->dft), h2c->dff);
}
if (h2s) {
if (h2s->id <= 0)
chunk_appendf(&trace_buf, " dsi=%d", h2c->dsi);
chunk_appendf(&trace_buf, " h2s=%p(%d,%s)", h2s, h2s->id, h2s_st_to_str(h2s->st));
}
}
/* Let's dump decoded requests and responses right after parsing. They
@ -2922,7 +2928,6 @@ static void h2_process_demux(struct h2c *h2c)
b_del(&h2c->dbuf, 1);
}
h2_skip_frame_hdr(&h2c->dbuf);
TRACE_STATE("rcvd H2 frame header", H2_EV_RX_FRAME|H2_EV_RX_FHDR, h2c->conn);
new_frame:
h2c->dfl = hdr.len;
@ -2930,8 +2935,8 @@ static void h2_process_demux(struct h2c *h2c)
h2c->dft = hdr.ft;
h2c->dff = hdr.ff;
h2c->dpl = padlen;
TRACE_STATE("rcvd H2 frame header, switching to FRAME_P state", H2_EV_RX_FRAME|H2_EV_RX_FHDR, h2c->conn);
h2c->st0 = H2_CS_FRAME_P;
TRACE_STATE("switching to FRAME_P state", H2_EV_RX_FRAME|H2_EV_RX_FHDR, h2c->conn);
/* check for minimum basic frame format validity */
ret = h2_frame_check(h2c->dft, 1, h2c->dsi, h2c->dfl, global.tune.bufsize);
@ -3093,8 +3098,9 @@ static void h2_process_demux(struct h2c *h2c)
}
if (h2c->st0 != H2_CS_FRAME_H) {
TRACE_STATE("switching to FRAME_H", H2_EV_RX_FRAME|H2_EV_RX_FHDR, h2c->conn);
b_del(&h2c->dbuf, h2c->dfl);
h2c->dsi = -1;
TRACE_STATE("switching to FRAME_H", H2_EV_RX_FRAME|H2_EV_RX_FHDR, h2c->conn);
h2c->st0 = H2_CS_FRAME_H;
}
}