ip: improve ip ACL traces 48/36348/3
authorBenoît Ganne <bganne@cisco.com>
Wed, 8 Jun 2022 08:56:33 +0000 (10:56 +0200)
committerNeale Ranns <neale@graphiant.com>
Fri, 10 Jun 2022 01:09:57 +0000 (01:09 +0000)
Type: improvement

Change-Id: I85c73cb940d81d0b249eda0d57de135bcd798418
Signed-off-by: Benoît Ganne <bganne@cisco.com>
src/vnet/classify/vnet_classify.c
src/vnet/classify/vnet_classify.h
src/vnet/ip/ip_in_out_acl.c

index c9a6fc6..479d302 100644 (file)
@@ -660,8 +660,8 @@ vnet_classify_find_entry (vnet_classify_table_t * t,
   return vnet_classify_find_entry_inline (t, h, hash, now);
 }
 
-static u8 *
-format_classify_entry (u8 * s, va_list * args)
+u8 *
+format_classify_entry (u8 *s, va_list *args)
 {
   vnet_classify_table_t *t = va_arg (*args, vnet_classify_table_t *);
   vnet_classify_entry_t *e = va_arg (*args, vnet_classify_entry_t *);
index 17a728d..c61ec8f 100644 (file)
@@ -239,6 +239,7 @@ struct _vnet_classify_main
 
 extern vnet_classify_main_t vnet_classify_main;
 
+u8 *format_classify_entry (u8 *s, va_list *args);
 u8 *format_classify_table (u8 * s, va_list * args);
 u8 *format_vnet_classify_table (u8 *s, va_list *args);
 
index 500eefd..9fc0717 100644 (file)
@@ -32,11 +32,26 @@ format_ip_in_out_acl_trace (u8 * s, u32 is_output, va_list * args)
   CLIB_UNUSED (vlib_main_t * vm) = va_arg (*args, vlib_main_t *);
   CLIB_UNUSED (vlib_node_t * node) = va_arg (*args, vlib_node_t *);
   ip_in_out_acl_trace_t *t = va_arg (*args, ip_in_out_acl_trace_t *);
-
-  s = format (s, "%s: sw_if_index %d, next_index %d, table %d, offset %d",
-             is_output ? "OUTACL" : "INACL",
-             t->sw_if_index, t->next_index, t->table_index, t->offset);
-  return s;
+  const vnet_classify_main_t *vcm = &vnet_classify_main;
+  const u32 indent = format_get_indent (s);
+  vnet_classify_table_t *table;
+  vnet_classify_entry_t *e;
+
+  s =
+    format (s, "%s: sw_if_index %d, next_index %d, table_index %d, offset %d",
+           is_output ? "OUTACL" : "INACL", t->sw_if_index, t->next_index,
+           t->table_index, t->offset);
+
+  if (pool_is_free_index (vcm->tables, t->table_index))
+    return format (s, "\n%Uno table", format_white_space, indent + 4);
+
+  if (~0 == t->offset)
+    return format (s, "\n%Uno match", format_white_space, indent + 4);
+
+  table = vnet_classify_table_get (t->table_index);
+  e = vnet_classify_get_entry (table, t->offset);
+  return format (s, "\n%U%U", format_white_space, indent + 4,
+                format_classify_entry, table, e);
 }
 
 static u8 *
@@ -496,7 +511,7 @@ ip_in_out_acl_inline_trace (
          _t->sw_if_index =
            ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way];
          _t->next_index = _next[0];
-         _t->table_index = t[0] ? t[0] - tables : ~0;
+         _t->table_index = table_index[0];
          _t->offset = (e[0]
                        && t[0]) ? vnet_classify_get_offset (t[0], e[0]) : ~0;
        }
@@ -508,7 +523,7 @@ ip_in_out_acl_inline_trace (
          _t->sw_if_index =
            ~0 == way ? 0 : vnet_buffer (b[1])->sw_if_index[way];
          _t->next_index = _next[1];
-         _t->table_index = t[1] ? t[1] - tables : ~0;
+         _t->table_index = table_index[1];
          _t->offset = (e[1]
                        && t[1]) ? vnet_classify_get_offset (t[1], e[1]) : ~0;
        }
@@ -694,7 +709,7 @@ ip_in_out_acl_inline_trace (
          t->sw_if_index =
            ~0 == way ? 0 : vnet_buffer (b[0])->sw_if_index[way];
          t->next_index = next0;
-         t->table_index = t0 - tables;
+         t->table_index = table_index0;
          t->offset = (e0 && t0) ? vnet_classify_get_offset (t0, e0) : ~0;
        }