ip: extend show cmd of ip reassembly configuration
[vpp.git] / src / vnet / ip / reass / ip6_full_reass.c
index 7f56d2c..8403bc5 100644 (file)
@@ -319,6 +319,13 @@ ip6_full_reass_add_trace (vlib_main_t * vm, vlib_node_runtime_t * node,
   vlib_buffer_t *b = vlib_get_buffer (vm, bi);
   vnet_buffer_opaque_t *vnb = vnet_buffer (b);
   bool is_after_handoff = false;
+  if (pool_is_free_index
+      (vm->trace_main.trace_buffer_pool, vlib_buffer_get_trace_index (b)))
+    {
+      // this buffer's trace is gone
+      b->flags &= ~VLIB_BUFFER_IS_TRACED;
+      return;
+    }
   if (vlib_buffer_get_trace_thread (b) != vm->thread_index)
     {
       is_after_handoff = true;
@@ -506,19 +513,19 @@ again:
   reass = NULL;
   now = vlib_time_now (vm);
 
-  if (!clib_bihash_search_48_8
-      (&rm->hash, (clib_bihash_kv_48_8_t *) kv, (clib_bihash_kv_48_8_t *) kv))
+  if (!clib_bihash_search_48_8 (&rm->hash, &kv->kv, &kv->kv))
     {
-      reass =
-       pool_elt_at_index (rm->per_thread_data
-                          [kv->v.memory_owner_thread_index].pool,
-                          kv->v.reass_index);
       if (vm->thread_index != kv->v.memory_owner_thread_index)
        {
          *do_handoff = 1;
-         return reass;
+         return NULL;
        }
 
+      reass =
+       pool_elt_at_index (rm->per_thread_data
+                          [kv->v.memory_owner_thread_index].pool,
+                          kv->v.reass_index);
+
       if (now > reass->last_heard + rm->timeout)
        {
          ip6_full_reass_on_timeout (vm, node, rm, reass, icmp_bi);
@@ -552,18 +559,17 @@ again:
       ++rt->reass_n;
     }
 
-  reass->key.as_u64[0] = ((clib_bihash_kv_48_8_t *) kv)->key[0];
-  reass->key.as_u64[1] = ((clib_bihash_kv_48_8_t *) kv)->key[1];
-  reass->key.as_u64[2] = ((clib_bihash_kv_48_8_t *) kv)->key[2];
-  reass->key.as_u64[3] = ((clib_bihash_kv_48_8_t *) kv)->key[3];
-  reass->key.as_u64[4] = ((clib_bihash_kv_48_8_t *) kv)->key[4];
-  reass->key.as_u64[5] = ((clib_bihash_kv_48_8_t *) kv)->key[5];
+  reass->key.as_u64[0] = kv->kv.key[0];
+  reass->key.as_u64[1] = kv->kv.key[1];
+  reass->key.as_u64[2] = kv->kv.key[2];
+  reass->key.as_u64[3] = kv->kv.key[3];
+  reass->key.as_u64[4] = kv->kv.key[4];
+  reass->key.as_u64[5] = kv->kv.key[5];
   kv->v.reass_index = (reass - rt->pool);
   kv->v.memory_owner_thread_index = vm->thread_index;
   reass->last_heard = now;
 
-  int rv =
-    clib_bihash_add_del_48_8 (&rm->hash, (clib_bihash_kv_48_8_t *) kv, 2);
+  int rv = clib_bihash_add_del_48_8 (&rm->hash, &kv->kv, 2);
   if (rv)
     {
       ip6_full_reass_free (rm, rt, reass);
@@ -1208,7 +1214,10 @@ ip6_full_reassembly_inline (vlib_main_t * vm,
 
              /* bi0 might have been updated by reass_finalize, reload */
              b0 = vlib_get_buffer (vm, bi0);
-             b0->error = node->errors[error0];
+             if (IP6_ERROR_NONE != error0)
+               {
+                 b0->error = node->errors[error0];
+               }
 
              if (next0 == IP6_FULL_REASSEMBLY_NEXT_HANDOFF)
                {
@@ -1349,7 +1358,7 @@ typedef struct
   clib_bihash_48_8_t *new_hash;
 } ip6_rehash_cb_ctx;
 
-static void
+static int
 ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
 {
   ip6_rehash_cb_ctx *ctx = _ctx;
@@ -1357,6 +1366,7 @@ ip6_rehash_cb (clib_bihash_kv_48_8_t * kv, void *_ctx)
     {
       ctx->failure = 1;
     }
+  return (BIHASH_WALK_CONTINUE);
 }
 
 static void
@@ -1517,13 +1527,13 @@ ip6_full_reass_walk_expired (vlib_main_t * vm,
 
          vec_reset_length (pool_indexes_to_free);
           /* *INDENT-OFF* */
-          pool_foreach_index (index, rt->pool, ({
+          pool_foreach_index (index, rt->pool)  {
                                 reass = pool_elt_at_index (rt->pool, index);
                                 if (now > reass->last_heard + rm->timeout)
                                   {
                                     vec_add1 (pool_indexes_to_free, index);
                                   }
-                              }));
+                              }
           /* *INDENT-ON* */
          int *i;
           /* *INDENT-OFF* */
@@ -1662,9 +1672,9 @@ show_ip6_full_reass (vlib_main_t * vm, unformat_input_t * input,
       if (details)
        {
           /* *INDENT-OFF* */
-          pool_foreach (reass, rt->pool, {
+          pool_foreach (reass, rt->pool) {
             vlib_cli_output (vm, "%U", format_ip6_full_reass, vm, reass);
-          });
+          }
           /* *INDENT-ON* */
        }
       sum_reass_n += rt->reass_n;
@@ -1673,8 +1683,19 @@ show_ip6_full_reass (vlib_main_t * vm, unformat_input_t * input,
   vlib_cli_output (vm, "---------------------");
   vlib_cli_output (vm, "Current IP6 reassemblies count: %lu\n",
                   (long unsigned) sum_reass_n);
-  vlib_cli_output (vm, "Maximum configured concurrent IP6 reassemblies per "
-                  "worker-thread: %lu\n", (long unsigned) rm->max_reass_n);
+  vlib_cli_output (vm,
+                  "Maximum configured concurrent full IP6 reassemblies per worker-thread: %lu\n",
+                  (long unsigned) rm->max_reass_n);
+  vlib_cli_output (vm,
+                  "Maximum configured amount of fragments "
+                  "per full IP6 reassembly: %lu\n",
+                  (long unsigned) rm->max_reass_len);
+  vlib_cli_output (vm,
+                  "Maximum configured full IP6 reassembly timeout: %lums\n",
+                  (long unsigned) rm->timeout_ms);
+  vlib_cli_output (vm,
+                  "Maximum configured full IP6 reassembly expire walk interval: %lums\n",
+                  (long unsigned) rm->expire_walk_interval_ms);
   vlib_cli_output (vm, "Buffers in use: %lu\n",
                   (long unsigned) sum_buffers_n);
   return 0;