Add more CLI options to vpp_api_test for calling ip_add_del_route 24/14924/3
authorJohn Lo <loj@cisco.com>
Thu, 20 Sep 2018 20:07:00 +0000 (16:07 -0400)
committerNeale Ranns <nranns@cisco.com>
Fri, 21 Sep 2018 08:18:34 +0000 (08:18 +0000)
Change-Id: I114e93b6bc71cfcdcfe6d3ddde26f77118e36ab8
Signed-off-by: John Lo <loj@cisco.com>
src/vat/api_format.c
src/vpp/api/custom_dump.c

index 61b3497..0a01989 100644 (file)
@@ -8486,6 +8486,8 @@ api_ip_add_del_route (vat_main_t * vam)
   mpls_label_t next_hop_out_label = MPLS_LABEL_INVALID;
   mpls_label_t next_hop_via_label = MPLS_LABEL_INVALID;
 
+  memset (&v4_next_hop_address, 0, sizeof (ip4_address_t));
+  memset (&v6_next_hop_address, 0, sizeof (ip6_address_t));
   /* Parse args required to build the message */
   while (unformat_check_input (i) != UNFORMAT_END_OF_INPUT)
     {
@@ -8518,6 +8520,16 @@ api_ip_add_del_route (vat_main_t * vam)
        {
          next_hop_set = 1;
        }
+      else
+       if (unformat
+           (i, "via %U", api_unformat_sw_if_index, vam, &sw_if_index))
+       {
+         next_hop_set = 1;
+       }
+      else if (unformat (i, "via sw_if_index %d", &sw_if_index))
+       {
+         next_hop_set = 1;
+       }
       else if (unformat (i, "resolve-attempts %d", &resolve_attempts))
        ;
       else if (unformat (i, "weight %d", &next_hop_weight))
@@ -23509,8 +23521,8 @@ _(sw_interface_slave_dump,                                              \
 _(ip_table_add_del,                                                     \
   "table <n> [ipv6] [add | del]\n")                                     \
 _(ip_add_del_route,                                                     \
-  "<addr>/<mask> via <addr | via-label <n>> [table-id <n>]\n"           \
-  "[<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"               \
+  "<addr>/<mask> via <<addr>|<intfc>|sw_if_index <id>|via-label <n>>\n" \
+  "[table-id <n>] [<intfc> | sw_if_index <id>] [resolve-attempts <n>]\n"\
   "[weight <n>] [drop] [local] [classify <n>] [del]\n"                  \
   "[multipath] [count <n>]")                                            \
 _(ip_mroute_add_del,                                                    \
index 44aaf82..e40a7dc 100644 (file)
@@ -726,9 +726,6 @@ static void *vl_api_ip_add_del_route_t_print
   if (mp->is_add == 0)
     s = format (s, "del ");
 
-  if (mp->next_hop_sw_if_index != ~0)
-    s = format (s, "sw_if_index %d ", ntohl (mp->next_hop_sw_if_index));
-
   if (mp->is_ipv6)
     s = format (s, "%U/%d ", format_ip6_address, mp->dst_address,
                mp->dst_address_length);
@@ -753,6 +750,9 @@ static void *vl_api_ip_add_del_route_t_print
        s = format (s, "via %U ", format_ip6_address, mp->next_hop_address);
       else
        s = format (s, "via %U ", format_ip4_address, mp->next_hop_address);
+      if (mp->next_hop_sw_if_index != ~0)
+       s = format (s, "sw_if_index %d ", ntohl (mp->next_hop_sw_if_index));
+
     }
 
   if (mp->next_hop_weight != 1)