summaryrefslogtreecommitdiff
path: root/trafgen_parser.y
diff options
context:
space:
mode:
authorPaolo Abeni <pabeni@redhat.com>2017-12-14 13:04:12 +0100
committerTobias Klauser <tklauser@distanz.ch>2017-12-14 15:45:08 +0100
commite207624c6d92e9c2979e1e310cab660f0320ca48 (patch)
tree7ebcbe0596dae05d2449a6a2d75c42658cda838e /trafgen_parser.y
parentfe87d2b6117de1e32769b388fe1704440e339d27 (diff)
trafgen: fix dinc()/ddec() modifiers
currently, after dinc(), the valued stored inside the packet is not in the (min, max) range but in the (0, max - min + 1) range, 'counter->val' should be used instead of 'val'. Additionally the values computed for ddec() are corrupted, in: val = (val - counter->inc) % (counter->min - counter->max + 1); the divider is negative, we should use (counter->max - counter->min + 1) as in the INC case. Finally we can avoid the switch statement at update time, inverting the value of 'counter->inc' for decrement and using a data type wide enough for the 'inc' field. v1 -> v2: - changed 'counter->inc' type to int Signed-off-by: Paolo Abeni <pabeni@redhat.com> Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'trafgen_parser.y')
-rw-r--r--trafgen_parser.y2
1 files changed, 1 insertions, 1 deletions
diff --git a/trafgen_parser.y b/trafgen_parser.y
index a42dc30..4d83af6 100644
--- a/trafgen_parser.y
+++ b/trafgen_parser.y
@@ -147,7 +147,7 @@ static inline void __setup_new_counter(struct counter *c, uint8_t start,
{
c->min = start;
c->max = stop;
- c->inc = stepping;
+ c->inc = (type == TYPE_INC) ? stepping : -stepping;
c->val = (type == TYPE_INC) ? start : stop;
c->off = payload_last;
c->type = type;