l2: handle complete clone fail in l2_flood
[vpp.git] / src / vnet / l2 / l2_flood.c
index 8d34233..b5eb5fe 100644 (file)
@@ -213,7 +213,6 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm,
          else if (n_clones > 1)
            {
              vec_validate (msm->clones[thread_index], n_clones);
-             vec_reset_length (msm->clones[thread_index]);
 
              /*
               * the header offset needs to be large enough to incorporate
@@ -226,9 +225,18 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm,
                                            n_clones,
                                            VLIB_BUFFER_CLONE_HEAD_SIZE);
 
+             vec_set_len (msm->clones[thread_index], n_cloned);
+
              if (PREDICT_FALSE (n_cloned != n_clones))
                {
                  b0->error = node->errors[L2FLOOD_ERROR_REPL_FAIL];
+                 /* Worst-case, no clones, consume the original buf */
+                 if (n_cloned == 0)
+                   {
+                     ci0 = bi0;
+                     member = msm->members[thread_index][0];
+                     goto use_original_buffer;
+                   }
                }
 
              /*
@@ -283,6 +291,7 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm,
              member = msm->members[thread_index][0];
            }
 
+       use_original_buffer:
          /*
           * the last clone that might go to a BVI
           */
@@ -305,8 +314,6 @@ VLIB_NODE_FN (l2flood_node) (vlib_main_t * vm,
              clib_memcpy_fast (t->src, h0->src_address, 6);
              clib_memcpy_fast (t->dst, h0->dst_address, 6);
            }
-
-
          /* Forward packet to the current member */
          if (PREDICT_FALSE (member->flags & L2_FLOOD_MEMBER_BVI))
            {