Register TCP with IP only if session is enabled 59/5659/4
authorFlorin Coras <fcoras@cisco.com>
Tue, 7 Mar 2017 09:20:52 +0000 (01:20 -0800)
committerJohn Lo <loj@cisco.com>
Tue, 7 Mar 2017 21:40:24 +0000 (21:40 +0000)
Change-Id: I73154179e78aeae5f879125237bce593d0978fae
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/ip/ip4_forward.c
src/vnet/session/session.c
src/vnet/tcp/tcp.c
src/vnet/tcp/tcp.h

index 31b687d..5472428 100644 (file)
@@ -1706,10 +1706,11 @@ ip4_local_inline (vlib_main_t * vm,
                     ip1->dst_address.as_u32 != 0xFFFFFFFF)
                    ? IP4_ERROR_SRC_LOOKUP_MISS : error1);
 
+       skip_checks:
+
          next0 = lm->local_next_by_ip_protocol[proto0];
          next1 = lm->local_next_by_ip_protocol[proto1];
 
-       skip_checks:
          next0 =
            error0 != IP4_ERROR_UNKNOWN_PROTOCOL ? IP_LOCAL_NEXT_DROP : next0;
          next1 =
index 422527e..b5a168c 100644 (file)
@@ -22,6 +22,7 @@
 #include <vnet/dpo/load_balance.h>
 #include <vnet/fib/ip4_fib.h>
 #include <vnet/session/application.h>
+#include <vnet/tcp/tcp.h>
 
 /**
  * Per-type vector of transport protocol virtual function tables
@@ -1287,6 +1288,9 @@ session_manager_main_enable (vlib_main_t * vm)
 
   smm->is_enabled = 1;
 
+  /* Enable TCP transport */
+  vnet_tcp_enable_disable (vm, 1);
+
   return 0;
 }
 
@@ -1313,7 +1317,6 @@ vnet_session_enable_disable (vlib_main_t * vm, u8 is_en)
   return 0;
 }
 
-
 clib_error_t *
 session_manager_main_init (vlib_main_t * vm)
 {
index e5feaeb..69433e2 100644 (file)
@@ -633,18 +633,15 @@ tcp_initialize_timer_wheels (tcp_main_t * tm)
 }
 
 clib_error_t *
-tcp_init (vlib_main_t * vm)
+tcp_main_enable (vlib_main_t * vm)
 {
-  ip_main_t *im = &ip_main;
-  ip_protocol_info_t *pi;
   tcp_main_t *tm = vnet_get_tcp_main ();
+  ip_protocol_info_t *pi;
+  ip_main_t *im = &ip_main;
   vlib_thread_main_t *vtm = vlib_get_thread_main ();
   clib_error_t *error = 0;
   u32 num_threads;
 
-  tm->vlib_main = vm;
-  tm->vnet_main = vnet_get_main ();
-
   if ((error = vlib_call_init_function (vm, ip_main_init)))
     return error;
   if ((error = vlib_call_init_function (vm, ip4_lookup_init)))
@@ -697,6 +694,36 @@ tcp_init (vlib_main_t * vm)
   return error;
 }
 
+clib_error_t *
+vnet_tcp_enable_disable (vlib_main_t * vm, u8 is_en)
+{
+  if (is_en)
+    {
+      if (tcp_main.is_enabled)
+       return 0;
+
+      return tcp_main_enable (vm);
+    }
+  else
+    {
+      tcp_main.is_enabled = 0;
+    }
+
+  return 0;
+}
+
+clib_error_t *
+tcp_init (vlib_main_t * vm)
+{
+  tcp_main_t *tm = vnet_get_tcp_main ();
+
+  tm->vlib_main = vm;
+  tm->vnet_main = vnet_get_main ();
+  tm->is_enabled = 0;
+
+  return 0;
+}
+
 VLIB_INIT_FUNCTION (tcp_init);
 
 /*
index 3560509..7d44343 100644 (file)
@@ -304,6 +304,9 @@ typedef struct _tcp_main
   /* Congestion control algorithms registered */
   tcp_cc_algorithm_t *cc_algos;
 
+  /* Flag that indicates if stack is on or off */
+  u8 is_enabled;
+
   /* convenience */
   vlib_main_t *vlib_main;
   vnet_main_t *vnet_main;
@@ -323,6 +326,8 @@ vnet_get_tcp_main ()
   return &tcp_main;
 }
 
+clib_error_t *vnet_tcp_enable_disable (vlib_main_t * vm, u8 is_en);
+
 always_inline tcp_connection_t *
 tcp_connection_get (u32 conn_index, u32 thread_index)
 {