Improve "show xxx tunnel" and "show int addr" output
[vpp.git] / src / vnet / vxlan-gpe / vxlan_gpe.c
index b0c6a68..918a982 100644 (file)
 
 vxlan_gpe_main_t vxlan_gpe_main;
 
-/**
- * @brief Tracing function for VXLAN GPE tunnel packets
- *
- * @param *s formatting string
- * @param *args
- *
- * @return *s formatted string
- *
- */
-u8 *
-format_vxlan_gpe_tunnel (u8 * s, va_list * args)
+static u8 *
+format_decap_next (u8 * s, va_list * args)
 {
   vxlan_gpe_tunnel_t *t = va_arg (*args, vxlan_gpe_tunnel_t *);
-  vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
-
-  s = format (s, "[%d] local: %U remote: %U ",
-             t - ngm->tunnels,
-             format_ip46_address, &t->local, IP46_TYPE_ANY,
-             format_ip46_address, &t->remote, IP46_TYPE_ANY);
-
-  s = format (s, "  vxlan VNI %d ", t->vni);
 
   switch (t->protocol)
     {
     case VXLAN_GPE_PROTOCOL_IP4:
-      s = format (s, "next-protocol ip4");
+      s = format (s, "protocol ip4 fib-idx %d", t->decap_fib_index);
       break;
     case VXLAN_GPE_PROTOCOL_IP6:
-      s = format (s, "next-protocol ip6");
+      s = format (s, "protocol ip6 fib-idx %d", t->decap_fib_index);
       break;
     case VXLAN_GPE_PROTOCOL_ETHERNET:
-      s = format (s, "next-protocol ethernet");
+      s = format (s, "protocol ethernet");
       break;
     case VXLAN_GPE_PROTOCOL_NSH:
-      s = format (s, "next-protocol nsh");
+      s = format (s, "protocol nsh");
       break;
     default:
-      s = format (s, "next-protocol unknown %d", t->protocol);
+      s = format (s, "protocol unknown %d", t->protocol);
     }
 
-  if (ip46_address_is_multicast (&t->remote))
-    s = format (s, "mcast_sw_if_index %d ", t->mcast_sw_if_index);
+  return s;
+}
+
+/**
+ * @brief Format function for VXLAN GPE tunnel
+ *
+ * @param *s formatting string
+ * @param *args
+ *
+ * @return *s formatted string
+ *
+ */
+u8 *
+format_vxlan_gpe_tunnel (u8 * s, va_list * args)
+{
+  vxlan_gpe_tunnel_t *t = va_arg (*args, vxlan_gpe_tunnel_t *);
+  vxlan_gpe_main_t *ngm = &vxlan_gpe_main;
 
-  s = format (s, " fibs: (encap %d, decap %d)",
-             t->encap_fib_index, t->decap_fib_index);
+  s = format (s, "[%d] lcl %U rmt %U vni %d fib-idx %d sw-if-idx %d ",
+             t - ngm->tunnels,
+             format_ip46_address, &t->local, IP46_TYPE_ANY,
+             format_ip46_address, &t->remote, IP46_TYPE_ANY,
+             t->vni, t->encap_fib_index, t->sw_if_index);
+
+#if 0
+  /* next_dpo not yet used by vxlan-gpe-encap node */
+  s = format (s, "encap-dpo-idx %d ", t->next_dpo.dpoi_index);
+  */
+#endif
+    s = format (s, "decap-next-%U ", format_decap_next, t);
+
+  if (PREDICT_FALSE (ip46_address_is_multicast (&t->remote)))
+    s = format (s, "mcast-sw-if-idx %d ", t->mcast_sw_if_index);
 
   return s;
 }