tcp: fix handling of broken syn options 05/16505/2
authorFlorin Coras <fcoras@cisco.com>
Mon, 17 Dec 2018 04:57:29 +0000 (20:57 -0800)
committerFlorin Coras <florin.coras@gmail.com>
Mon, 17 Dec 2018 18:51:19 +0000 (18:51 +0000)
Change-Id: Ia8b2a077ba4897ddd15cf33221b191cd7a3f1d33
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h
src/vnet/tcp/tcp_input.c
src/vnet/tcp/tcp_output.c

index a3cd1f3..285ed62 100644 (file)
@@ -246,7 +246,7 @@ tcp_connection_del (tcp_connection_t * tc)
 }
 
 tcp_connection_t *
-tcp_connection_new (u8 thread_index)
+tcp_connection_alloc (u8 thread_index)
 {
   tcp_main_t *tm = vnet_get_tcp_main ();
   tcp_connection_t *tc;
@@ -258,6 +258,15 @@ tcp_connection_new (u8 thread_index)
   return tc;
 }
 
+void
+tcp_connection_free (tcp_connection_t * tc)
+{
+  tcp_main_t *tm = &tcp_main;
+  pool_put (tm->connections[tc->c_thread_index], tc);
+  if (CLIB_DEBUG > 0)
+    clib_memset (tc, 0xFA, sizeof (*tc));
+}
+
 /** Notify session that connection has been reset.
  *
  * Switch state to closed and wait for session to call cleanup.
index 46b03ac..a62e01d 100644 (file)
@@ -565,7 +565,8 @@ void tcp_connection_close (tcp_connection_t * tc);
 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_new (u8 thread_index);
+tcp_connection_t *tcp_connection_alloc (u8 thread_index);
+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,
                                           ip4_address_t * start,
index 4406d68..f0ae8b1 100644 (file)
@@ -3097,7 +3097,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 +3119,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;
        }
 
index 113fb14..fc4bceb 100644 (file)
@@ -447,7 +447,6 @@ tcp_init_mss (tcp_connection_t * tc)
 
   if (tc->snd_mss < 45)
     {
-      clib_warning ("snd mss is 0");
       /* Assume that at least the min default mss works */
       tc->snd_mss = default_min_mss;
       tc->rcv_opts.mss = default_min_mss;