From: Billy McFall Date: Fri, 14 Oct 2016 11:37:33 +0000 (-0400) Subject: VPP-489: CLI Command "test lookup" crashes with invalid fib-index. X-Git-Tag: v17.01-rc0~86 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=309fe069dbfc36cf2274cd70ea43a1f2f9cce507;p=vpp.git VPP-489: CLI Command "test lookup" crashes with invalid fib-index. Change-Id: If4c47b91e949483675cf569cd474b6c85fecef05 Signed-off-by: Billy McFall --- diff --git a/vnet/vnet/ip/ip4_forward.c b/vnet/vnet/ip/ip4_forward.c index b0390b8a44a..6a2b58c0d09 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, " %d does not exist", + table_id); + } else if (unformat (input, "count %f", &count)) ;