From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6264EA0350; Thu, 23 Dec 2021 16:25:33 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id DFB7240DDA; Thu, 23 Dec 2021 16:25:32 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 0ECE44068C for ; Thu, 23 Dec 2021 16:25:30 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640273131; x=1671809131; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=LuLRSC0267Uu+kJtrgQ5t3H7fogJFYbhlxWyrKBG9ek=; b=hKUsJCp3Rs51agUok59w/HwEzug3a2VkIaeNVlAR3+FAmwqR4RSb9PhA aZdQAMFasfW/WTIDWM7bGZaLPVRAM1kmaRgMDZoR8mvE/e5uAjEOoQT1X EwGjCXxL2J9uqa1DC1IAjCMo1vAqMDpz4VmmUchbJGvxC7CTTY5bpySnR 8XCLr6fvYyLHhBeeBsSKIZ3ntR9PO9glTBOGXYG9z5knc1Q7Sxx4Vffp6 weI8sS5t8w8/tC6VTZJV46VjMu4gdU0vggDpJwcsmgppb+j5k2lF97D92 NNgXRV69Boy6cnQ8kyvK78DArxjNTd3/uATkBqEW0bOAC4O9X9RNvmi+l A==; X-IronPort-AV: E=McAfee;i="6200,9189,10206"; a="241063411" X-IronPort-AV: E=Sophos;i="5.88,229,1635231600"; d="scan'208";a="241063411" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Dec 2021 07:25:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,229,1635231600"; d="scan'208";a="468566698" Received: from silpixa00400072.ir.intel.com (HELO silpixa00400072.ger.corp.intel.com) ([10.237.222.91]) by orsmga006.jf.intel.com with ESMTP; 23 Dec 2021 07:25:27 -0800 From: Vladimir Medvedkin To: dev@dpdk.org Cc: vladimir.medvedkin@intel.com Subject: [PATCH] app/test-fib: fix possible division by zero Date: Thu, 23 Dec 2021 15:25:17 +0000 Message-Id: <20211223152519.758827-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch fixes the division by 0, which occurs if the number of routes is less than 10. Can be triggered by passing -n argument with value < 10: ./dpdk-test-fib -- -n 9 ... Floating point exception (core dumped) Fixes: 103809d032cd ("app/test-fib: add test application for FIB") Cc: vladimir.medvedkin@intel.com Signed-off-by: Vladimir Medvedkin --- app/test-fib/main.c | 40 ++++++++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 16 deletions(-) diff --git a/app/test-fib/main.c b/app/test-fib/main.c index ecd420116a..9bc8b8a7ca 100644 --- a/app/test-fib/main.c +++ b/app/test-fib/main.c @@ -902,8 +902,9 @@ run_v4(void) return -ret; } } - printf("AVG FIB add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -930,8 +931,9 @@ run_v4(void) return -ret; } } - printf("AVG LPM add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -984,8 +986,9 @@ run_v4(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -996,8 +999,9 @@ run_v4(void) rte_lpm_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -1097,8 +1101,9 @@ run_v6(void) return -ret; } } - printf("AVG FIB add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1125,8 +1130,9 @@ run_v6(void) return -ret; } } - printf("AVG LPM add %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM add %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } @@ -1183,8 +1189,9 @@ run_v6(void) for (j = 0; j < (config.nb_routes - i) / k; j++) rte_fib6_delete(fib, rt[i + j].addr, rt[i + j].depth); - printf("AVG FIB delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG FIB delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } @@ -1195,8 +1202,9 @@ run_v6(void) rte_lpm6_delete(lpm, rt[i + j].addr, rt[i + j].depth); - printf("AVG LPM delete %"PRIu64"\n", - (rte_rdtsc_precise() - start) / j); + if (j != 0) + printf("AVG LPM delete %"PRIu64"\n", + (rte_rdtsc_precise() - start) / j); i += j; } } -- 2.25.1