BUG/MINOR: flt_trace/htx: Only apply the random forwarding on the message body.

In the function trace_http_payload(), when the random forwarding is enabled,
only blocks of type HTX_BLK_DATA must be considered. Because other blocks must
be forwarding in one time.

This patch must be backported to 1.9. But it will have to be adapted. Because
several changes on the HTX in the 2.0 are missing in the 1.9.
This commit is contained in:
Christopher Faulet 2019-06-04 22:09:53 +02:00
parent c31872fc04
commit 0bdeeaacbb

View File

@ -464,8 +464,32 @@ trace_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg
struct trace_config *conf = FLT_CONF(filter);
int ret = len;
if (ret && conf->rand_forwarding)
if (ret && conf->rand_forwarding) {
struct htx *htx = htxbuf(&msg->chn->buf);
struct htx_blk *blk;
uint32_t sz, data = 0;
for (blk = htx_get_first_blk(htx); blk; blk = htx_get_next_blk(htx, blk)) {
if (htx_get_blk_type(blk) != HTX_BLK_DATA)
break;
sz = htx_get_blksz(blk);
if (offset >= sz) {
offset -= sz;
continue;
}
data += sz - offset;
offset = 0;
if (data > len) {
data = len;
break;
}
}
ret = random() % (ret+1);
if (ret > data)
ret = len;
}
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
"offset=%u - len=%u - forward=%d",