* [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter
@ 2019-03-19 12:10 Eelco Chaudron
2019-03-19 12:10 ` Eelco Chaudron
2019-03-29 20:04 ` Dumitrescu, Cristian
0 siblings, 2 replies; 4+ messages in thread
From: Eelco Chaudron @ 2019-03-19 12:10 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>
---
v3 - Rather than using a 0 check, set up profile data such that no
check at runtime is needed.
v2 - Removed configuration change that got included by accident
lib/librte_meter/rte_meter.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c
index e55f9be65..45679444e 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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter
2019-03-19 12:10 [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron
@ 2019-03-19 12:10 ` Eelco Chaudron
2019-03-29 20:04 ` Dumitrescu, Cristian
1 sibling, 0 replies; 4+ messages in thread
From: Eelco Chaudron @ 2019-03-19 12:10 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>
---
v3 - Rather than using a 0 check, set up profile data such that no
check at runtime is needed.
v2 - Removed configuration change that got included by accident
lib/librte_meter/rte_meter.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/lib/librte_meter/rte_meter.c b/lib/librte_meter/rte_meter.c
index e55f9be65..45679444e 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;
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter
2019-03-19 12:10 [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron
2019-03-19 12:10 ` Eelco Chaudron
@ 2019-03-29 20:04 ` Dumitrescu, Cristian
2019-03-29 20:04 ` Dumitrescu, Cristian
1 sibling, 1 reply; 4+ messages in thread
From: Dumitrescu, Cristian @ 2019-03-29 20:04 UTC (permalink / raw)
To: Eelco Chaudron; +Cc: dev
> -----Original Message-----
> From: Eelco Chaudron [mailto:echaudro@redhat.com]
> Sent: Tuesday, March 19, 2019 12:11 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter
>
> 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>
>
> ---
> v3 - Rather than using a 0 check, set up profile data such that no
> check at runtime is needed.
> v2 - Removed configuration change that got included by accident
>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Applied to the next-qos tree, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter
2019-03-29 20:04 ` Dumitrescu, Cristian
@ 2019-03-29 20:04 ` Dumitrescu, Cristian
0 siblings, 0 replies; 4+ messages in thread
From: Dumitrescu, Cristian @ 2019-03-29 20:04 UTC (permalink / raw)
To: Eelco Chaudron; +Cc: dev
> -----Original Message-----
> From: Eelco Chaudron [mailto:echaudro@redhat.com]
> Sent: Tuesday, March 19, 2019 12:11 PM
> To: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Cc: dev@dpdk.org
> Subject: [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter
>
> 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>
>
> ---
> v3 - Rather than using a 0 check, set up profile data such that no
> check at runtime is needed.
> v2 - Removed configuration change that got included by accident
>
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
Applied to the next-qos tree, thanks!
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2019-03-29 20:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-19 12:10 [dpdk-dev] [PATCH v3] lib/librte_meter: fix divide by zero for RFC4115 meter Eelco Chaudron
2019-03-19 12:10 ` Eelco Chaudron
2019-03-29 20:04 ` Dumitrescu, Cristian
2019-03-29 20:04 ` Dumitrescu, Cristian
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).