summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenoît Ganne <bganne@cisco.com>2019-09-17 17:30:35 +0200
committerDamjan Marion <dmarion@me.com>2019-09-25 22:19:59 +0000
commit2cf5b1a1ec8d959f1355974822deba35d6bfb04b (patch)
treec79371b0ebb520c322bcf1ed2bd978dec621552c
parent1b696ac9b334aa9305925e4759c6c6f6b47c3328 (diff)
interface: fix pcap drop trace in case of vlan
Type: fix Change-Id: If3c4e5c376b51a26143d8922dcacfbda534163bd Signed-off-by: Benoît Ganne <bganne@cisco.com> (cherry picked from commit 4e323cbdbd57fcd77db68e295f639288441ef3e3)
-rw-r--r--src/vnet/interface_output.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 250d0dbe251..5d3d53e5ad8 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -1207,8 +1207,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);