tcp: fix syn-sent reset
[vpp.git] / src / vnet / tcp / tcp_input.c
index 164a1b3..67cec5a 100755 (executable)
@@ -327,8 +327,8 @@ tcp_rcv_rst (tcp_worker_ctx_t * wrk, tcp_connection_t * tc)
       tcp_connection_set_state (tc, TCP_STATE_CLOSED);
       break;
     case TCP_STATE_SYN_SENT:
-      tcp_program_reset_ntf (wrk, tc);
-      tcp_connection_set_state (tc, TCP_STATE_CLOSED);
+      /* Do not program ntf because the connection is half-open */
+      tcp_handle_rst (tc);
       break;
     case TCP_STATE_ESTABLISHED:
       tcp_connection_timers_reset (tc);
@@ -2945,7 +2945,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          /* Make sure the segment is exactly right */
          if (tc0->rcv_nxt != vnet_buffer (b0)->tcp.seq_number || is_fin0)
            {
-             tcp_rcv_rst (wrk, tc0);
+             tcp_send_reset_w_pkt (tc0, b0, thread_index, is_ip4);
              error0 = TCP_ERROR_SEGMENT_INVALID;
              goto drop;
            }
@@ -2958,7 +2958,8 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
           */
          if (tcp_rcv_ack_no_cc (tc0, b0, &error0))
            {
-             tcp_rcv_rst (wrk, tc0);
+             tcp_send_reset_w_pkt (tc0, b0, thread_index, is_ip4);
+             error0 = TCP_ERROR_SEGMENT_INVALID;
              goto drop;
            }
 
@@ -2985,7 +2986,9 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          if (session_stream_accept_notify (&tc0->connection))
            {
              error0 = TCP_ERROR_MSG_QUEUE_FULL;
-             tcp_rcv_rst (wrk, tc0);
+             tcp_send_reset (tc0);
+             session_transport_delete_notify (&tc0->connection);
+             tcp_connection_cleanup (tc0);
              goto drop;
            }
          error0 = TCP_ERROR_ACK_OK;
@@ -3702,14 +3705,10 @@ tcp_input_dispatch_buffer (tcp_main_t * tm, tcp_connection_t * tc,
 
   if (PREDICT_FALSE (error != TCP_ERROR_NONE))
     {
-      /* Overload tcp flags to store state */
-      tcp_state_t state = tc->state;
-      vnet_buffer (b)->tcp.flags = tc->state;
-
       b->error = error_node->errors[error];
       if (error == TCP_ERROR_DISPATCH)
        clib_warning ("tcp conn %u disp error state %U flags %U",
-                     tc->c_c_index, format_tcp_state, state,
+                     tc->c_c_index, format_tcp_state, tc->state,
                      format_tcp_flags, (int) flags);
     }
 }