#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
};
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 *
{
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))
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 *
goto done;
}
- /*
- * If session exists pool peeker lock is taken at this point unless
- * the session is already on the right thread or is a listener
- */
-
if (s0->session_state == SESSION_STATE_OPENED)
{
u8 queue_event = 1;
uc0 = udp_connection_from_transport (session_get_transport (s0));
+ uc0->sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
if (uc0->flags & UDP_CONN_F_CONNECTED)
{
if (s0->thread_index != thread_index)
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;
}
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)
{
goto done;
}
s0 = session_get (uc0->c_s_index, uc0->c_thread_index);
+ uc0->sw_if_index = vnet_buffer (b[0])->sw_if_index[VLIB_RX];
error0 = UDP_ERROR_ACCEPT;
}
udp_connection_enqueue (uc0, s0, &hdr0, thread_index, b[0], 1,
else
{
error0 = UDP_ERROR_NOT_READY;
- session_pool_remove_peeker (s0->thread_index);
}
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);
.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,
.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,