From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by dpdk.org (Postfix) with ESMTP id B2C6C1B4DE for ; Fri, 1 Feb 2019 16:59:59 +0100 (CET) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E0FA6A7878; Fri, 1 Feb 2019 15:59:58 +0000 (UTC) Received: from localhost.localdomain (ovpn-116-117.ams2.redhat.com [10.36.116.117]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27BC560C76; Fri, 1 Feb 2019 15:59:57 +0000 (UTC) From: Eelco Chaudron To: cristian.dumitrescu@intel.com Cc: dev@dpdk.org Date: Fri, 1 Feb 2019 15:59:33 +0000 Message-Id: <154903677150.46295.18413598190427874662.stgit@dbuild> User-Agent: StGit/unknown-version MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Fri, 01 Feb 2019 15:59:59 +0000 (UTC) Subject: [dpdk-dev] [PATCH] lib/librte_meter: fix divide by zero for RFC4115 meter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Feb 2019 16:00:00 -0000 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 --- 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;