summaryrefslogtreecommitdiffstats
path: root/src/vnet/tcp/tcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/tcp/tcp.c')
-rw-r--r--src/vnet/tcp/tcp.c50
1 files changed, 23 insertions, 27 deletions
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index c70a44cae90..c54a994fede 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -181,6 +181,13 @@ tcp_session_get_listener (u32 listener_index)
return &tc->connection;
}
+static tcp_connection_t *
+tcp_half_open_connection_alloc (void)
+{
+ ASSERT (vlib_get_thread_index () == 0);
+ return tcp_connection_alloc (0);
+}
+
/**
* Cleanup half-open connection
*
@@ -188,10 +195,8 @@ tcp_session_get_listener (u32 listener_index)
static void
tcp_half_open_connection_free (tcp_connection_t * tc)
{
- tcp_main_t *tm = vnet_get_tcp_main ();
- if (CLIB_DEBUG)
- clib_memset (tc, 0xFA, sizeof (*tc));
- pool_put (tm->half_open_connections, tc);
+ ASSERT (vlib_get_thread_index () == 0);
+ return tcp_connection_free (tc);
}
/**
@@ -219,18 +224,6 @@ tcp_half_open_connection_cleanup (tcp_connection_t * tc)
return 0;
}
-static tcp_connection_t *
-tcp_half_open_connection_new (void)
-{
- tcp_main_t *tm = vnet_get_tcp_main ();
- tcp_connection_t *tc = 0;
- ASSERT (vlib_get_thread_index () == 0);
- pool_get (tm->half_open_connections, tc);
- clib_memset (tc, 0, sizeof (*tc));
- tc->c_c_index = tc - tm->half_open_connections;
- return tc;
-}
-
/**
* Cleans up connection state.
*
@@ -304,13 +297,23 @@ tcp_connection_alloc (u8 thread_index)
}
tcp_connection_t *
-tcp_connection_alloc_w_base (u8 thread_index, tcp_connection_t * base)
+tcp_connection_alloc_w_base (u8 thread_index, tcp_connection_t **base)
{
tcp_worker_ctx_t *wrk = tcp_get_worker (thread_index);
tcp_connection_t *tc;
- pool_get (wrk->connections, tc);
- clib_memcpy_fast (tc, base, sizeof (*tc));
+ /* Make sure connection is still valid if pool moves */
+ if ((*base)->c_thread_index == thread_index)
+ {
+ u32 base_index = (*base)->c_c_index;
+ pool_get (wrk->connections, tc);
+ *base = tcp_connection_get (base_index, thread_index);
+ }
+ else
+ {
+ pool_get (wrk->connections, tc);
+ }
+ clib_memcpy_fast (tc, *base, sizeof (*tc));
tc->c_c_index = tc - wrk->connections;
tc->c_thread_index = thread_index;
return tc;
@@ -816,7 +819,7 @@ tcp_session_open (transport_endpoint_cfg_t * rmt)
/*
* Create connection and send SYN
*/
- tc = tcp_half_open_connection_new ();
+ tc = tcp_half_open_connection_alloc ();
ip_copy (&tc->c_rmt_ip, &rmt->ip, rmt->is_ip4);
ip_copy (&tc->c_lcl_ip, &lcl_addr, rmt->is_ip4);
tc->c_rmt_port = rmt->port;
@@ -1515,13 +1518,6 @@ tcp_main_enable (vlib_main_t * vm)
vlib_time_now (vm));
}
- /*
- * Use a preallocated half-open connection pool?
- */
- if (tcp_cfg.preallocated_half_open_connections)
- pool_init_fixed (tm->half_open_connections,
- tcp_cfg.preallocated_half_open_connections);
-
tcp_initialize_iss_seed (tm);
tm->bytes_per_buffer = vlib_buffer_get_default_data_size (vm);