From: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
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 [thread overview]
Message-ID: <20211223153742.760838-1-vladimir.medvedkin@intel.com> (raw)
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 <vladimir.medvedkin@intel.com>
---
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
next reply other threads:[~2021-12-23 15:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-23 15:37 Vladimir Medvedkin [this message]
2022-01-27 18:08 ` [PATCH v3] " Vladimir Medvedkin
2022-01-28 17:44 ` Kevin Traynor
2022-02-11 7:55 ` David Marchand
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20211223153742.760838-1-vladimir.medvedkin@intel.com \
--to=vladimir.medvedkin@intel.com \
--cc=dev@dpdk.org \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).