tls: dtls initial implementation
[vpp.git] / src / vnet / session / session.c
index 9a4d29b..85a802c 100644 (file)
@@ -854,23 +854,12 @@ static void
 session_switch_pool_reply (void *arg)
 {
   u32 session_index = pointer_to_uword (arg);
-  segment_manager_t *sm;
-  app_worker_t *app_wrk;
   session_t *s;
 
   s = session_get_if_valid (session_index, vlib_get_thread_index ());
   if (!s)
     return;
 
-  app_wrk = app_worker_get_if_valid (s->app_wrk_index);
-  if (!app_wrk)
-    return;
-
-  /* Attach fifos to the right session and segment slice */
-  sm = app_worker_get_connect_segment_manager (app_wrk);
-  segment_manager_attach_fifo (sm, s->rx_fifo, s);
-  segment_manager_attach_fifo (sm, s->tx_fifo, s);
-
   /* Notify app that it has data on the new session */
   session_enqueue_notify (s);
 }
@@ -910,8 +899,8 @@ session_switch_pool (void *cb_args)
     {
       /* Cleanup fifo segment slice state for fifos */
       sm = app_worker_get_connect_segment_manager (app_wrk);
-      segment_manager_detach_fifo (sm, s->rx_fifo);
-      segment_manager_detach_fifo (sm, s->tx_fifo);
+      segment_manager_detach_fifo (sm, &s->rx_fifo);
+      segment_manager_detach_fifo (sm, &s->tx_fifo);
 
       /* Notify app, using old session, about the migration event */
       app_worker_migrate_notify (app_wrk, s, new_sh);
@@ -935,6 +924,8 @@ session_dgram_connect_notify (transport_connection_t * tc,
 {
   session_t *new_s;
   session_switch_pool_args_t *rpc_args;
+  segment_manager_t *sm;
+  app_worker_t *app_wrk;
 
   /*
    * Clone half-open session to the right thread.
@@ -944,7 +935,17 @@ session_dgram_connect_notify (transport_connection_t * tc,
   new_s->session_state = SESSION_STATE_READY;
   new_s->flags |= SESSION_F_IS_MIGRATING;
 
-  session_lookup_add_connection (tc, session_handle (new_s));
+  if (!(tc->flags & TRANSPORT_CONNECTION_F_NO_LOOKUP))
+    session_lookup_add_connection (tc, session_handle (new_s));
+
+  app_wrk = app_worker_get_if_valid (new_s->app_wrk_index);
+  if (app_wrk)
+    {
+      /* New set of fifos attached to the same shared memory */
+      sm = app_worker_get_connect_segment_manager (app_wrk);
+      segment_manager_attach_fifo (sm, &new_s->rx_fifo, new_s);
+      segment_manager_attach_fifo (sm, &new_s->tx_fifo, new_s);
+    }
 
   /*
    * Ask thread owning the old session to clean it up and make us the tx
@@ -1547,9 +1548,6 @@ session_vpp_event_queues_allocate (session_main_t * smm)
       cfg->ring_cfgs = rc;
 
       smm->wrk[i].vpp_event_queue = fifo_segment_msg_q_alloc (eqs, i, cfg);
-
-      if (svm_msg_q_alloc_consumer_eventfd (smm->wrk[i].vpp_event_queue))
-       clib_warning ("eventfd returned");
     }
 }
 
@@ -1670,11 +1668,9 @@ session_queue_run_on_main_thread (vlib_main_t * vm)
 static clib_error_t *
 session_manager_main_enable (vlib_main_t * vm)
 {
-  segment_manager_main_init_args_t _sm_args = { 0 }, *sm_args = &_sm_args;
   session_main_t *smm = &session_main;
   vlib_thread_main_t *vtm = vlib_get_thread_main ();
   u32 num_threads, preallocated_sessions_per_worker;
-  uword margin = 8 << 12;
   session_worker_t *wrk;
   int i;
 
@@ -1708,10 +1704,8 @@ session_manager_main_enable (vlib_main_t * vm)
   /* Allocate vpp event queues segment and queue */
   session_vpp_event_queues_allocate (smm);
 
-  /* Initialize fifo segment main baseva and timeout */
-  sm_args->baseva = smm->session_baseva + smm->evt_qs_segment_size + margin;
-  sm_args->size = smm->session_va_space_size;
-  segment_manager_main_init (sm_args);
+  /* Initialize segment manager properties */
+  segment_manager_main_init ();
 
   /* Preallocate sessions */
   if (smm->preallocated_sessions)
@@ -1831,7 +1825,7 @@ session_main_init (vlib_main_t * vm)
   smm->evt_qs_segment_size = 1 << 20;
 #endif
 
-  smm->last_transport_proto_type = TRANSPORT_PROTO_QUIC;
+  smm->last_transport_proto_type = TRANSPORT_PROTO_DTLS;
 
   return 0;
 }