tcp: cleanup connections if handshake fails
[vpp.git] / src / vnet / tcp / tcp_input.c
index 4406d68..91876fe 100644 (file)
@@ -2720,8 +2720,7 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
           */
          if (!tcp_rcv_ack_is_acceptable (tc0, b0))
            {
-             TCP_DBG ("connection not accepted");
-             tcp_send_reset_w_pkt (tc0, b0, is_ip4);
+             tcp_connection_reset (tc0);
              error0 = TCP_ERROR_ACK_INVALID;
              goto drop;
            }
@@ -2729,8 +2728,8 @@ tcp46_rcv_process_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
          /* Make sure the ack is exactly right */
          if (tc0->rcv_nxt != vnet_buffer (b0)->tcp.seq_number || is_fin0)
            {
+             tcp_connection_reset (tc0);
              error0 = TCP_ERROR_SEGMENT_INVALID;
-             tcp_send_reset_w_pkt (tc0, b0, is_ip4);
              goto drop;
            }
 
@@ -3097,7 +3096,7 @@ tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
        }
 
       /* Create child session and send SYN-ACK */
-      child0 = tcp_connection_new (my_thread_index);
+      child0 = tcp_connection_alloc (my_thread_index);
       child0->c_lcl_port = th0->dst_port;
       child0->c_rmt_port = th0->src_port;
       child0->c_is_ip4 = is_ip4;
@@ -3119,7 +3118,8 @@ tcp46_listen_inline (vlib_main_t * vm, vlib_node_runtime_t * node,
 
       if (tcp_options_parse (th0, &child0->rcv_opts, 1))
        {
-         clib_warning ("options parse fail");
+         error0 = TCP_ERROR_OPTIONS;
+         tcp_connection_free (child0);
          goto drop;
        }