aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2023-03-14 09:59:02 -0700
committerDave Barach <vpp@barachs.net>2023-03-16 16:57:00 +0000
commite541d6f0edd39a093bcbee91282969647c1e6ebf (patch)
treefedc3d26cffb3f6306020a50f98084d9a9986bd9
parent890eced9171388a62ad9dbd810627cad51e53208 (diff)
session: support active opens with same source port
Type: fix Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I2b426e9e988c32d261f36367087f358d8cc25e2f
-rw-r--r--src/vnet/session/transport.c13
-rw-r--r--src/vnet/tcp/tcp.c4
2 files changed, 14 insertions, 3 deletions
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 06954c04ccc..7e40164a9f8 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -734,7 +734,18 @@ transport_alloc_local_endpoint (u8 proto, transport_endpoint_cfg_t * rmt_cfg,
port = clib_net_to_host_u16 (rmt_cfg->peer.port);
*lcl_port = port;
- return transport_endpoint_mark_used (proto, lcl_addr, port);
+ if (!transport_endpoint_mark_used (proto, lcl_addr, port))
+ return 0;
+
+ /* IP:port pair already in use, check if 6-tuple available */
+ if (session_lookup_connection (rmt->fib_index, lcl_addr, &rmt->ip, port,
+ rmt->port, proto, rmt->is_ip4))
+ return SESSION_E_PORTINUSE;
+
+ /* 6-tuple is available so increment lcl endpoint refcount */
+ transport_share_local_endpoint (proto, lcl_addr, port);
+
+ return 0;
}
return 0;
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 6e0c1474dd5..5c612a73970 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -808,8 +808,8 @@ tcp_session_open (transport_endpoint_cfg_t * rmt)
|| (!rmt->is_ip4 && vec_len (tcp_cfg.ip6_src_addrs)))
rv = tcp_alloc_custom_local_endpoint (&lcl_addr, &lcl_port, rmt);
else
- rv = transport_alloc_local_endpoint (TRANSPORT_PROTO_TCP,
- rmt, &lcl_addr, &lcl_port);
+ rv = transport_alloc_local_endpoint (TRANSPORT_PROTO_TCP, rmt, &lcl_addr,
+ &lcl_port);
if (rv)
return rv;