diff options
author | Florin Coras <fcoras@cisco.com> | 2018-10-15 21:35:42 -0700 |
---|---|---|
committer | Dave Barach <openvpp@barachs.net> | 2018-10-16 17:14:39 +0000 |
commit | eb97e5f548b009ffa92efa3f778b4a7f6f40b7eb (patch) | |
tree | 4c0148896cce873cc1fe1c26546025eb832e9dea | |
parent | f47e9b648aaab716c62bf004fa36176dbe8b21d7 (diff) |
tls: fix multi threaded medium scale test (VPP-1457)
- ensure session enqueue epoch does not wrap between two enqueues
- use 3 states for echo clients app, to distinguish between starting and
closing phases
- force tcp fin retransmit if out of buffers while sending a fin
Change-Id: I6f2cab46affd1148aba2a33fb6d58bcc54f32805
Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r-- | src/vnet/session-apps/echo_client.c | 26 | ||||
-rw-r--r-- | src/vnet/session-apps/echo_client.h | 6 | ||||
-rw-r--r-- | src/vnet/session/session.c | 8 | ||||
-rw-r--r-- | src/vnet/session/session.h | 3 | ||||
-rw-r--r-- | src/vnet/session/stream_session.h | 5 | ||||
-rw-r--r-- | src/vnet/tcp/tcp_output.c | 10 | ||||
-rw-r--r-- | src/vnet/tls/tls.c | 5 |
7 files changed, 52 insertions, 11 deletions
diff --git a/src/vnet/session-apps/echo_client.c b/src/vnet/session-apps/echo_client.c index b47dcf21a4b..0258c16520a 100644 --- a/src/vnet/session-apps/echo_client.c +++ b/src/vnet/session-apps/echo_client.c @@ -208,7 +208,7 @@ echo_client_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node, connections_this_batch = ecm->connections_this_batch_by_thread[my_thread_index]; - if ((ecm->run_test == 0) || + if ((ecm->run_test != ECHO_CLIENTS_RUNNING) || ((vec_len (connection_indices) == 0) && vec_len (connections_this_batch) == 0)) return 0; @@ -352,6 +352,16 @@ echo_clients_init (vlib_main_t * vm) return 0; } +static void +echo_clients_session_disconnect (stream_session_t * s) +{ + echo_client_main_t *ecm = &echo_client_main; + vnet_disconnect_args_t _a, *a = &_a; + a->handle = session_handle (s); + a->app_index = ecm->app_index; + vnet_disconnect_session (a); +} + static int echo_clients_session_connected_callback (u32 app_index, u32 api_context, stream_session_t * s, u8 is_fail) @@ -361,6 +371,9 @@ echo_clients_session_connected_callback (u32 app_index, u32 api_context, u32 session_index; u8 thread_index; + if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_STARTING)) + return -1; + if (is_fail) { clib_warning ("connection %d failed!", api_context); @@ -407,7 +420,7 @@ echo_clients_session_connected_callback (u32 app_index, u32 api_context, __sync_fetch_and_add (&ecm->ready_connections, 1); if (ecm->ready_connections == ecm->expected_connections) { - ecm->run_test = 1; + ecm->run_test = ECHO_CLIENTS_RUNNING; /* Signal the CLI process that the action is starting... */ signal_evt_to_cli (1); } @@ -447,6 +460,12 @@ echo_clients_rx_callback (stream_session_t * s) echo_client_main_t *ecm = &echo_client_main; eclient_session_t *sp; + if (PREDICT_FALSE (ecm->run_test != ECHO_CLIENTS_RUNNING)) + { + echo_clients_session_disconnect (s); + return -1; + } + sp = pool_elt_at_index (ecm->sessions, s->server_rx_fifo->client_session_index); receive_data_chunk (ecm, sp); @@ -624,6 +643,7 @@ echo_clients_command_fn (vlib_main_t * vm, ecm->vlib_main = vm; ecm->tls_engine = TLS_ENGINE_OPENSSL; ecm->no_copy = 0; + ecm->run_test = ECHO_CLIENTS_STARTING; if (thread_main->n_vlib_mains > 1) clib_spinlock_init (&ecm->sessions_lock); @@ -825,7 +845,7 @@ echo_clients_command_fn (vlib_main_t * vm, error = clib_error_return (0, "failed: test bytes"); cleanup: - ecm->run_test = 0; + ecm->run_test = ECHO_CLIENTS_EXITING; vlib_process_wait_for_event_or_clock (vm, 10e-3); for (i = 0; i < vec_len (ecm->connection_index_by_thread); i++) { diff --git a/src/vnet/session-apps/echo_client.h b/src/vnet/session-apps/echo_client.h index db5ba163628..2270720dcda 100644 --- a/src/vnet/session-apps/echo_client.h +++ b/src/vnet/session-apps/echo_client.h @@ -105,6 +105,12 @@ typedef struct vlib_main_t *vlib_main; } echo_client_main_t; +enum +{ + ECHO_CLIENTS_STARTING, + ECHO_CLIENTS_RUNNING, + ECHO_CLIENTS_EXITING +} echo_clients_test_state_e; extern echo_client_main_t echo_client_main; vlib_node_registration_t echo_clients_node; diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c index 83b96d317dc..7b50950fe01 100644 --- a/src/vnet/session/session.c +++ b/src/vnet/session/session.c @@ -153,7 +153,7 @@ session_free (stream_session_t * s) memset (s, 0xFA, sizeof (*s)); } -static void +void session_free_w_fifos (stream_session_t * s) { segment_manager_dealloc_fifos (s->svm_segment_index, s->server_rx_fifo, @@ -197,7 +197,7 @@ session_alloc_for_connection (transport_connection_t * tc) s = session_alloc (thread_index); s->session_type = session_type_from_proto_and_ip (tc->proto, tc->is_ip4); s->session_state = SESSION_STATE_CONNECTING; - s->enqueue_epoch = ~0; + s->enqueue_epoch = (u64) ~ 0; /* Attach transport to session and vice versa */ s->connection_index = tc->c_index; @@ -393,7 +393,7 @@ session_enqueue_stream_connection (transport_connection_t * tc, * by calling stream_server_flush_enqueue_events () */ session_manager_main_t *smm = vnet_get_session_manager_main (); u32 thread_index = s->thread_index; - u32 enqueue_epoch = smm->current_enqueue_epoch[tc->proto][thread_index]; + u64 enqueue_epoch = smm->current_enqueue_epoch[tc->proto][thread_index]; if (s->enqueue_epoch != enqueue_epoch) { @@ -434,7 +434,7 @@ session_enqueue_dgram_connection (stream_session_t * s, * by calling stream_server_flush_enqueue_events () */ session_manager_main_t *smm = vnet_get_session_manager_main (); u32 thread_index = s->thread_index; - u32 enqueue_epoch = smm->current_enqueue_epoch[proto][thread_index]; + u64 enqueue_epoch = smm->current_enqueue_epoch[proto][thread_index]; if (s->enqueue_epoch != enqueue_epoch) { diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h index 1e08cccb6f7..914e0581fec 100644 --- a/src/vnet/session/session.h +++ b/src/vnet/session/session.h @@ -195,7 +195,7 @@ struct _session_manager_main clib_rwlock_t *peekers_rw_locks; /** Per-proto, per-worker enqueue epoch counters */ - u32 *current_enqueue_epoch[TRANSPORT_N_PROTO]; + u64 *current_enqueue_epoch[TRANSPORT_N_PROTO]; /** Per-proto, per-worker thread vector of sessions to enqueue */ u32 **session_to_enqueue[TRANSPORT_N_PROTO]; @@ -308,6 +308,7 @@ stream_session_is_valid (u32 si, u8 thread_index) stream_session_t *session_alloc (u32 thread_index); int session_alloc_fifos (segment_manager_t * sm, stream_session_t * s); void session_free (stream_session_t * s); +void session_free_w_fifos (stream_session_t * s); always_inline stream_session_t * session_get (u32 si, u32 thread_index) diff --git a/src/vnet/session/stream_session.h b/src/vnet/session/stream_session.h index 30178d7a453..287a8927339 100644 --- a/src/vnet/session/stream_session.h +++ b/src/vnet/session/stream_session.h @@ -67,7 +67,7 @@ typedef struct _stream_session_t u8 thread_index; /** To avoid n**2 "one event per frame" check */ - u8 enqueue_epoch; + u64 enqueue_epoch; /** svm segment index where fifos were allocated */ u32 svm_segment_index; @@ -120,6 +120,9 @@ typedef struct local_session_ /** Port for connection. Overlaps thread_index/enqueue_epoch */ u16 port; + /** Partly overlaps enqueue_epoch */ + u8 pad_epoch[7]; + /** Segment index where fifos were allocated */ u32 svm_segment_index; diff --git a/src/vnet/tcp/tcp_output.c b/src/vnet/tcp/tcp_output.c index 0d5feb976f8..79d64cf2da3 100644 --- a/src/vnet/tcp/tcp_output.c +++ b/src/vnet/tcp/tcp_output.c @@ -1078,7 +1078,15 @@ tcp_send_fin (tcp_connection_t * tc) tcp_retransmit_timer_force_update (tc); if (PREDICT_FALSE (tcp_get_free_buffer_index (tm, &bi))) - return; + { + /* Out of buffers so program fin retransmit ASAP */ + tcp_timer_update (tc, TCP_TIMER_RETRANSMIT, 1); + tc->flags |= TCP_CONN_FINSNT; + tc->snd_una_max += 1; + tc->snd_nxt = tc->snd_una_max; + return; + } + b = vlib_get_buffer (vm, bi); tcp_init_buffer (vm, b); fin_snt = tc->flags & TCP_CONN_FINSNT; diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c index aba7919927c..9a82360610b 100644 --- a/src/vnet/tls/tls.c +++ b/src/vnet/tls/tls.c @@ -119,6 +119,7 @@ tls_ctx_half_open_alloc (void) { clib_rwlock_writer_lock (&tm->half_open_rwlock); pool_get (tm->half_open_ctx_pool, ctx); + ctx_index = ctx - tm->half_open_ctx_pool; clib_rwlock_writer_unlock (&tm->half_open_rwlock); } else @@ -126,10 +127,10 @@ tls_ctx_half_open_alloc (void) /* reader lock assumption: only main thread will call pool_get */ clib_rwlock_reader_lock (&tm->half_open_rwlock); pool_get (tm->half_open_ctx_pool, ctx); + ctx_index = ctx - tm->half_open_ctx_pool; clib_rwlock_reader_unlock (&tm->half_open_rwlock); } memset (ctx, 0, sizeof (*ctx)); - ctx_index = ctx - tm->half_open_ctx_pool; return ctx_index; } @@ -254,6 +255,8 @@ tls_notify_app_connected (tls_ctx_t * ctx, u8 is_failed) { TLS_DBG (1, "failed to notify app"); tls_disconnect (ctx->tls_ctx_handle, vlib_get_thread_index ()); + session_free_w_fifos (app_session); + return -1; } session_lookup_add_connection (&ctx->connection, |