]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MEDIUM: peers: fix incorrect age in frequency counters
authorWilly Tarreau <w@1wt.eu>
Fri, 25 Mar 2016 17:17:47 +0000 (18:17 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 25 Mar 2016 17:17:47 +0000 (18:17 +0100)
The frequency counters's window start is sent as "now - freq.date",
which is a positive age compared to the current date. But on receipt,
this age was added to the current date instead of subtracted. So
since the date was always in the future, they were always expired if
the activity changed side in less than the counter's measuring period
(eg: 10s).

This bug was reported by Christian Ruppert who also provided an easy
reproducer.

It needs to be backported to 1.6.

src/peers.c

index 295a0a5a420126d3b2ea182bf2902f33ab9cedeb..d3fef4ae3f4b984c2b85e99a7b4aa628178c2a2c 100644 (file)
@@ -1152,7 +1152,7 @@ switchstate:
                                                                        case STD_T_FRQP: {
                                                                                struct freq_ctr_period data;
 
-                                                                               data.curr_tick = tick_add(now_ms, intdecode(&msg_cur, msg_end));
+                                                                               data.curr_tick = tick_add(now_ms, -intdecode(&msg_cur, msg_end));
                                                                                if (!msg_cur) {
                                                                                        /* malformed message */
                                                                                        appctx->st0 = PEER_SESS_ST_ERRPROTO;