l2-flood: fix restore vnet buffer's flags in the replication routine 06/9406/2
authorSteve Shin <jonshin@cisco.com>
Mon, 13 Nov 2017 23:46:35 +0000 (15:46 -0800)
committerJohn Lo <loj@cisco.com>
Tue, 14 Nov 2017 03:08:50 +0000 (03:08 +0000)
When BUM packets are flooded in the l2 domain, some data should be
kept and restored for recycling in the replication routine.
If l2 bridge domain has multiple interfaces mixed with normal and
vlan tagged, the vlan tag value of the vnet buffer can be changed
while flooding the replicated packets. The change is made to store
and restore the original vlan tag in the replication logic.

Change-Id: I399cf54cd2e74cb44a2be42241bdc4fba85032c5
Signed-off-by: Steve Shin <jonshin@cisco.com>
src/vnet/replication.c
src/vnet/replication.h

index 0fdca0b..5a8a0fe 100644 (file)
@@ -45,6 +45,7 @@ replication_prep (vlib_main_t * vm,
   /* Save state from vlib buffer */
   ctx->saved_free_list_index = vlib_buffer_get_free_list_index (b0);
   ctx->current_data = b0->current_data;
+  ctx->flags = b0->flags & VNET_BUFFER_FLAGS_VLAN_BITS;
 
   /* Set up vlib buffer hooks */
   b0->recycle_count = ctx_id;
@@ -104,6 +105,10 @@ replication_recycle (vlib_main_t * vm, vlib_buffer_t * b0, u32 is_last)
   clib_memcpy (vnet_buffer (b0), ctx->vnet_buffer,
               sizeof (vnet_buffer_opaque_t));
 
+  /* Restore the vlan flags */
+  b0->flags &= ~VNET_BUFFER_FLAGS_VLAN_BITS;
+  b0->flags |= ctx->flags;
+
   /* Restore the packet start (current_data) and length */
   vlib_buffer_advance (b0, ctx->current_data - b0->current_data);
 
index 42ec69a..531a61c 100644 (file)
@@ -43,12 +43,13 @@ typedef struct
 
   /* data saved from the original packet and restored for each replica */
   u64 l2_header[3];            /*  24B (must be at least 22B for l2 packets) */
+  u32 flags;                   /* vnet buffer flags */
   u16 ip_tos;                  /* v4 and v6 */
   u16 ip4_checksum;            /* needed for v4 only */
 
   /* data saved from the vlib buffer header and restored for each replica */
   i16 current_data;            /* offset of first byte of packet in packet data */
-  u8 pad[6];                   /* to 64B */
+  u8 pad[2];                   /* to 64B */
   u8 l2_packet;                        /* flag for l2 vs l3 packet data */
 
 } replication_context_t;       /* 128B */