Fix - sh ip fib mtrie sum
[vpp.git] / src / vnet / ip / ip4_mtrie.c
index adc9512..f114da0 100644 (file)
@@ -271,7 +271,7 @@ set_leaf (ip4_fib_mtrie_t * m,
 
   old_ply = pool_elt_at_index (ip4_ply_pool, old_ply_index);
 
-  ASSERT (a->dst_address_length >= 0 && a->dst_address_length <= 32);
+  ASSERT (a->dst_address_length <= 32);
   ASSERT (dst_address_byte_index < ARRAY_LEN (a->dst_address.as_u8));
 
   /* how many bits of the destination address are in the next PLY */
@@ -284,7 +284,8 @@ set_leaf (ip4_fib_mtrie_t * m,
   if (n_dst_bits_next_plies <= 0)
     {
       /* The mask length of the address to insert maps to this ply */
-      uword i, n_dst_bits_this_ply, old_leaf_is_terminal;
+      uword old_leaf_is_terminal;
+      u32 i, n_dst_bits_this_ply;
 
       /* The number of bits, and hence slots/buckets, we will fill */
       n_dst_bits_this_ply = clib_min (8, -n_dst_bits_next_plies);
@@ -401,7 +402,7 @@ set_root_leaf (ip4_fib_mtrie_t * m,
 
   old_ply = &m->root_ply;
 
-  ASSERT (a->dst_address_length >= 0 && a->dst_address_length <= 32);
+  ASSERT (a->dst_address_length <= 32);
 
   /* how many bits of the destination address are in the next PLY */
   n_dst_bits_next_plies = a->dst_address_length - BITS (u16);
@@ -412,7 +413,8 @@ set_root_leaf (ip4_fib_mtrie_t * m,
   if (n_dst_bits_next_plies <= 0)
     {
       /* The mask length of the address to insert maps to this ply */
-      uword i, n_dst_bits_this_ply, old_leaf_is_terminal;
+      uword old_leaf_is_terminal;
+      u32 i, n_dst_bits_this_ply;
 
       /* The number of bits, and hence slots/buckets, we will fill */
       n_dst_bits_this_ply = 16 - a->dst_address_length;
@@ -515,7 +517,7 @@ unset_leaf (ip4_fib_mtrie_t * m,
   i32 i, n_dst_bits_this_ply, old_leaf_is_terminal;
   u8 dst_byte;
 
-  ASSERT (a->dst_address_length >= 0 && a->dst_address_length <= 32);
+  ASSERT (a->dst_address_length <= 32);
   ASSERT (dst_address_byte_index < ARRAY_LEN (a->dst_address.as_u8));
 
   n_dst_bits_next_plies =
@@ -588,7 +590,7 @@ unset_root_leaf (ip4_fib_mtrie_t * m,
   u16 dst_byte;
   ip4_fib_mtrie_16_ply_t *old_ply;
 
-  ASSERT (a->dst_address_length >= 0 && a->dst_address_length <= 32);
+  ASSERT (a->dst_address_length <= 32);
 
   old_ply = &m->root_ply;
   n_dst_bits_next_plies = a->dst_address_length - BITS (u16);
@@ -738,7 +740,7 @@ format_ip4_fib_mtrie_ply (u8 * s, va_list * va)
   u32 base_address = va_arg (*va, u32);
   u32 ply_index = va_arg (*va, u32);
   ip4_fib_mtrie_8_ply_t *p;
-  uword indent;
+  u32 indent;
   int i;
 
   p = pool_elt_at_index (ip4_ply_pool, ply_index);
@@ -762,6 +764,7 @@ u8 *
 format_ip4_fib_mtrie (u8 * s, va_list * va)
 {
   ip4_fib_mtrie_t *m = va_arg (*va, ip4_fib_mtrie_t *);
+  int verbose = va_arg (*va, int);
   ip4_fib_mtrie_16_ply_t *p;
   u32 base_address = 0;
   int i;
@@ -769,18 +772,22 @@ format_ip4_fib_mtrie (u8 * s, va_list * va)
   s = format (s, "%d plies, memory usage %U\n",
              pool_elts (ip4_ply_pool),
              format_memory_size, mtrie_memory_usage (m));
-  s = format (s, "root-ply");
-  p = &m->root_ply;
 
-  for (i = 0; i < ARRAY_LEN (p->leaves); i++)
+  if (verbose)
     {
-      u16 slot;
+      s = format (s, "root-ply");
+      p = &m->root_ply;
 
-      slot = clib_host_to_net_u16 (i);
-
-      if (p->dst_address_bits_of_leaves[slot] > 0)
+      for (i = 0; i < ARRAY_LEN (p->leaves); i++)
        {
-         FORMAT_PLY (s, p, slot, base_address, 16, 2);
+         u16 slot;
+
+         slot = clib_host_to_net_u16 (i);
+
+         if (p->dst_address_bits_of_leaves[slot] > 0)
+           {
+             FORMAT_PLY (s, p, slot, base_address, 16, 2);
+           }
        }
     }