misc: fix error handling in punt_replicate 33/26433/2
authorDave Barach <dave@barachs.net>
Wed, 8 Apr 2020 18:31:45 +0000 (14:31 -0400)
committerNeale Ranns <nranns@cisco.com>
Thu, 9 Apr 2020 06:50:11 +0000 (06:50 +0000)
If vlib_buffer_clone (...) fails due to a buffer allocation error, update
*n_dispatched with the actual number of clones, not the requested
number of clones.

Punt_replicate(...) should not set *to_next[0] = bi0. The original
buffer is enqueued separately in punt_dispatch_node(...)

Type: fix

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: I774ad8f8c1a0633de4cf8ae5530629201c229347

src/vlib/punt_node.c
src/vnet/ip/punt_node.c

index e341e40..de72104 100644 (file)
@@ -120,11 +120,16 @@ punt_replicate (vlib_main_t * vm,
        * so there's no need to check if the to_next frame
        * is full */
     }
-  *n_dispatched = *n_dispatched + n_clones0;
+  *n_dispatched = *n_dispatched + n_cloned0;
 
   /* The original buffer is the first clone */
   next0 = punt_dp_db[pr0][0];
-  *to_next[0] = bi0;
+  /*
+   * Note: the original buffer is enqueued in punt_dispatch_node.
+   * Don't do it here.
+   *
+   * *to_next[0] = bi0;
+   */
   return next0;
 }
 
index b48af84..0306d59 100644 (file)
@@ -596,6 +596,7 @@ punt_socket_rx_fd (vlib_main_t * vm, vlib_node_runtime_t * node, u32 fd)
   return 1;
 
 error:
+  vlib_put_next_frame (vm, node, next, n_left_to_next);
   vlib_node_increment_counter (vm, punt_socket_rx_node.index, error, 1);
   return 0;
 }