summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWilliam Tu <u9012063@gmail.com>2019-04-19 15:26:41 -0700
committerBen Pfaff <blp@ovn.org>2019-04-22 10:01:05 -0700
commita631ef76b6bd3e11988e2c847d1405e839d74f0d (patch)
treed6fb1209aa6fcd2df6368c779ac588fca93c4a9b
parent6b14ed0393af98c4067930fad2133ab7e5e0d39b (diff)
downloadopenvswitch-a631ef76b6bd3e11988e2c847d1405e839d74f0d.tar.gz
dpif-netdev: fix meter at high packet rate.
When testing packet rate around 1Mpps with meter enabled, the frequency of hitting meter action becomes much higher, around 30us each time. As a result, the meter's calculation of 'uint32_t delta_t' becomes always 0 and meter action has no effect. This is due to the previous commit 05f9e707e194 divides the delta by 1000, in order to convert to msec granularity. The patch fixes it updating the time when across millisecond boundary. Fixes: 05f9e707e194 ("dpif-netdev: Use microsecond granularity.") Acked-by: Yi-Hung Wei <yihung.wei@gmail.com> Acked-by: Ilya Maximets <i.maximets@samsung.com> Signed-off-by: William Tu <u9012063@gmail.com> Signed-off-by: Ben Pfaff <blp@ovn.org>
-rw-r--r--lib/dpif-netdev.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/dpif-netdev.c b/lib/dpif-netdev.c
index 335fadcaa..059370f29 100644
--- a/lib/dpif-netdev.c
+++ b/lib/dpif-netdev.c
@@ -5547,7 +5547,7 @@ dp_netdev_run_meter(struct dp_netdev *dp, struct dp_packet_batch *packets_,
memset(exceeded_rate, 0, cnt * sizeof *exceeded_rate);
/* All packets will hit the meter at the same time. */
- long_delta_t = (now - meter->used) / 1000; /* msec */
+ long_delta_t = now / 1000 - meter->used / 1000; /* msec */
/* Make sure delta_t will not be too large, so that bucket will not
* wrap around below. */