aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/udp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/udp')
-rw-r--r--src/vnet/udp/udp.c34
1 files changed, 10 insertions, 24 deletions
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index 4553701dced..7147fa32657 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -362,44 +362,30 @@ udp_open_connection (transport_endpoint_cfg_t * rmt)
rv = transport_alloc_local_endpoint (TRANSPORT_PROTO_UDP, rmt, &lcl_addr,
&lcl_port);
if (rv)
- {
- if (rv != SESSION_E_PORTINUSE)
- return rv;
-
- if (udp_connection_port_used_extern (lcl_port, rmt->is_ip4))
- return SESSION_E_PORTINUSE;
-
- /* If port in use, check if 5-tuple is also in use */
- if (session_lookup_connection (rmt->fib_index, &lcl_addr, &rmt->ip,
- lcl_port, rmt->port, TRANSPORT_PROTO_UDP,
- rmt->is_ip4))
- return SESSION_E_PORTINUSE;
-
- /* 5-tuple is available so increase lcl endpoint refcount and proceed
- * with connection allocation */
- transport_share_local_endpoint (TRANSPORT_PROTO_UDP, &lcl_addr,
- lcl_port);
- goto conn_alloc;
- }
+ return rv;
if (udp_is_valid_dst_port (lcl_port, rmt->is_ip4))
{
/* If specific source port was requested abort */
if (rmt->peer.port)
- return SESSION_E_PORTINUSE;
+ {
+ transport_release_local_endpoint (TRANSPORT_PROTO_UDP, &lcl_addr,
+ lcl_port);
+ return SESSION_E_PORTINUSE;
+ }
/* Try to find a port that's not used */
while (udp_is_valid_dst_port (lcl_port, rmt->is_ip4))
{
- lcl_port = transport_alloc_local_port (TRANSPORT_PROTO_UDP,
- &lcl_addr);
+ transport_release_local_endpoint (TRANSPORT_PROTO_UDP, &lcl_addr,
+ lcl_port);
+ lcl_port =
+ transport_alloc_local_port (TRANSPORT_PROTO_UDP, &lcl_addr, rmt);
if (lcl_port < 1)
return SESSION_E_PORTINUSE;
}
}
-conn_alloc:
-
/* We don't poll main thread if we have workers */
thread_index = transport_cl_thread ();