summaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2020-04-10 14:51:46 +0000
committerDave Barach <openvpp@barachs.net>2020-04-15 14:04:04 +0000
commit1e8d949781a44846dabbf56e1aab80bbf4cc8d59 (patch)
treee49156954369441e590ef0b30ca897ca0c223cdc /src/vnet
parent1bd2c019eba5c893d634cc496bd6d54c00020d7e (diff)
tcp: allow local port sharing if 5-tuple available
Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: Id0c4b46247e7419a328387678a4753cfb1e42d75
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/tcp/tcp.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index b1ae37409fd..e4335e06769 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -764,7 +764,20 @@ tcp_session_open (transport_endpoint_cfg_t * rmt)
rmt, &lcl_addr, &lcl_port);
if (rv)
- return rv;
+ {
+ if (rv != SESSION_E_PORTINUSE)
+ return rv;
+
+ 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);
+ }
/*
* Create connection and send SYN