From: Christopher Faulet Date: Tue, 4 Jun 2019 20:09:53 +0000 (+0200) Subject: BUG/MINOR: flt_trace/htx: Only apply the random forwarding on the message body. X-Git-Tag: v2.0-dev6~30 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0bdeeaacb;p=thirdparty%2Fhaproxy.git 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. --- diff --git a/src/flt_trace.c b/src/flt_trace.c index 4eb8d5fe6a..e001d7b370 100644 --- a/src/flt_trace.c +++ b/src/flt_trace.c @@ -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",