From patchwork Thu Dec 23 15:37:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Medvedkin X-Patchwork-Id: 105368 X-Patchwork-Delegate: david.marchand@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 72C11A0350; Thu, 23 Dec 2021 16:37:50 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F153A4068C; Thu, 23 Dec 2021 16:37:49 +0100 (CET) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by mails.dpdk.org (Postfix) with ESMTP id 7C0634067B; Thu, 23 Dec 2021 16:37:47 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1640273867; x=1671809867; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=Q4lLzK5Le+JkaLWC7EqA5QmOYt1eoSsHTMr7l4Vg2ig=; b=Z2jgB2i7DxADyvSI4/2YMdrB/3pJciIumDFmGfnjnWWijp+5z9vbdfKc 5XVcUhljTW16FZqR++GuCouUkKuvMG6ElIL4dgkClaWGiMNWBCR5VP8ay /23oHht+BOyIQBDpR6pCwxBB1/RNaemH0sQEREPvMgt7KtNG/bwb3u6pt PpAVn0d9TxoVBOzbYmHQx7v9ImA3XjHbRwfSHgUcVlfBFo5mgi/dJMcrU QOcgentsU3VEZmb8+o+4vFE5CeazThqn1VL8NmKVIRkCXvI7NY9x/ElpP r+j0is3mUbftKtwtgKHk6+bBDFXBVlK+QPSOTOzlsNRNaf8lB5WikC15i w==; X-IronPort-AV: E=McAfee;i="6200,9189,10206"; a="241064896" X-IronPort-AV: E=Sophos;i="5.88,229,1635231600"; d="scan'208";a="241064896" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Dec 2021 07:37:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.88,229,1635231600"; d="scan'208";a="508889867" Received: from silpixa00400072.ir.intel.com (HELO silpixa00400072.ger.corp.intel.com) ([10.237.222.91]) by orsmga007.jf.intel.com with ESMTP; 23 Dec 2021 07:37:45 -0800 From: Vladimir Medvedkin To: dev@dpdk.org Cc: stable@dpdk.org Subject: [PATCH v2] app/test-fib: fix possible division by zero Date: Thu, 23 Dec 2021 15:37:42 +0000 Message-Id: <20211223153742.760838-1-vladimir.medvedkin@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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: stable@dpdk.org 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; } }