VPP-489: CLI Command "test lookup" crashes with invalid fib-index. 24/3424/2
authorBilly McFall <bmcfall@redhat.com>
Fri, 14 Oct 2016 11:37:33 +0000 (07:37 -0400)
committerDave Barach <openvpp@barachs.net>
Fri, 14 Oct 2016 13:51:45 +0000 (13:51 +0000)
Change-Id: If4c47b91e949483675cf569cd474b6c85fecef05
Signed-off-by: Billy McFall <bmcfall@redhat.com>
vnet/vnet/ip/ip4_forward.c

index b0390b8..6a2b58c 100644 (file)
@@ -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))
        ;