Add no-append flag to vlib_frame_t

Change-Id: I01c4f5755d579282773ac227b0bc24f8ddbb2bd1
Signed-off-by: Damjan Marion <damarion@cisco.com>
diff --git a/src/vlib/main.c b/src/vlib/main.c
index eed627c..89202be 100644
--- a/src/vlib/main.c
+++ b/src/vlib/main.c
@@ -233,7 +233,7 @@
 	ASSERT (nf->frame_index != frame_index);
     }
 
-  f->frame_flags &= ~VLIB_FRAME_IS_ALLOCATED;
+  f->frame_flags &= ~(VLIB_FRAME_IS_ALLOCATED | VLIB_FRAME_NO_APPEND);
 
   vec_add1 (fs->free_frame_indices, frame_index);
   ASSERT (fs->n_alloc_frames > 0);
@@ -387,9 +387,11 @@
       f->flags = 0;
     }
 
-  /* Allocate new frame if current one is already full. */
+  /* Allocate new frame if current one is marked as no-append or
+     it is already full. */
   n_used = f->n_vectors;
-  if (n_used >= VLIB_FRAME_SIZE || (allocate_new_next_frame && n_used > 0))
+  if (n_used >= VLIB_FRAME_SIZE || (allocate_new_next_frame && n_used > 0) ||
+      (f->frame_flags & VLIB_FRAME_NO_APPEND))
     {
       /* Old frame may need to be freed after dispatch, since we'll have
          two redundant frames from node -> next node. */
@@ -1370,7 +1372,7 @@
 				   VLIB_NODE_STATE_POLLING,
 				   f, last_time_stamp);
 
-  f->frame_flags &= ~VLIB_FRAME_PENDING;
+  f->frame_flags &= ~(VLIB_FRAME_PENDING | VLIB_FRAME_NO_APPEND);
 
   /* Frame is ready to be used again, so restore it. */
   if (restore_frame_index != ~0)
diff --git a/src/vlib/node.h b/src/vlib/node.h
index e5d46d8..ec47f20 100644
--- a/src/vlib/node.h
+++ b/src/vlib/node.h
@@ -417,6 +417,9 @@
 #define VLIB_FRAME_NO_FREE_AFTER_DISPATCH \
   VLIB_NODE_FLAG_FRAME_NO_FREE_AFTER_DISPATCH
 
+  /* Don't append this frame */
+#define VLIB_FRAME_NO_APPEND (1 << 14)
+
   /* This next frame owns enqueue to node
      corresponding to node_runtime_index. */
 #define VLIB_FRAME_OWNER (1 << 15)
diff --git a/src/vlib/node_funcs.h b/src/vlib/node_funcs.h
index 777746a..bf11a0e 100644
--- a/src/vlib/node_funcs.h
+++ b/src/vlib/node_funcs.h
@@ -242,6 +242,12 @@
   return f;
 }
 
+always_inline void
+vlib_frame_no_append (vlib_frame_t * f)
+{
+  f->frame_flags |= VLIB_FRAME_NO_APPEND;
+}
+
 always_inline u32
 vlib_frame_index (vlib_main_t * vm, vlib_frame_t * f)
 {