icmp: bug fix of buffer->error 45/18445/4
authorKingwel Xie <kingwel.xie@ericsson.com>
Thu, 21 Mar 2019 01:47:17 +0000 (21:47 -0400)
committerOle Trøan <otroan@employees.org>
Thu, 21 Mar 2019 11:29:24 +0000 (11:29 +0000)
Recent changes in icmp4/6 choose to free the original
buffer, and make a copy for sending icmp reply back.
However, buffer->error will be ignored when the buffer
is freed unconditionally.

A quick fix can be moving the counter increment code to icmp,
but I prefert to enqueue all buffers to 'error-drop' so that
they can be handled in a batch

rebase, using vlib_buffer_enqueue_to_single_next

Change-Id: I9f3028b55f1d5f634763e2410cd91e17f368195e
Signed-off-by: Kingwel Xie <kingwel.xie@ericsson.com>
src/vnet/ip/icmp4.c
src/vnet/ip/icmp6.c

index ce81dc0..500aa6d 100644 (file)
@@ -495,7 +495,6 @@ ip4_icmp_error (vlib_main_t * vm,
 
          org_p0 = vlib_get_buffer (vm, org_pi0);
          p0 = vlib_buffer_copy_no_chain (vm, org_p0, &pi0);
-         vlib_buffer_free_one (vm, org_pi0);
          if (!p0 || pi0 == ~0) /* Out of buffers */
            continue;
 
@@ -575,6 +574,15 @@ ip4_icmp_error (vlib_main_t * vm,
       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
     }
 
+  /*
+   * push the original buffers to error-drop, so that
+   * they can get the error counters handled, then freed
+   */
+  vlib_buffer_enqueue_to_single_next (vm, node,
+                                     vlib_frame_vector_args (frame),
+                                     IP4_ICMP_ERROR_NEXT_DROP,
+                                     frame->n_vectors);
+
   return frame->n_vectors;
 }
 
index ff83a0c..9d283ff 100644 (file)
@@ -512,7 +512,6 @@ ip6_icmp_error (vlib_main_t * vm,
 
          org_p0 = vlib_get_buffer (vm, org_pi0);
          p0 = vlib_buffer_copy_no_chain (vm, org_p0, &pi0);
-         vlib_buffer_free_one (vm, org_pi0);
          if (!p0 || pi0 == ~0) /* Out of buffers */
            continue;
 
@@ -588,6 +587,15 @@ ip6_icmp_error (vlib_main_t * vm,
       vlib_put_next_frame (vm, node, next_index, n_left_to_next);
     }
 
+  /*
+   * push the original buffers to error-drop, so that
+   * they can get the error counters handled, then freed
+   */
+  vlib_buffer_enqueue_to_single_next (vm, node,
+                                     vlib_frame_vector_args (frame),
+                                     IP6_ICMP_ERROR_NEXT_DROP,
+                                     frame->n_vectors);
+
   return frame->n_vectors;
 }