gtpu: encap-vrf-id in show gtpu tunnels command 13/25713/3
authorNick Zavaritsky <nick.zavaritsky@emnify.com>
Thu, 5 Mar 2020 17:24:37 +0000 (17:24 +0000)
committerDamjan Marion <dmarion@me.com>
Sat, 21 Mar 2020 12:13:36 +0000 (12:13 +0000)
Show encap-vrf-id instead of fib-idx.  When a tunnel is created, you
specify encap-vrf-id, hence it makes sense for the show command to
present it the same way.  Fib index, on the other hand, is the internal
artifact of how IP tables are managed; showing it isn't helpful.

Type: improvement
Change-Id: I8d1713d6727dd8685d6c10c07f421c18edafa6e0
Signed-off-by: Nick Zavaritsky <nick.zavaritsky@emnify.com>
src/plugins/gtpu/gtpu.c

index baa4d24..7aa374f 100644 (file)
@@ -87,12 +87,19 @@ format_gtpu_tunnel (u8 * s, va_list * args)
 {
   gtpu_tunnel_t *t = va_arg (*args, gtpu_tunnel_t *);
   gtpu_main_t *ngm = &gtpu_main;
+  ip4_main_t *im4 = &ip4_main;
+  ip6_main_t *im6 = &ip6_main;
+  u8 is_ipv6 = !ip46_address_is_ip4 (&t->dst);
 
-  s = format (s, "[%d] src %U dst %U teid %d fib-idx %d sw-if-idx %d ",
+  u32 encap_vrf_id =
+    is_ipv6 ? im6->fibs[t->encap_fib_index].ft_table_id :
+    im4->fibs[t->encap_fib_index].ft_table_id;
+
+  s = format (s, "[%d] src %U dst %U teid %d encap-vrf-id %d sw-if-idx %d ",
              t - ngm->tunnels,
              format_ip46_address, &t->src, IP46_TYPE_ANY,
              format_ip46_address, &t->dst, IP46_TYPE_ANY,
-             t->teid,  t->encap_fib_index, t->sw_if_index);
+             t->teid,  encap_vrf_id, t->sw_if_index);
 
   s = format (s, "encap-dpo-idx %d ", t->next_dpo.dpoi_index);
   s = format (s, "decap-next-%U ", format_decap_next, t->decap_next_index);