session: use safe realloc for pools
[vpp.git] / src / vnet / udp / udp_input.c
index 523ab02..e701ca5 100644 (file)
@@ -26,8 +26,8 @@
 #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
 };
@@ -134,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))
@@ -163,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 *
@@ -271,10 +273,8 @@ udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
                  ASSERT (s0->session_index == uc0->c_s_index);
 
                  /*
-                  * Drop the peeker lock on pool resize and ask session
-                  * layer for a new session.
+                  * Ask session layer for a new session.
                   */
-                 session_pool_remove_peeker (s0->thread_index);
                  session_dgram_connect_notify (&uc0->connection,
                                                s0->thread_index, &s0);
                  queue_event = 0;
@@ -284,7 +284,6 @@ udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
            }
          udp_connection_enqueue (uc0, s0, &hdr0, thread_index, b[0],
                                  queue_event, &error0);
-         session_pool_remove_peeker (s0->thread_index);
        }
       else if (s0->session_state == SESSION_STATE_READY)
        {
@@ -312,7 +311,6 @@ udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
       else
        {
          error0 = UDP_ERROR_NOT_READY;
-         session_pool_remove_peeker (s0->thread_index);
        }
 
     done:
@@ -348,8 +346,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,
@@ -374,8 +372,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,