summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2019-09-23 16:03:49 -0400
committerDave Barach <dave@barachs.net>2019-09-23 16:12:12 -0400
commit9382ad9b390e17c8bfd8229342656348d059becb (patch)
tree16cd4e20d893af54443d7085a56bd5dabc61a180 /src/vnet
parentd5ade023bdb8c2acae41e31010b17ba2070f2541 (diff)
misc: improve pcap drop trace output
Append <nodename>: <error-string> to pcap drop traces. The data displays perfectly fine in [vanilla] wireshark, and makes it 100% obvious which node dropped the packet, and why. Type: feature Ticket: VPP-1776 Signed-off-by: Dave Barach <dave@barachs.net> Change-Id: I9b964b99da4011b93723354db6ef0b128fca20cb
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/interface_output.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/vnet/interface_output.c b/src/vnet/interface_output.c
index 8eb2e67b1bd..8e257014789 100644
--- a/src/vnet/interface_output.c
+++ b/src/vnet/interface_output.c
@@ -1177,6 +1177,7 @@ pcap_drop_trace (vlib_main_t * vm,
u32 bi0;
i16 save_current_data;
u16 save_current_length;
+ vlib_error_main_t *em = &vm->error_main;
from = vlib_frame_vector_args (f);
@@ -1222,6 +1223,59 @@ pcap_drop_trace (vlib_main_t * vm,
else if (b0->current_data > 0)
vlib_buffer_advance (b0, (word) - b0->current_data);
+ {
+ vlib_buffer_t *last = b0;
+ u32 error_node_index;
+ int drop_string_len;
+ vlib_node_t *n;
+ /* Length of the error string */
+ int error_string_len =
+ clib_strnlen (em->error_strings_heap[b0->error], 128);
+
+ /* Dig up the drop node */
+ error_node_index = vm->node_main.node_by_error[b0->error];
+ n = vlib_get_node (vm, error_node_index);
+
+ /* Length of full drop string, w/ "nodename: " prepended */
+ drop_string_len = error_string_len + vec_len (n->name) + 2;
+
+ /* Find the last buffer in the chain */
+ while (last->flags & VLIB_BUFFER_NEXT_PRESENT)
+ last = vlib_get_buffer (vm, last->next_buffer);
+
+ /*
+ * Append <nodename>: <error-string> to the capture,
+ * only if we can do that without allocating a new buffer.
+ */
+ if (PREDICT_TRUE ((last->current_data + last->current_length)
+ < (VLIB_BUFFER_DEFAULT_DATA_SIZE
+ - drop_string_len)))
+ {
+ clib_memcpy_fast (last->data + last->current_data +
+ last->current_length, n->name,
+ vec_len (n->name));
+ clib_memcpy_fast (last->data + last->current_data +
+ last->current_length + vec_len (n->name),
+ ": ", 2);
+ clib_memcpy_fast (last->data + last->current_data +
+ last->current_length + vec_len (n->name) +
+ 2, em->error_strings_heap[b0->error],
+ error_string_len);
+ last->current_length += drop_string_len;
+ b0->flags &= ~(VLIB_BUFFER_TOTAL_LENGTH_VALID);
+ pcap_add_buffer (&pp->pcap_main, vm, bi0,
+ pp->max_bytes_per_pkt);
+ last->current_length -= drop_string_len;
+ b0->current_data = save_current_data;
+ b0->current_length = save_current_length;
+ continue;
+ }
+ }
+
+ /*
+ * Didn't have space in the last buffer, here's the dropped
+ * packet as-is
+ */
pcap_add_buffer (&pp->pcap_main, vm, bi0, pp->max_bytes_per_pkt);
b0->current_data = save_current_data;