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 B760FA034C; Tue, 11 Jan 2022 17:15:08 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 43DF742733; Tue, 11 Jan 2022 17:15:08 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mails.dpdk.org (Postfix) with ESMTP id 3D13A41143 for ; Tue, 11 Jan 2022 17:15:07 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1641917706; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JhOVys+zh4EgJgdT6ZdBXC/z2BOUhWIdsJ2ssU6S+bE=; b=J8JzD7GwIeNJe6A+ARpHL8pT3cJbb+Biqhwfq3KAGLjtj3uKRg7WnuXcCOQ0iHk7IrCXRM StWIo6CUFpgZMiLhOrlq+6+2hzOpLShxOOEFVi9K9S683g0MvQDR2VDjYjliFvtARU1S20 Qb9V3Y0+bw3I6Qd+KAjnHZEaNE3kN/0= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-kzPHi7GRN3i-z76znydjVg-1; Tue, 11 Jan 2022 11:15:03 -0500 X-MC-Unique: kzPHi7GRN3i-z76znydjVg-1 Received: by mail-wm1-f70.google.com with SMTP id o18-20020a05600c511200b00345c1603997so3412067wms.1 for ; Tue, 11 Jan 2022 08:15:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:references:from:subject:in-reply-to :content-transfer-encoding; bh=JhOVys+zh4EgJgdT6ZdBXC/z2BOUhWIdsJ2ssU6S+bE=; b=uXKC6EKPztnGFVLRe8IwQ7+C7Jny51aAVhpQA8eWmy8coIyTpy6whyiepEZounN+w1 3l/RopJAAjZpnwwdHPUf62ME9Vbln8rzeEkMu3yJOSXlR6IvxUP9ApS4zIfi1TtosDT9 qI5ha66f14JEgZlxIrf2vPRXd8tiUbVTjCETmwlwTfcxtDpBygaGyWAC2JZNtHehnJ/K g4NXp3Mah/2R7Cnop5c2rIUBsUnALONssPDD9Cv3tD9gDPTFmPXZ6t7kCEv0eQw4QpOO pPh4c9RzSBXeW9fZx6cRxv/QkVbLY10UPnj4cblkUZIKT9RCQJVtUFelFfxcVk4b/0To vAyw== X-Gm-Message-State: AOAM532TPEaTnnFRwplr0LE7ovGxM73nRPI6pK5PQ9bY6SVkf0B5kTAl GtbUagPqbHd3hWEx5xlCMzSH+i6KNqI9OPcL4nbW92EloLdxNocajOF42A+HMF3HVWQZ73H3mOX NWhI= X-Received: by 2002:adf:b60e:: with SMTP id f14mr4619690wre.11.1641917702232; Tue, 11 Jan 2022 08:15:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKFsfKxsqoaw0GGp3pOBwf6+NxP9ZrBTEDaMYEoLMVZ6uDXgaHcS62qNuet77dWRcyFeHXSg== X-Received: by 2002:adf:b60e:: with SMTP id f14mr4619668wre.11.1641917701942; Tue, 11 Jan 2022 08:15:01 -0800 (PST) Received: from [192.168.0.36] ([78.19.108.41]) by smtp.gmail.com with ESMTPSA id i6sm11319109wrf.79.2022.01.11.08.15.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jan 2022 08:15:01 -0800 (PST) Message-ID: Date: Tue, 11 Jan 2022 16:15:00 +0000 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 To: Vladimir Medvedkin , dev@dpdk.org References: <20211223152519.758827-1-vladimir.medvedkin@intel.com> From: Kevin Traynor Subject: Re: [PATCH] app/test-fib: fix possible division by zero In-Reply-To: <20211223152519.758827-1-vladimir.medvedkin@intel.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=ktraynor@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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 On 23/12/2021 15:25, Vladimir Medvedkin wrote: > 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: > 9 causing a divide by zero - another example of inflation :-) > ./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 > You probably want to add 'Cc: stable@dpdk.org' for this. > 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); You are just not printing the result for these cases. Do you think it is worth to print a warning message (one), and update any documentation so the user is aware of the acceptable bounds? > 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; > } > } >