session udp: fix transport flags and migration
[vpp.git] / src / vnet / session / session_node.c
index b5f4321..0290fe6 100644 (file)
@@ -50,6 +50,8 @@ session_mq_listen_handler (void *data)
   clib_memset (a, 0, sizeof (*a));
   a->sep.is_ip4 = mp->is_ip4;
   clib_memcpy_fast (&a->sep.ip, &mp->ip, sizeof (mp->ip));
+  if (mp->is_ip4)
+    ip46_address_mask_ip4 (&a->sep.ip);
   a->sep.port = mp->port;
   a->sep.fib_index = mp->vrf;
   a->sep.sw_if_index = ENDPOINT_INVALID_INDEX;
@@ -113,11 +115,17 @@ session_mq_connect_handler (void *data)
   a->sep.transport_proto = mp->proto;
   a->sep.peer.fib_index = mp->vrf;
   clib_memcpy_fast (&a->sep.peer.ip, &mp->lcl_ip, sizeof (mp->lcl_ip));
+  if (mp->is_ip4)
+    {
+      ip46_address_mask_ip4 (&a->sep.ip);
+      ip46_address_mask_ip4 (&a->sep.peer.ip);
+    }
+  a->sep.peer.port = mp->lcl_port;
   a->sep.peer.sw_if_index = ENDPOINT_INVALID_INDEX;
   a->sep_ext.parent_handle = mp->parent_handle;
   a->sep_ext.ckpair_index = mp->ckpair_index;
   a->sep_ext.crypto_engine = mp->crypto_engine;
-  a->sep_ext.flags = mp->flags;
+  a->sep_ext.transport_flags = mp->flags;
   if (mp->hostname_len)
     {
       vec_validate (a->sep_ext.hostname, mp->hostname_len - 1);
@@ -1563,33 +1571,40 @@ session_queue_exit (vlib_main_t * vm)
 
 VLIB_MAIN_LOOP_EXIT_FUNCTION (session_queue_exit);
 
+static uword
+session_queue_run_on_main (vlib_main_t * vm)
+{
+  vlib_node_runtime_t *node;
+
+  node = vlib_node_get_runtime (vm, session_queue_node.index);
+  return session_queue_node_fn (vm, node, 0);
+}
+
 static uword
 session_queue_process (vlib_main_t * vm, vlib_node_runtime_t * rt,
                       vlib_frame_t * f)
 {
-  f64 now, timeout = 1.0;
   uword *event_data = 0;
+  f64 timeout = 1.0;
   uword event_type;
 
   while (1)
     {
       vlib_process_wait_for_event_or_clock (vm, timeout);
-      now = vlib_time_now (vm);
       event_type = vlib_process_get_events (vm, (uword **) & event_data);
 
       switch (event_type)
        {
-       case SESSION_Q_PROCESS_FLUSH_FRAMES:
-         /* Flush the frames by updating all transports times */
-         transport_update_time (now, 0);
+       case SESSION_Q_PROCESS_RUN_ON_MAIN:
+         /* Run session queue node on main thread */
+         session_queue_run_on_main (vm);
          break;
        case SESSION_Q_PROCESS_STOP:
          timeout = 100000.0;
          break;
        case ~0:
-         /* Timed out. Update time for all transports to trigger all
-          * outstanding retransmits. */
-         transport_update_time (now, 0);
+         /* Timed out. Run on main to ensure all events are handled */
+         session_queue_run_on_main (vm);
          break;
        }
       vec_reset_length (event_data);