session: refactor local connects
[vpp.git] / src / vnet / session / session.c
index 606f717..36aadcb 100644 (file)
@@ -123,6 +123,13 @@ session_program_transport_close (session_t * s)
   session_manager_worker_t *wrk;
   session_event_t *evt;
 
+  if (!session_has_transport (s))
+    {
+      /* Polling may not be enabled on main thread so close now */
+      session_transport_close (s);
+      return;
+    }
+
   /* If we are in the handler thread, or being called with the worker barrier
    * held, just append a new event to pending disconnects vector. */
   if (vlib_thread_is_main_w_barrier () || thread_index == s->thread_index)
@@ -462,7 +469,7 @@ stream_session_peek_bytes (transport_connection_t * tc, u8 * buffer,
 }
 
 u32
-stream_session_dequeue_drop (transport_connection_t * tc, u32 max_bytes)
+session_dequeue_drop (transport_connection_t * tc, u32 max_bytes)
 {
   session_t *s = session_get (tc->s_index, tc->thread_index);
   return svm_fifo_dequeue_drop (s->tx_fifo, max_bytes);
@@ -1030,25 +1037,23 @@ session_open (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
 int
 session_listen (session_t * ls, session_endpoint_cfg_t * sep)
 {
-  transport_connection_t *tc;
   transport_endpoint_t *tep;
   u32 tc_index, s_index;
 
   /* Transport bind/listen */
   tep = session_endpoint_to_transport (sep);
   s_index = ls->session_index;
-  tc_index = transport_start_listen (sep->transport_proto, s_index, tep);
+  tc_index = transport_start_listen (session_get_transport_proto (ls),
+                                    s_index, tep);
 
   if (tc_index == (u32) ~ 0)
     return -1;
 
-  /* Attach transport to session */
+  /* Attach transport to session. Lookup tables are populated by the app
+   * worker because local tables (for ct sessions) are not backed by a fib */
   ls = listen_session_get (s_index);
   ls->connection_index = tc_index;
 
-  /* Add to the main lookup table after transport was initialized */
-  tc = transport_get_listener (sep->transport_proto, tc_index);
-  session_lookup_add_connection (tc, listen_session_get_handle (ls));
   return 0;
 }