Minor tweaks 97/16197/1
authorDave Barach <dave@barachs.net>
Mon, 26 Nov 2018 23:34:33 +0000 (18:34 -0500)
committerDave Barach <dave@barachs.net>
Mon, 26 Nov 2018 23:36:14 +0000 (18:36 -0500)
Significant refit coming soon.

Signed-off-by: Dave Barach <dave@barachs.net>
Change-Id: If7d196e84354c5088706e2ac81e2add42597a550

extras/wireshark/packet-vpp.c
src/vnet/tcp/tcp_output.c

index 9584e70..fc568da 100644 (file)
@@ -95,7 +95,7 @@ static dissector_table_t vpp_subdissector_table;
 _(eth_maybefcs)                                 \
 _(ip)                                           \
 _(ipv6)                                         \
-_(udp)
+_(tcp)
 
 #define _(a) static dissector_handle_t a##_dissector_handle;
 foreach_next_dissector;
@@ -110,17 +110,28 @@ foreach_next_dissector;
  * arg is [only] used as a string (#xxx). 
  */
 
+/* 
+ * Note: in addition to these direct mappings, we 
+ * send traces w/ b->data[b->current_data] = 0x45 to
+ * the ip dissector, and 0x60 to the ipv6 dissector.
+ *
+ * It pays to add direct mappings for common places which
+ * may receive broken packets during development. ip4-lookup and
+ * ip6-lookup are obvious places where people send
+ * hand-crafted packets which may turn out to be broken.
+ */
 #define foreach_node_to_dissector_pair          \
-_("ip6-lookup", ipv6)                           \
+_("ethernet-input", eth_maybefcs)               \
+_("ip4-glean", ip)                              \
+_("ip4-icmp-error", ip)                         \
 _("ip4-input", ip)                              \
-_("ip4-not-enabled", ip)                        \
 _("ip4-input-no-checksum", ip)                  \
-_("ip4-lookup", ip)                             \
 _("ip4-local", ip)                              \
-_("ip4-udp-lookup", udp)                        \
-_("ip4-icmp-error", ip)                         \
-_("ip4-glean", ip)                              \
-_("ethernet-input", eth_maybefcs)
+_("ip4-lookup", ip)                             \
+_("ip4-udp-lookup", ip)                         \
+_("ip6-lookup", ipv6)                           \
+_("tcp4-output", tcp)                           \
+_("tcp6-output", tcp)
 
 static void
 add_multi_line_string_to_tree(proto_tree *tree, tvbuff_t *tvb, gint start,
@@ -756,8 +767,25 @@ dissect_vpp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
      * Failing that, pretend its an ethernet packet
      */ 
     if (!dissector_try_string (vpp_subdissector_table, name, eth_tvb,
-                               pinfo, tree, NULL))
-        call_dissector (eth_maybefcs_dissector_handle, eth_tvb, pinfo, tree);
+                               pinfo, tree, NULL)) {
+        guint8 maybe_protocol_id; 
+        dissector_handle_t best_guess_dissector_handle
+            = eth_maybefcs_dissector_handle;
+
+        maybe_protocol_id = tvb_get_guint8 (tvb, offset);
+
+        switch (maybe_protocol_id) {
+        case 0x45:
+            best_guess_dissector_handle = ip_dissector_handle;
+            break;
+        case 0x60:
+            best_guess_dissector_handle = ipv6_dissector_handle;
+            break;
+        default:
+            break;
+        }
+        call_dissector (best_guess_dissector_handle, eth_tvb, pinfo, tree);
+    }
 
     g_free (name);
     return tvb_captured_length(tvb);
index 2068e43..619dce1 100644 (file)
@@ -2209,19 +2209,20 @@ tcp6_output (vlib_main_t * vm, vlib_node_runtime_t * node,
 /* *INDENT-OFF* */
 VLIB_REGISTER_NODE (tcp4_output_node) =
 {
-  .function = tcp4_output,.name = "tcp4-output",
-    /* Takes a vector of packets. */
-    .vector_size = sizeof (u32),
-    .n_errors = TCP_N_ERROR,
-    .error_strings = tcp_error_strings,
-    .n_next_nodes = TCP_OUTPUT_N_NEXT,
-    .next_nodes = {
+  .function = tcp4_output,
+  .name = "tcp4-output",
+  /* Takes a vector of packets. */
+  .vector_size = sizeof (u32),
+  .n_errors = TCP_N_ERROR,
+  .error_strings = tcp_error_strings,
+  .n_next_nodes = TCP_OUTPUT_N_NEXT,
+  .next_nodes = {
 #define _(s,n) [TCP_OUTPUT_NEXT_##s] = n,
     foreach_tcp4_output_next
 #undef _
-    },
-    .format_buffer = format_tcp_header,
-    .format_trace = format_tcp_tx_trace,
+  },
+  .format_buffer = format_tcp_header,
+  .format_trace = format_tcp_tx_trace,
 };
 /* *INDENT-ON* */