mirror of
https://git.haproxy.org/git/haproxy.git/
synced 2025-08-07 23:56:57 +02:00
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:
parent
c31872fc04
commit
0bdeeaacbb
@ -464,8 +464,32 @@ trace_http_payload(struct stream *s, struct filter *filter, struct http_msg *msg
|
|||||||
struct trace_config *conf = FLT_CONF(filter);
|
struct trace_config *conf = FLT_CONF(filter);
|
||||||
int ret = len;
|
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);
|
ret = random() % (ret+1);
|
||||||
|
if (ret > data)
|
||||||
|
ret = len;
|
||||||
|
}
|
||||||
|
|
||||||
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
|
STRM_TRACE(conf, s, "%-25s: channel=%-10s - mode=%-5s (%s) - "
|
||||||
"offset=%u - len=%u - forward=%d",
|
"offset=%u - len=%u - forward=%d",
|
||||||
|
Loading…
Reference in New Issue
Block a user