ip: reassembly - return correct value
[vpp.git] / src / vnet / ip / reass / ip6_full_reass.c
index 7419334..2764798 100644 (file)
@@ -705,8 +705,6 @@ ip6_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
   vlib_buffer_t *last_b = NULL;
   u32 sub_chain_bi = reass->first_bi;
   u32 total_length = 0;
-  u32 buf_cnt = 0;
-  u32 dropped_cnt = 0;
   u32 *vec_drop_compress = NULL;
   ip6_full_reass_rc_t rv = IP6_FULL_REASS_RC_OK;
   do
@@ -748,7 +746,6 @@ ip6_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
        vlib_buffer_length_in_chain (vm, tmp) - trim_front - trim_end;
       while (1)
        {
-         ++buf_cnt;
          if (trim_front)
            {
              if (trim_front > tmp->current_length)
@@ -804,7 +801,6 @@ ip6_full_reass_finalize (vlib_main_t * vm, vlib_node_runtime_t * node,
                  goto free_buffers_and_return;
                }
              vec_add1 (vec_drop_compress, tmp_bi);
-             ++dropped_cnt;
            }
          if (tmp->flags & VLIB_BUFFER_NEXT_PRESENT)
            {
@@ -1283,15 +1279,17 @@ ip6_full_reassembly_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
            }
          else
            {
+             u32 fib_index =
+               (vnet_buffer (b0)->sw_if_index[VLIB_TX] == (u32) ~0) ?
+                       vec_elt (ip6_main.fib_index_by_sw_if_index,
+                          vnet_buffer (b0)->sw_if_index[VLIB_RX]) :
+                       vnet_buffer (b0)->sw_if_index[VLIB_TX];
              kv.k.as_u64[0] = ip0->src_address.as_u64[0];
              kv.k.as_u64[1] = ip0->src_address.as_u64[1];
              kv.k.as_u64[2] = ip0->dst_address.as_u64[0];
              kv.k.as_u64[3] = ip0->dst_address.as_u64[1];
              kv.k.as_u64[4] =
-               ((u64) vec_elt (ip6_main.fib_index_by_sw_if_index,
-                               vnet_buffer (b0)->sw_if_index[VLIB_RX]))
-                 << 32 |
-               (u64) frag_hdr->identification;
+               ((u64) fib_index) << 32 | (u64) frag_hdr->identification;
              /* RFC 8200: The Next Header values in the Fragment headers of
               * different fragments of the same original packet may differ.
               * Only the value from the Offset zero fragment packet is used
@@ -1448,12 +1446,6 @@ ip6_full_reassembly_inline (vlib_main_t *vm, vlib_node_runtime_t *node,
   return frame->n_vectors;
 }
 
-static char *ip6_full_reassembly_error_strings[] = {
-#define _(sym, string) string,
-  foreach_ip6_error
-#undef _
-};
-
 VLIB_NODE_FN (ip6_full_reass_node) (vlib_main_t * vm,
                                    vlib_node_runtime_t * node,
                                    vlib_frame_t * frame)
@@ -1467,8 +1459,8 @@ VLIB_REGISTER_NODE (ip6_full_reass_node) = {
     .name = "ip6-full-reassembly",
     .vector_size = sizeof (u32),
     .format_trace = format_ip6_full_reass_trace,
-    .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
-    .error_strings = ip6_full_reassembly_error_strings,
+    .n_errors = IP6_N_ERROR,
+    .error_counters = ip6_error_counters,
     .n_next_nodes = IP6_FULL_REASSEMBLY_N_NEXT,
     .next_nodes =
         {
@@ -1491,8 +1483,8 @@ VLIB_REGISTER_NODE (ip6_local_full_reass_node) = {
     .name = "ip6-local-full-reassembly",
     .vector_size = sizeof (u32),
     .format_trace = format_ip6_full_reass_trace,
-    .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
-    .error_strings = ip6_full_reassembly_error_strings,
+    .n_errors = IP6_N_ERROR,
+    .error_counters = ip6_error_counters,
     .n_next_nodes = IP6_FULL_REASSEMBLY_N_NEXT,
     .next_nodes =
         {
@@ -1516,8 +1508,8 @@ VLIB_REGISTER_NODE (ip6_full_reass_node_feature) = {
     .name = "ip6-full-reassembly-feature",
     .vector_size = sizeof (u32),
     .format_trace = format_ip6_full_reass_trace,
-    .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
-    .error_strings = ip6_full_reassembly_error_strings,
+    .n_errors = IP6_N_ERROR,
+    .error_counters = ip6_error_counters,
     .n_next_nodes = IP6_FULL_REASSEMBLY_N_NEXT,
     .next_nodes =
         {
@@ -1548,8 +1540,8 @@ VLIB_REGISTER_NODE (ip6_full_reass_node_custom) = {
     .name = "ip6-full-reassembly-custom",
     .vector_size = sizeof (u32),
     .format_trace = format_ip6_full_reass_trace,
-    .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
-    .error_strings = ip6_full_reassembly_error_strings,
+    .n_errors = IP6_N_ERROR,
+    .error_counters = ip6_error_counters,
     .n_next_nodes = IP6_FULL_REASSEMBLY_N_NEXT,
     .next_nodes =
         {
@@ -1851,14 +1843,13 @@ ip6_full_reass_walk_expired (vlib_main_t *vm, vlib_node_runtime_t *node,
 }
 
 VLIB_REGISTER_NODE (ip6_full_reass_expire_node) = {
-    .function = ip6_full_reass_walk_expired,
-    .format_trace = format_ip6_full_reass_trace,
-    .type = VLIB_NODE_TYPE_PROCESS,
-    .name = "ip6-full-reassembly-expire-walk",
-
-    .n_errors = ARRAY_LEN (ip6_full_reassembly_error_strings),
-    .error_strings = ip6_full_reassembly_error_strings,
+  .function = ip6_full_reass_walk_expired,
+  .format_trace = format_ip6_full_reass_trace,
+  .type = VLIB_NODE_TYPE_PROCESS,
+  .name = "ip6-full-reassembly-expire-walk",
 
+  .n_errors = IP6_N_ERROR,
+  .error_counters = ip6_error_counters,
 };
 
 static u8 *
@@ -2194,7 +2185,7 @@ ip6_full_reass_enable_disable_with_refcnt (u32 sw_if_index, int is_enable)
                                            "ip6-full-reassembly-feature",
                                            sw_if_index, 0, 0, 0);
     }
-  return -1;
+  return 0;
 }
 
 void