tcp: avoid regrabing error node in input and output
[vpp.git] / src / vnet / tcp / tcp_output.c
index a68d526..a21c012 100644 (file)
@@ -1472,7 +1472,7 @@ tcp_timer_retransmit_syn_handler (tcp_connection_t * tc)
   /* Active open establish timeout */
   if (tc->rto >= TCP_ESTABLISH_TIME >> 1)
     {
-      session_stream_connect_notify (&tc->connection, 1 /* fail */ );
+      session_stream_connect_notify (&tc->connection, SESSION_E_TIMEDOUT);
       tcp_connection_cleanup (tc);
       return;
     }
@@ -2010,7 +2010,7 @@ tcp_do_retransmit (tcp_connection_t * tc, u32 max_burst_size)
 }
 
 int
-tcp_session_custom_tx (void *conn, u32 max_burst_size)
+tcp_session_custom_tx (void *conn, transport_send_params_t * sp)
 {
   tcp_connection_t *tc = (tcp_connection_t *) conn;
   u32 n_segs = 0;
@@ -2018,8 +2018,7 @@ tcp_session_custom_tx (void *conn, u32 max_burst_size)
   if (tcp_in_cong_recovery (tc) && (tc->flags & TCP_CONN_RXT_PENDING))
     {
       tc->flags &= ~TCP_CONN_RXT_PENDING;
-      n_segs = tcp_do_retransmit (tc, max_burst_size);
-      max_burst_size -= n_segs;
+      n_segs = tcp_do_retransmit (tc, sp->max_burst_size);
     }
 
   if (!(tc->flags & TCP_CONN_SNDACK))
@@ -2031,13 +2030,13 @@ tcp_session_custom_tx (void *conn, u32 max_burst_size)
   if (n_segs && !tc->pending_dupacks)
     return n_segs;
 
-  if (!max_burst_size)
+  if (sp->max_burst_size <= n_segs)
     {
       tcp_program_ack (tc);
-      return max_burst_size;
+      return n_segs;
     }
 
-  n_segs += tcp_send_acks (tc, max_burst_size);
+  n_segs += tcp_send_acks (tc, sp->max_burst_size - n_segs);
 
   return n_segs;
 }
@@ -2182,9 +2181,6 @@ tcp46_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
   u32 n_left_from, *from, thread_index = vm->thread_index;
   vlib_buffer_t *bufs[VLIB_FRAME_SIZE], **b;
   u16 nexts[VLIB_FRAME_SIZE], *next;
-  vlib_node_runtime_t *error_node;
-
-  error_node = vlib_node_get_runtime (vm, tcp_node_index (output, is_ip4));
 
   from = vlib_frame_vector_args (frame);
   n_left_from = frame->n_vectors;
@@ -2222,8 +2218,8 @@ tcp46_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          tcp_check_if_gso (tc0, b[0]);
          tcp_check_if_gso (tc1, b[1]);
 
-         tcp_output_handle_packet (tc0, b[0], error_node, &next[0], is_ip4);
-         tcp_output_handle_packet (tc1, b[1], error_node, &next[1], is_ip4);
+         tcp_output_handle_packet (tc0, b[0], node, &next[0], is_ip4);
+         tcp_output_handle_packet (tc1, b[1], node, &next[1], is_ip4);
        }
       else
        {
@@ -2231,24 +2227,22 @@ tcp46_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
            {
              tcp_output_push_ip (vm, b[0], tc0, is_ip4);
              tcp_check_if_gso (tc0, b[0]);
-             tcp_output_handle_packet (tc0, b[0], error_node, &next[0],
-                                       is_ip4);
+             tcp_output_handle_packet (tc0, b[0], node, &next[0], is_ip4);
            }
          else
            {
-             b[0]->error = error_node->errors[TCP_ERROR_INVALID_CONNECTION];
+             b[0]->error = node->errors[TCP_ERROR_INVALID_CONNECTION];
              next[0] = TCP_OUTPUT_NEXT_DROP;
            }
          if (tc1 != 0)
            {
              tcp_output_push_ip (vm, b[1], tc1, is_ip4);
              tcp_check_if_gso (tc1, b[1]);
-             tcp_output_handle_packet (tc1, b[1], error_node, &next[1],
-                                       is_ip4);
+             tcp_output_handle_packet (tc1, b[1], node, &next[1], is_ip4);
            }
          else
            {
-             b[1]->error = error_node->errors[TCP_ERROR_INVALID_CONNECTION];
+             b[1]->error = node->errors[TCP_ERROR_INVALID_CONNECTION];
              next[1] = TCP_OUTPUT_NEXT_DROP;
            }
        }
@@ -2274,11 +2268,11 @@ tcp46_output_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
        {
          tcp_output_push_ip (vm, b[0], tc0, is_ip4);
          tcp_check_if_gso (tc0, b[0]);
-         tcp_output_handle_packet (tc0, b[0], error_node, &next[0], is_ip4);
+         tcp_output_handle_packet (tc0, b[0], node, &next[0], is_ip4);
        }
       else
        {
-         b[0]->error = error_node->errors[TCP_ERROR_INVALID_CONNECTION];
+         b[0]->error = node->errors[TCP_ERROR_INVALID_CONNECTION];
          next[0] = TCP_OUTPUT_NEXT_DROP;
        }