* [PATCH v2] app/test-fib: fix possible division by zero
@ 2021-12-23 15:37 Vladimir Medvedkin
2022-01-27 18:08 ` [PATCH v3] " Vladimir Medvedkin
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Medvedkin @ 2021-12-23 15:37 UTC (permalink / raw)
To: dev; +Cc: stable
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH v3] app/test-fib: fix possible division by zero
2021-12-23 15:37 [PATCH v2] app/test-fib: fix possible division by zero Vladimir Medvedkin
@ 2022-01-27 18:08 ` Vladimir Medvedkin
2022-01-28 17:44 ` Kevin Traynor
0 siblings, 1 reply; 4+ messages in thread
From: Vladimir Medvedkin @ 2022-01-27 18:08 UTC (permalink / raw)
To: dev; +Cc: stable
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 | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/app/test-fib/main.c b/app/test-fib/main.c
index ecd420116a..067c5284f9 100644
--- a/app/test-fib/main.c
+++ b/app/test-fib/main.c
@@ -711,6 +711,10 @@ parse_opts(int argc, char **argv)
print_usage();
rte_exit(-EINVAL, "Invalid option -n\n");
}
+
+ if (config.nb_routes < config.print_fract)
+ config.print_fract = config.nb_routes;
+
break;
case 'd':
distrib_string = optarg;
@@ -1242,6 +1246,10 @@ main(int argc, char **argv)
config.nb_routes = 0;
while (fgets(line, sizeof(line), fr) != NULL)
config.nb_routes++;
+
+ if (config.nb_routes < config.print_fract)
+ config.print_fract = config.nb_routes;
+
rewind(fr);
}
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] app/test-fib: fix possible division by zero
2022-01-27 18:08 ` [PATCH v3] " Vladimir Medvedkin
@ 2022-01-28 17:44 ` Kevin Traynor
2022-02-11 7:55 ` David Marchand
0 siblings, 1 reply; 4+ messages in thread
From: Kevin Traynor @ 2022-01-28 17:44 UTC (permalink / raw)
To: Vladimir Medvedkin, dev; +Cc: stable
On 27/01/2022 18:08, 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:
>
> ./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>
> ---
This looks a better solution, and thanks for adding the tags.
Acked-by: Kevin Traynor <ktraynor@redhat.com>
> app/test-fib/main.c | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/app/test-fib/main.c b/app/test-fib/main.c
> index ecd420116a..067c5284f9 100644
> --- a/app/test-fib/main.c
> +++ b/app/test-fib/main.c
> @@ -711,6 +711,10 @@ parse_opts(int argc, char **argv)
> print_usage();
> rte_exit(-EINVAL, "Invalid option -n\n");
> }
> +
> + if (config.nb_routes < config.print_fract)
> + config.print_fract = config.nb_routes;
> +
> break;
> case 'd':
> distrib_string = optarg;
> @@ -1242,6 +1246,10 @@ main(int argc, char **argv)
> config.nb_routes = 0;
> while (fgets(line, sizeof(line), fr) != NULL)
> config.nb_routes++;
> +
> + if (config.nb_routes < config.print_fract)
> + config.print_fract = config.nb_routes;
> +
> rewind(fr);
> }
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v3] app/test-fib: fix possible division by zero
2022-01-28 17:44 ` Kevin Traynor
@ 2022-02-11 7:55 ` David Marchand
0 siblings, 0 replies; 4+ messages in thread
From: David Marchand @ 2022-02-11 7:55 UTC (permalink / raw)
To: Vladimir Medvedkin; +Cc: dev, dpdk stable, Kevin Traynor
On Fri, Jan 28, 2022 at 6:44 PM Kevin Traynor <ktraynor@redhat.com> wrote:
>
> On 27/01/2022 18:08, 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:
> >
> > ./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>
> Acked-by: Kevin Traynor <ktraynor@redhat.com>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-11 7:56 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23 15:37 [PATCH v2] app/test-fib: fix possible division by zero Vladimir Medvedkin
2022-01-27 18:08 ` [PATCH v3] " Vladimir Medvedkin
2022-01-28 17:44 ` Kevin Traynor
2022-02-11 7:55 ` David Marchand
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).