X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fvnet%2Ftcp%2Ftcp.c;h=bfab1d6f0c590e4171a6e73dcc4cbb8bb9e036b1;hb=a436a42221280888acd09858c7353e694c359bca;hp=3b94420e6398c0011e34fe85e385041740e134ca;hpb=9094b5c319d3f072d3c248fe7c876e4048c13ac2;p=vpp.git diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c index 3b94420e639..bfab1d6f0c5 100644 --- a/src/vnet/tcp/tcp.c +++ b/src/vnet/tcp/tcp.c @@ -73,7 +73,6 @@ tcp_add_del_adjacency (tcp_connection_t * tc, u8 is_add) static void tcp_cc_init (tcp_connection_t * tc) { - tc->cc_algo = tcp_cc_algo_get (tcp_cfg.cc_algo); tc->cc_algo->init (tc); } @@ -136,10 +135,11 @@ tcp_connection_bind (u32 session_index, transport_endpoint_t * lcl) listener->c_s_index = session_index; listener->c_fib_index = lcl->fib_index; listener->state = TCP_STATE_LISTEN; + listener->cc_algo = tcp_cc_algo_get (tcp_cfg.cc_algo); tcp_connection_timers_init (listener); - TCP_EVT_DBG (TCP_EVT_BIND, listener); + TCP_EVT (TCP_EVT_BIND, listener); return listener->c_c_index; } @@ -158,7 +158,7 @@ tcp_connection_unbind (u32 listener_index) tc = pool_elt_at_index (tm->listener_pool, listener_index); - TCP_EVT_DBG (TCP_EVT_UNBIND, tc); + TCP_EVT (TCP_EVT_UNBIND, tc); /* Poison the entry */ if (CLIB_DEBUG > 0) @@ -240,7 +240,7 @@ tcp_connection_cleanup (tcp_connection_t * tc) { tcp_main_t *tm = &tcp_main; - TCP_EVT_DBG (TCP_EVT_DELETE, tc); + TCP_EVT (TCP_EVT_DELETE, tc); /* Cleanup local endpoint if this was an active connect */ transport_endpoint_cleanup (TRANSPORT_PROTO_TCP, &tc->c_lcl_ip, @@ -306,6 +306,19 @@ tcp_connection_alloc (u8 thread_index) return tc; } +tcp_connection_t * +tcp_connection_alloc_w_base (u8 thread_index, tcp_connection_t * base) +{ + tcp_main_t *tm = vnet_get_tcp_main (); + tcp_connection_t *tc; + + pool_get (tm->connections[thread_index], tc); + clib_memcpy_fast (tc, base, sizeof (*tc)); + tc->c_c_index = tc - tm->connections[thread_index]; + tc->c_thread_index = thread_index; + return tc; +} + void tcp_connection_free (tcp_connection_t * tc) { @@ -327,7 +340,7 @@ tcp_connection_free (tcp_connection_t * tc) void tcp_connection_reset (tcp_connection_t * tc) { - TCP_EVT_DBG (TCP_EVT_RST_RCVD, tc); + TCP_EVT (TCP_EVT_RST_RCVD, tc); switch (tc->state) { case TCP_STATE_SYN_RCVD: @@ -384,7 +397,7 @@ tcp_connection_reset (tcp_connection_t * tc) void tcp_connection_close (tcp_connection_t * tc) { - TCP_EVT_DBG (TCP_EVT_CLOSE, tc); + TCP_EVT (TCP_EVT_CLOSE, tc); /* Send/Program FIN if needed and switch state */ switch (tc->state) @@ -464,6 +477,18 @@ tcp_session_cleanup (u32 conn_index, u32 thread_index) tcp_connection_cleanup (tc); } +static void +tcp_session_reset (u32 conn_index, u32 thread_index) +{ + tcp_connection_t *tc; + tc = tcp_connection_get (conn_index, thread_index); + session_transport_closed_notify (&tc->connection); + tcp_send_reset (tc); + tcp_connection_timers_reset (tc); + tcp_connection_set_state (tc, TCP_STATE_CLOSED); + tcp_timer_update (tc, TCP_TIMER_WAITCLOSE, tcp_cfg.cleanup_time); +} + /** * Initialize all connection timers as invalid */ @@ -738,10 +763,11 @@ tcp_session_open (transport_endpoint_cfg_t * rmt) tc->c_is_ip4 = rmt->is_ip4; tc->c_proto = TRANSPORT_PROTO_TCP; tc->c_fib_index = rmt->fib_index; + tc->cc_algo = tcp_cc_algo_get (tcp_cfg.cc_algo); /* The other connection vars will be initialized after SYN ACK */ tcp_connection_timers_init (tc); - TCP_EVT_DBG (TCP_EVT_OPEN, tc); + TCP_EVT (TCP_EVT_OPEN, tc); tc->state = TCP_STATE_SYN_SENT; tcp_init_snd_vars (tc); tcp_send_syn (tc); @@ -750,12 +776,6 @@ tcp_session_open (transport_endpoint_cfg_t * rmt) return tc->c_c_index; } -const char *tcp_dbg_evt_str[] = { -#define _(sym, str) str, - foreach_tcp_dbg_evt -#undef _ -}; - const char *tcp_fsm_states[] = { #define _(sym, str) str, foreach_tcp_fsm_state @@ -1244,6 +1264,7 @@ const static transport_proto_vft_t tcp_proto = { .connect = tcp_session_open, .close = tcp_session_close, .cleanup = tcp_session_cleanup, + .reset = tcp_session_reset, .send_mss = tcp_session_send_mss, .send_space = tcp_session_send_space, .update_time = tcp_update_time, @@ -1263,17 +1284,11 @@ const static transport_proto_vft_t tcp_proto = { void tcp_connection_tx_pacer_update (tcp_connection_t * tc) { - f64 srtt; - u64 rate; - if (!transport_connection_is_tx_paced (&tc->connection)) return; - srtt = clib_min ((f64) tc->srtt * TCP_TICK, tc->mrtt_us); - /* TODO should constrain to interface's max throughput but - * we don't have link speeds for sw ifs ..*/ - rate = tc->cwnd / srtt; - transport_connection_tx_pacer_update (&tc->connection, rate); + transport_connection_tx_pacer_update (&tc->connection, + tcp_cc_get_pacing_rate (tc)); } void @@ -1380,7 +1395,7 @@ tcp_expired_timers_dispatch (u32 * expired_timers) connection_index = expired_timers[i] & 0x0FFFFFFF; timer_id = expired_timers[i] >> 28; - TCP_EVT_DBG (TCP_EVT_TIMER_POP, connection_index, timer_id); + TCP_EVT (TCP_EVT_TIMER_POP, connection_index, timer_id); /* Handle expiration */ (*timer_expiration_handlers[timer_id]) (connection_index); @@ -1578,7 +1593,7 @@ VLIB_INIT_FUNCTION (tcp_init); uword unformat_tcp_cc_algo (unformat_input_t * input, va_list * va) { - uword *result = va_arg (*va, uword *); + tcp_cc_algorithm_type_e *result = va_arg (*va, tcp_cc_algorithm_type_e *); tcp_main_t *tm = &tcp_main; char *cc_algo_name; u8 found = 0;