summaryrefslogtreecommitdiffstats
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
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
-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;
color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
.. _containerSetup:

.. toctree::

Container packages
__________________

Now we can go into container *cone* and install prerequisites such as VPP, and perform some additional commands:

To enter our container via the shell, type:

.. code-block:: console
    
    # lxc-attach -n cone
    root@cone:/#

Run the linux DHCP setup and install VPP: 

.. code-block:: console
    
    root@cone:/# resolvconf -d eth0
    root@cone:/# dhclient
    root@cone:/# apt-get install -y wget
    root@cone:/# echo "deb [trusted=yes] https://nexus.fd.io/content/repositories/fd.io.ubuntu.xenial.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list
    root@cone:/# apt-get update
    root@cone:/# apt-get install -y --force-yes vpp
    root@cone:/# sh -c 'echo  \"\\ndpdk {\\n   no-pci\\n}\" >> /etc/vpp/startup.conf'

After this is done, start VPP in this container:

.. code-block:: console
    
    root@cone:/# service vpp start

Exit this container with the **exit** command (you *may* need to run **exit** twice):

.. code-block:: console

    root@cone:/# exit
    exit
    root@cone:/# exit
    exit
    root@localhost:~#

Repeat the container setup on this page for the second container **ctwo**. Go to the end of the previous page if you forgot how to start a container.