Skip to content

Commit

Permalink
app/fib: fix division by zero
Browse files Browse the repository at this point in the history
[ upstream commit a01070d ]

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: 103809d ("app/test-fib: add test application for FIB")

Signed-off-by: Vladimir Medvedkin <vladimir.medvedkin@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
  • Loading branch information
vmedvedk authored and bluca committed Feb 17, 2022
1 parent 1b84be5 commit 32d2194
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/test-fib/main.c
Expand Up @@ -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;
Expand Down Expand Up @@ -1240,6 +1244,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);
}

Expand Down

0 comments on commit 32d2194

Please sign in to comment.