vlib: fix vlib_buffer_copy to preserve buffer flags bit

Make vlib_buffer_copy() preserve buffer flags bit the same way as
that of vlib_buffer_clone() so both are consistent.

Type: fix

Signed-off-by: John Lo <loj@cisco.com>
Change-Id: I6c32aa1e88724b482ce2439d82019e690311b664
diff --git a/src/vlib/buffer_funcs.h b/src/vlib/buffer_funcs.h
index 8091d83..bb090f2 100644
--- a/src/vlib/buffer_funcs.h
+++ b/src/vlib/buffer_funcs.h
@@ -954,13 +954,18 @@
 int vlib_buffer_add_data (vlib_main_t * vm, u32 * buffer_index, void *data,
 			  u32 n_data_bytes);
 
+/* Define vlib_buffer and vnet_buffer flags bits preserved for copy/clone */
+#define VLIB_BUFFER_COPY_CLONE_FLAGS_MASK                     	\
+  (VLIB_BUFFER_NEXT_PRESENT | VLIB_BUFFER_TOTAL_LENGTH_VALID |	\
+   VLIB_BUFFER_IS_TRACED | ~VLIB_BUFFER_FLAGS_ALL)
+
 /* duplicate all buffers in chain */
 always_inline vlib_buffer_t *
 vlib_buffer_copy (vlib_main_t * vm, vlib_buffer_t * b)
 {
   vlib_buffer_t *s, *d, *fd;
   uword n_alloc, n_buffers = 1;
-  u32 flag_mask = VLIB_BUFFER_NEXT_PRESENT | VLIB_BUFFER_TOTAL_LENGTH_VALID;
+  u32 flag_mask = VLIB_BUFFER_COPY_CLONE_FLAGS_MASK;
   int i;
 
   s = b;
@@ -1131,8 +1136,8 @@
 	  d->total_length_not_including_first_buffer +=
 	    s->total_length_not_including_first_buffer;
 	}
-      d->flags = s->flags | VLIB_BUFFER_NEXT_PRESENT;
-      d->flags &= ~VLIB_BUFFER_EXT_HDR_VALID;
+      d->flags = (s->flags & VLIB_BUFFER_COPY_CLONE_FLAGS_MASK) |
+	VLIB_BUFFER_NEXT_PRESENT;
       clib_memcpy_fast (d->opaque, s->opaque, sizeof (s->opaque));
       clib_memcpy_fast (d->opaque2, s->opaque2, sizeof (s->opaque2));
       clib_memcpy_fast (vlib_buffer_get_current (d),