http hsa: use octet-stream content type for tps
[vpp.git] / src / vnet / udp / udp_input.c
index 0a4af60..d14bdb8 100644 (file)
 #include <vppinfra/elog.h>
 
 #include <vnet/vnet.h>
-#include <vnet/pg/pg.h>
 #include <vnet/ip/ip.h>
 #include <vnet/udp/udp.h>
 #include <vnet/udp/udp_packet.h>
 #include <vnet/session/session.h>
 
-static char *udp_error_strings[] = {
-#define udp_error(n,s) s,
+static vlib_error_desc_t udp_error_counters[] = {
+#define udp_error(f, n, s, d) { #n, d, VL_COUNTER_SEVERITY_##s },
 #include "udp_error.def"
 #undef udp_error
 };
@@ -98,7 +97,7 @@ udp_trace_buffer (vlib_main_t * vm, vlib_node_runtime_t * node,
   t = vlib_add_trace (vm, node, b, sizeof (*t));
   t->connection = s ? s->connection_index : ~0;
   t->disposition = error0;
-  t->thread_index = s->thread_index;
+  t->thread_index = s ? s->thread_index : vm->thread_index;
 }
 
 static udp_connection_t *
@@ -135,7 +134,8 @@ udp_connection_enqueue (udp_connection_t * uc0, session_t * s0,
 {
   int wrote0;
 
-  clib_spinlock_lock (&uc0->rx_lock);
+  if (!(uc0->flags & UDP_CONN_F_CONNECTED))
+    clib_spinlock_lock (&uc0->rx_lock);
 
   if (svm_fifo_max_enqueue_prod (s0->rx_fifo)
       < hdr0->data_length + sizeof (session_dgram_hdr_t))
@@ -164,7 +164,8 @@ udp_connection_enqueue (udp_connection_t * uc0, session_t * s0,
 
 unlock_rx_lock:
 
-  clib_spinlock_unlock (&uc0->rx_lock);
+  if (!(uc0->flags & UDP_CONN_F_CONNECTED))
+    clib_spinlock_unlock (&uc0->rx_lock);
 }
 
 always_inline session_t *
@@ -317,14 +318,13 @@ udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
        }
 
     done:
+      if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
+       udp_trace_buffer (vm, node, b[0], s0, error0);
 
       b += 1;
       n_left_from -= 1;
 
       udp_inc_err_counter (err_counters, error0, 1);
-
-      if (PREDICT_FALSE (node->flags & VLIB_NODE_FLAG_TRACE))
-       udp_trace_buffer (vm, node, b[0], s0, error0);
     }
 
   vlib_buffer_free (vm, first_buffer, frame->n_vectors);
@@ -350,8 +350,8 @@ VLIB_REGISTER_NODE (udp4_input_node) =
   .vector_size = sizeof (u32),
   .format_trace = format_udp_input_trace,
   .type = VLIB_NODE_TYPE_INTERNAL,
-  .n_errors = ARRAY_LEN (udp_error_strings),
-  .error_strings = udp_error_strings,
+  .n_errors = UDP_N_ERROR,
+  .error_counters = udp_error_counters,
   .n_next_nodes = UDP_INPUT_N_NEXT,
   .next_nodes = {
 #define _(s, n) [UDP_INPUT_NEXT_##s] = n,
@@ -376,8 +376,8 @@ VLIB_REGISTER_NODE (udp6_input_node) =
   .vector_size = sizeof (u32),
   .format_trace = format_udp_input_trace,
   .type = VLIB_NODE_TYPE_INTERNAL,
-  .n_errors = ARRAY_LEN (udp_error_strings),
-  .error_strings = udp_error_strings,
+  .n_errors = UDP_N_ERROR,
+  .error_counters = udp_error_counters,
   .n_next_nodes = UDP_INPUT_N_NEXT,
   .next_nodes = {
 #define _(s, n) [UDP_INPUT_NEXT_##s] = n,