aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBilly McFall <bmcfall@redhat.com>2016-10-14 07:37:33 -0400
committerDave Barach <openvpp@barachs.net>2016-10-14 13:51:45 +0000
commit309fe069dbfc36cf2274cd70ea43a1f2f9cce507 (patch)
treeba1119950d9ca14fc0605e5bad11dca001554e01
parentb80c536e34b610ca77cd84448754e4bd9c46cf68 (diff)
VPP-489: CLI Command "test lookup" crashes with invalid fib-index.
Change-Id: If4c47b91e949483675cf569cd474b6c85fecef05 Signed-off-by: Billy McFall <bmcfall@redhat.com>
-rw-r--r--vnet/vnet/ip/ip4_forward.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c
index b0390b8a..6a2b58c0 100644
--- a/vnet/vnet/ip/ip4_forward.c
+++ b/vnet/vnet/ip/ip4_forward.c
@@ -2989,6 +2989,7 @@ test_lookup_command_fn (vlib_main_t * vm,
unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ ip4_fib_t *fib;
u32 table_id = 0;
f64 count = 1;
u32 n;
@@ -2998,7 +2999,13 @@ test_lookup_command_fn (vlib_main_t * vm,
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT) {
if (unformat (input, "table %d", &table_id))
- ;
+ {
+ /* Make sure the entry exists. */
+ fib = ip4_fib_get(table_id);
+ if ((fib) && (fib->index != table_id))
+ return clib_error_return (0, "<fib-index> %d does not exist",
+ table_id);
+ }
else if (unformat (input, "count %f", &count))
;