tcp: set cc_algo on connection alloc 62/21362/3
authorFlorin Coras <fcoras@cisco.com>
Fri, 16 Aug 2019 16:44:00 +0000 (09:44 -0700)
committerDamjan Marion <dmarion@me.com>
Mon, 19 Aug 2019 09:22:38 +0000 (09:22 +0000)
Type: feature

Change-Id: Ie00329b11e26cab5db64b9c006171d283854c8ef
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_input.c

index 4628e4b..44ee8c8 100644 (file)
@@ -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,6 +135,7 @@ 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);
 
@@ -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)
 {
@@ -738,6 +751,7 @@ 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);
 
index 81ce1d5..c71b577 100644 (file)
@@ -705,6 +705,8 @@ void tcp_connection_cleanup (tcp_connection_t * tc);
 void tcp_connection_del (tcp_connection_t * tc);
 int tcp_half_open_connection_cleanup (tcp_connection_t * tc);
 tcp_connection_t *tcp_connection_alloc (u8 thread_index);
+tcp_connection_t *tcp_connection_alloc_w_base (u8 thread_index,
+                                              tcp_connection_t * base);
 void tcp_connection_free (tcp_connection_t * tc);
 void tcp_connection_reset (tcp_connection_t * tc);
 int tcp_configure_v4_source_address_range (vlib_main_t * vm,
index ccefe74..b9480ca 100755 (executable)
@@ -2302,7 +2302,6 @@ always_inline uword
 tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
                       vlib_frame_t * from_frame, int is_ip4)
 {
-  tcp_main_t *tm = vnet_get_tcp_main ();
   u32 n_left_from, *from, *first_buffer, errors = 0;
   u32 my_thread_index = vm->thread_index;
   tcp_worker_ctx_t *wrk = tcp_get_worker (my_thread_index);
@@ -2433,10 +2432,7 @@ tcp46_syn_sent_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
       /* Valid SYN or SYN-ACK. Move connection from half-open pool to
        * current thread pool. */
-      pool_get (tm->connections[my_thread_index], new_tc0);
-      clib_memcpy_fast (new_tc0, tc0, sizeof (*new_tc0));
-      new_tc0->c_c_index = new_tc0 - tm->connections[my_thread_index];
-      new_tc0->c_thread_index = my_thread_index;
+      new_tc0 = tcp_connection_alloc_w_base (my_thread_index, tc0);
       new_tc0->rcv_nxt = vnet_buffer (b0)->tcp.seq_end;
       new_tc0->irs = seq0;
       new_tc0->timers[TCP_TIMER_RETRANSMIT_SYN] = TCP_TIMER_HANDLE_INVALID;
@@ -3105,6 +3101,7 @@ tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
       child0->c_is_ip4 = is_ip4;
       child0->state = TCP_STATE_SYN_RCVD;
       child0->c_fib_index = lc0->c_fib_index;
+      child0->cc_algo = lc0->cc_algo;
 
       if (is_ip4)
        {