aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/udp/udp.c
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2023-01-09 12:46:07 -0800
committerDave Barach <vpp@barachs.net>2023-01-10 18:25:32 +0000
commit9bc72ac8de6dcc74aa82fa6c3223e9f93b2dc3c2 (patch)
tree2ee71b1319f75224bd44f5cca4bed195ff444a69 /src/vnet/udp/udp.c
parenta9e266ea4a8d87eb9383a7fe936426380db9623b (diff)
udp: avoid listener cleanups with active opens
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Ibff9f32e4fcaf0344207d8e43f3547180cbd4eef
Diffstat (limited to 'src/vnet/udp/udp.c')
-rw-r--r--src/vnet/udp/udp.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index e095a66dcf2..4553701dced 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -38,6 +38,9 @@ udp_connection_register_port (u16 lcl_port, u8 is_ip4)
n = sparse_vec_validate (um->next_by_dst_port6, lcl_port);
n[0] = um->local_to_input_edge[is_ip4];
+
+ __atomic_add_fetch (&um->transport_ports_refcnt[is_ip4][lcl_port], 1,
+ __ATOMIC_RELAXED);
}
static void
@@ -46,6 +49,11 @@ udp_connection_unregister_port (u16 lcl_port, u8 is_ip4)
udp_main_t *um = &udp_main;
u16 *n;
+ /* Needed because listeners are not tracked as local endpoints */
+ if (__atomic_sub_fetch (&um->transport_ports_refcnt[is_ip4][lcl_port], 1,
+ __ATOMIC_RELAXED))
+ return;
+
if (is_ip4)
n = sparse_vec_validate (um->next_by_dst_port4, lcl_port);
else
@@ -548,6 +556,9 @@ udp_enable_disable (vlib_main_t *vm, u8 is_en)
udp_realloc_ports_sv (&um->next_by_dst_port4);
udp_realloc_ports_sv (&um->next_by_dst_port6);
+ vec_validate (um->transport_ports_refcnt[0], 65535);
+ vec_validate (um->transport_ports_refcnt[1], 65535);
+
return 0;
}