summaryrefslogtreecommitdiff
path: root/lib/librte_meter/rte_meter.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/librte_meter/rte_meter.c')
-rw-r--r--lib/librte_meter/rte_meter.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c
index e55f9be..4567944 100644
--- a/lib/librte_meter/rte_meter.c
+++ b/lib/librte_meter/rte_meter.c
@@ -19,7 +19,15 @@
static void
rte_meter_get_tb_params(uint64_t hz, uint64_t rate, uint64_t *tb_period, uint64_t *tb_bytes_per_period)
{
- double period = ((double) hz) / ((double) rate);
+ double period;
+
+ if (rate == 0) {
+ *tb_bytes_per_period = 0;
+ *tb_period = RTE_METER_TB_PERIOD_MIN;
+ return;
+ }
+
+ period = ((double) hz) / ((double) rate);
if (period >= RTE_METER_TB_PERIOD_MIN) {
*tb_bytes_per_period = 1;