diff options
author | Florin Coras <fcoras@cisco.com> | 2020-12-02 21:14:56 -0800 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2021-02-26 21:58:12 +0000 |
commit | 30fdf39628c095ed4a5d607079c1b18294050c56 (patch) | |
tree | 36f2c9a87fe9565f974437339e6a85c18cefd598 /src | |
parent | 4f0ac7e833fffe8fec659037efe0928d1bba0677 (diff) |
udp: avoid locking connected udp sessions on rx
Type: improvement
Signed-off-by: Florin Coras <fcoras@cisco.com>
Change-Id: I52aa2322980b51cfc0b282fb37d7f63d30777dee
Diffstat (limited to 'src')
-rw-r--r-- | src/vnet/udp/udp.c | 2 | ||||
-rw-r--r-- | src/vnet/udp/udp.h | 2 | ||||
-rw-r--r-- | src/vnet/udp/udp_input.c | 6 |
3 files changed, 8 insertions, 2 deletions
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c index 1d05e02b2ab..00d9ec104dd 100644 --- a/src/vnet/udp/udp.c +++ b/src/vnet/udp/udp.c @@ -124,6 +124,7 @@ void 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 @@ udp_session_unbind (u32 listener_index) 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 1494b33a8c3..d0e3bf3015d 100644 --- a/src/vnet/udp/udp.h +++ b/src/vnet/udp/udp.h @@ -218,6 +218,8 @@ udp_connection_clone_safe (u32 connection_index, u32 thread_index) 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 523ab029bd4..c76c1b796bd 100644 --- a/src/vnet/udp/udp_input.c +++ b/src/vnet/udp/udp_input.c @@ -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 * |