sr: some fixes for SRv6 CLI/API 64/23864/4
authorAhmed Abdelsalam <ahabdels@cisco.com>
Sun, 8 Dec 2019 11:58:27 +0000 (12:58 +0100)
committerNeale Ranns <nranns@cisco.com>
Thu, 16 Jan 2020 20:31:08 +0000 (20:31 +0000)
Return FIB table_id instead of vrf_index to clients

Type: fix
Signed-off-by: Ahmed Abdelsalam <ahabdels@cisco.com>
Change-Id: I76a97bad3ecd3ac8eb045efb1657eaa90c2a57b6

src/vnet/srv6/sr_api.c
src/vnet/srv6/sr_localsid.c

index ffd0c4d..606eaa6 100644 (file)
@@ -24,6 +24,7 @@
 #include <vnet/interface.h>
 #include <vnet/api_errno.h>
 #include <vnet/feature/feature.h>
+#include <vnet/fib/fib_table.h>
 
 #include <vnet/vnet_msg_enum.h>
 
@@ -239,7 +240,16 @@ static void send_sr_localsid_details
   else
     clib_memcpy (rmp->xconnect_nh_addr6, &t->next_hop.ip6,
                 sizeof (ip6_address_t));
-  rmp->xconnect_iface_or_vrf_table = htonl (t->sw_if_index);
+
+  if (t->behavior == SR_BEHAVIOR_T || t->behavior == SR_BEHAVIOR_DT6)
+    rmp->xconnect_iface_or_vrf_table =
+      htonl (fib_table_get_table_id (t->sw_if_index, FIB_PROTOCOL_IP6));
+  else if (t->behavior == SR_BEHAVIOR_DT4)
+    rmp->xconnect_iface_or_vrf_table =
+      htonl (fib_table_get_table_id (t->sw_if_index, FIB_PROTOCOL_IP4));
+  else
+    rmp->xconnect_iface_or_vrf_table = htonl (t->sw_if_index);
+
   rmp->context = context;
 
   vl_api_send_msg (reg, (u8 *) rmp);
index 05651bb..79e4c2a 100755 (executable)
@@ -504,7 +504,9 @@ show_sr_localsid_command_fn (vlib_main_t * vm, unformat_input_t * input,
          vlib_cli_output (vm,
                           "\tAddress: \t%U\n\tBehavior: \tT (Endpoint with specific IPv6 table lookup)"
                           "\n\tTable:  \t%u",
-                          format_ip6_address, &ls->localsid, ls->vrf_index);
+                          format_ip6_address, &ls->localsid,
+                          fib_table_get_table_id (ls->vrf_index,
+                                                  FIB_PROTOCOL_IP6));
          break;
        case SR_BEHAVIOR_DX4:
          vlib_cli_output (vm,
@@ -537,13 +539,16 @@ show_sr_localsid_command_fn (vlib_main_t * vm, unformat_input_t * input,
          vlib_cli_output (vm,
                           "\tAddress: \t%U\n\tBehavior: \tDT6 (Endpoint with decapsulation and specific IPv6 table lookup)"
                           "\n\tTable: %u", format_ip6_address, &ls->localsid,
-                          ls->vrf_index);
+                          fib_table_get_table_id (ls->vrf_index,
+                                                  FIB_PROTOCOL_IP6));
          break;
        case SR_BEHAVIOR_DT4:
          vlib_cli_output (vm,
                           "\tAddress: \t%U\n\tBehavior: \tDT4 (Endpoint with decapsulation and specific IPv4 table lookup)"
                           "\n\tTable: \t%u", format_ip6_address,
-                          &ls->localsid, ls->vrf_index);
+                          &ls->localsid,
+                          fib_table_get_table_id (ls->vrf_index,
+                                                  FIB_PROTOCOL_IP4));
          break;
        default:
          if (ls->behavior >= SR_BEHAVIOR_LAST)