udp: avoid locking connected udp sessions on rx
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I52aa2322980b51cfc0b282fb37d7f63d30777dee
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index 1d05e02..00d9ec1 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -124,6 +124,7 @@
udp_connection_free (udp_connection_t * uc)
{
u32 thread_index = uc->c_thread_index;
+ clib_spinlock_free (&uc->rx_lock);
if (CLIB_DEBUG)
clib_memset (uc, 0xFA, sizeof (*uc));
pool_put (udp_main.connections[thread_index], uc);
@@ -222,6 +223,7 @@
listener = udp_listener_get (listener_index);
udp_connection_unregister_port (clib_net_to_host_u16 (listener->c_lcl_port),
listener->c_is_ip4);
+ clib_spinlock_free (&listener->rx_lock);
pool_put (um->listener_pool, listener);
return 0;
}
diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h
index 1494b33..d0e3bf3 100644
--- a/src/vnet/udp/udp.h
+++ b/src/vnet/udp/udp.h
@@ -218,6 +218,8 @@
new_c->c_thread_index = current_thread_index;
new_c->c_c_index = udp_connection_index (new_c);
new_c->c_fib_index = old_c->c_fib_index;
+ /* Assume cloned sessions don't need lock */
+ new_c->rx_lock = 0;
return new_c;
}
diff --git a/src/vnet/udp/udp_input.c b/src/vnet/udp/udp_input.c
index 523ab02..c76c1b7 100644
--- a/src/vnet/udp/udp_input.c
+++ b/src/vnet/udp/udp_input.c
@@ -134,7 +134,8 @@
{
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 @@
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 *