interface: fix pcap drop trace in case of vlan
[vpp.git] / src / vnet / interface_output.c
index 92cbaac..f51e9a1 100644 (file)
@@ -506,8 +506,7 @@ vnet_interface_output_node_inline_gso (vlib_main_t * vm,
 
   si = vnet_get_sw_interface (vnm, rt->sw_if_index);
   hi = vnet_get_sup_hw_interface (vnm, rt->sw_if_index);
-  if (!(si->flags & (VNET_SW_INTERFACE_FLAG_ADMIN_UP |
-                    VNET_SW_INTERFACE_FLAG_BOND_SLAVE)) ||
+  if (!(si->flags & VNET_SW_INTERFACE_FLAG_ADMIN_UP) ||
       !(hi->flags & VNET_HW_INTERFACE_FLAG_LINK_UP))
     {
       vlib_simple_counter_main_t *cm;
@@ -1193,8 +1192,19 @@ pcap_drop_trace (vlib_main_t * vm,
 
          /*
           * Typically, we'll need to rewind the buffer
+          * if l2_hdr_offset is valid, make sure to rewind to the start of
+          * the L2 header. This may not be the buffer start in case we pop-ed
+          * vlan tags.
+          * Otherwise, rewind to buffer start and hope for the best.
           */
-         if (b0->current_data > 0)
+         if (b0->flags & VNET_BUFFER_F_L2_HDR_OFFSET_VALID)
+           {
+             if (b0->current_data > vnet_buffer (b0)->l2_hdr_offset)
+               vlib_buffer_advance (b0,
+                                    vnet_buffer (b0)->l2_hdr_offset -
+                                    b0->current_data);
+           }
+         else if (b0->current_data > 0)
            vlib_buffer_advance (b0, (word) - b0->current_data);
 
          pcap_add_buffer (&im->pcap_main, vm, bi0, 512);
@@ -1318,7 +1328,7 @@ interface_tx_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
 }
 
 /* *INDENT-OFF* */
-VLIB_REGISTER_NODE (interface_tx, static) = {
+VLIB_REGISTER_NODE (interface_tx) = {
   .function = interface_tx_node_fn,
   .name = "interface-tx",
   .vector_size = sizeof (u32),