aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2019-05-13 16:25:50 +0200
committerFlorin Coras <florin.coras@gmail.com>2019-05-14 02:02:43 +0000
commit161638f14b967c9b11dee130c596f008c9e857c3 (patch)
tree9c969b7c2ed1b1646c8f986096fa6f20f7fc75a9
parent07c0a9d0687a8f38b2863ada33836caf05399bac (diff)
Unregister UDPC port only when owned
Needed in QUIC, when cleaning up accepted UDP sessions Change-Id: Ifcb32687175562bed4ca69bdc519cedd4dc3c2bc Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
-rw-r--r--src/vnet/udp/udp.c7
-rw-r--r--src/vnet/udp/udp.h3
-rw-r--r--src/vnet/udp/udp_input.c1
3 files changed, 9 insertions, 2 deletions
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index 4178a49c4db..d5166d9142e 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -95,6 +95,7 @@ udp_session_bind (u32 session_index, transport_endpoint_t * lcl)
listener->c_proto = TRANSPORT_PROTO_UDP;
listener->c_s_index = session_index;
listener->c_fib_index = lcl->fib_index;
+ listener->owns_port = 1;
clib_spinlock_init (&listener->rx_lock);
node_index = lcl->is_ip4 ? udp4_input_node.index : udp6_input_node.index;
@@ -168,8 +169,9 @@ udp_session_close (u32 connection_index, u32 thread_index)
uc = udp_connection_get (connection_index, thread_index);
if (uc)
{
- udp_unregister_dst_port (vm, clib_net_to_host_u16 (uc->c_lcl_port),
- uc->c_is_ip4);
+ if (uc->owns_port || !uc->is_connected)
+ udp_unregister_dst_port (vm, clib_net_to_host_u16 (uc->c_lcl_port),
+ uc->c_is_ip4);
session_transport_delete_notify (&uc->connection);
udp_connection_free (uc);
}
@@ -302,6 +304,7 @@ udp_open_connection (transport_endpoint_cfg_t * rmt)
uc->c_is_ip4 = rmt->is_ip4;
uc->c_proto = TRANSPORT_PROTO_UDP;
uc->c_fib_index = rmt->fib_index;
+ uc->owns_port = 1;
return uc->c_c_index;
}
diff --git a/src/vnet/udp/udp.h b/src/vnet/udp/udp.h
index 03dbcdd5cac..f5efbbca0ff 100644
--- a/src/vnet/udp/udp.h
+++ b/src/vnet/udp/udp.h
@@ -41,6 +41,7 @@ typedef struct
transport_connection_t connection; /**< must be first */
clib_spinlock_t rx_lock; /**< rx fifo lock */
u8 is_connected; /**< connected mode */
+ u8 owns_port; /**< does port belong to conn (UDPC) */
} udp_connection_t;
#define foreach_udp4_dst_port \
@@ -234,6 +235,8 @@ udp_connection_clone_safe (u32 connection_index, u32 thread_index)
udp_pool_remove_peeker (thread_index);
new_c->c_thread_index = current_thread_index;
new_c->c_c_index = udp_connection_index (new_c);
+ new_c->is_connected = old_c->is_connected;
+ new_c->c_fib_index = old_c->c_fib_index;
return new_c;
}
diff --git a/src/vnet/udp/udp_input.c b/src/vnet/udp/udp_input.c
index e42f9fa754f..c6b9167aff6 100644
--- a/src/vnet/udp/udp_input.c
+++ b/src/vnet/udp/udp_input.c
@@ -207,6 +207,7 @@ udp46_input_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
child0->c_rmt_port = udp0->src_port;
child0->c_is_ip4 = is_ip4;
child0->c_fib_index = tc0->fib_index;
+ child0->is_connected = 1;
if (session_stream_accept (&child0->connection,
tc0->s_index, 1))