DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] lib/librte_meter: fix divide by zero for RFC4115 meter
@ 2019-02-01 15:59 Eelco Chaudron
  0 siblings, 0 replies; only message in thread
From: Eelco Chaudron @ 2019-02-01 15:59 UTC (permalink / raw)
  To: cristian.dumitrescu; +Cc: dev

RFC 4115 allows a meter with either cir and/or eir configured.
When only one is configured a divide by zero would occur.

Fixes: 655796d2b5fb ("meter: support RFC4115 trTCM")
Cc: echaudro@redhat.com

Signed-off-by: Eelco Chaudron <echaudro@redhat.com>
---
 config/common_linuxapp       |    4 ++--
 lib/librte_meter/rte_meter.h |    8 ++++----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/config/common_linuxapp b/config/common_linuxapp
index 6c1c8d0f4..186323993 100644
--- a/config/common_linuxapp
+++ b/config/common_linuxapp
@@ -7,9 +7,9 @@ CONFIG_RTE_EXEC_ENV="linuxapp"
 CONFIG_RTE_EXEC_ENV_LINUXAPP=y
 
 CONFIG_RTE_EAL_NUMA_AWARE_HUGEPAGES=y
-CONFIG_RTE_EAL_IGB_UIO=y
+CONFIG_RTE_EAL_IGB_UIO=n
 CONFIG_RTE_EAL_VFIO=y
-CONFIG_RTE_KNI_KMOD=y
+CONFIG_RTE_KNI_KMOD=n
 CONFIG_RTE_LIBRTE_KNI=y
 CONFIG_RTE_LIBRTE_PMD_KNI=y
 CONFIG_RTE_LIBRTE_VHOST=y
diff --git a/lib/librte_meter/rte_meter.h b/lib/librte_meter/rte_meter.h
index 005e4eeee..56d85ecf0 100644
--- a/lib/librte_meter/rte_meter.h
+++ b/lib/librte_meter/rte_meter.h
@@ -597,8 +597,8 @@ rte_meter_trtcm_rfc4115_color_blind_check(
 	/* Bucket update */
 	time_diff_tc = time - m->time_tc;
 	time_diff_te = time - m->time_te;
-	n_periods_tc = time_diff_tc / p->cir_period;
-	n_periods_te = time_diff_te / p->eir_period;
+	n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : 0;
+	n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : 0;
 	m->time_tc += n_periods_tc * p->cir_period;
 	m->time_te += n_periods_te * p->eir_period;
 
@@ -641,8 +641,8 @@ rte_meter_trtcm_rfc4115_color_aware_check(
 	/* Bucket update */
 	time_diff_tc = time - m->time_tc;
 	time_diff_te = time - m->time_te;
-	n_periods_tc = time_diff_tc / p->cir_period;
-	n_periods_te = time_diff_te / p->eir_period;
+	n_periods_tc = p->cir_period != 0 ? time_diff_tc / p->cir_period : 0;
+	n_periods_te = p->eir_period != 0 ? time_diff_te / p->eir_period : 0;
 	m->time_tc += n_periods_tc * p->cir_period;
 	m->time_te += n_periods_te * p->eir_period;
 

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2019-02-01 15:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-01 15:59 [dpdk-dev] [PATCH] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).