papi: Use CMSG_SPACE for sizing ancillary buffer space
[vpp.git] / src / vnet / session / session.c
index 67652b5..e2fd164 100644 (file)
@@ -209,7 +209,7 @@ session_alloc (u32 thread_index)
   clib_memset (s, 0, sizeof (*s));
   s->session_index = s - wrk->sessions;
   s->thread_index = thread_index;
-  s->app_index = APP_INVALID_INDEX;
+  s->al_index = APP_INVALID_INDEX;
 
   return s;
 }
@@ -318,7 +318,7 @@ session_cleanup_half_open (session_handle_t ho_handle)
        }
       /* Migrated transports are no longer half-opens */
       transport_cleanup (session_get_transport_proto (ho),
-                        ho->connection_index, ho->app_index /* overloaded */);
+                        ho->connection_index, ho->al_index /* overloaded */);
     }
   else if (ho->session_state != SESSION_STATE_TRANSPORT_DELETED)
     {
@@ -410,8 +410,8 @@ session_half_open_migrated_notify (transport_connection_t *tc)
       return -1;
     }
   ho->connection_index = tc->c_index;
-  /* Overload app index for half-open with new thread */
-  ho->app_index = tc->thread_index;
+  /* Overload al_index for half-open with new thread */
+  ho->al_index = tc->thread_index;
   return 0;
 }
 
@@ -705,7 +705,7 @@ session_main_flush_enqueue_events (transport_proto_t transport_proto,
   session_worker_t *wrk = session_main_get_worker (thread_index);
   session_handle_t *handles;
   session_t *s;
-  u32 i;
+  u32 i, is_cl;
 
   handles = wrk->session_to_enqueue[transport_proto];
 
@@ -714,8 +714,12 @@ session_main_flush_enqueue_events (transport_proto_t transport_proto,
       s = session_get_from_handle (handles[i]);
       session_fifo_tuning (s, s->rx_fifo, SESSION_FT_ACTION_ENQUEUED,
                           0 /* TODO/not needed */);
-      session_enqueue_notify_inline (s,
-                                    s->thread_index != thread_index ? 1 : 0);
+      is_cl =
+       s->thread_index != thread_index || (s->flags & SESSION_F_IS_CLESS);
+      if (!is_cl)
+       session_enqueue_notify_inline (s, 0);
+      else
+       session_enqueue_notify_inline (s, 1);
     }
 
   vec_reset_length (handles);
@@ -862,12 +866,23 @@ session_enqueue_dgram_connection (session_t *s, session_dgram_hdr_t *hdr,
                                                  queue_event, 0 /* is_cl */);
 }
 
+int
+session_enqueue_dgram_connection2 (session_t *s, session_dgram_hdr_t *hdr,
+                                  vlib_buffer_t *b, u8 proto, u8 queue_event)
+{
+  return session_enqueue_dgram_connection_inline (s, hdr, b, proto,
+                                                 queue_event, 1 /* is_cl */);
+}
+
 int
 session_enqueue_dgram_connection_cl (session_t *s, session_dgram_hdr_t *hdr,
                                     vlib_buffer_t *b, u8 proto,
                                     u8 queue_event)
 {
-  return session_enqueue_dgram_connection_inline (s, hdr, b, proto,
+  session_t *awls;
+
+  awls = app_listener_select_wrk_cl_session (s, hdr);
+  return session_enqueue_dgram_connection_inline (awls, hdr, b, proto,
                                                  queue_event, 1 /* is_cl */);
 }
 
@@ -1180,6 +1195,9 @@ session_transport_closed_notify (transport_connection_t * tc)
   if (!(s = session_get_if_valid (tc->s_index, tc->thread_index)))
     return;
 
+  if (s->session_state >= SESSION_STATE_TRANSPORT_CLOSED)
+    return;
+
   /* Transport thinks that app requested close but it actually didn't.
    * Can happen for tcp:
    * 1)if fin and rst are received in close succession.
@@ -1345,6 +1363,8 @@ session_open_cl (session_endpoint_cfg_t *rmt, session_handle_t *rsh)
   s->app_wrk_index = app_wrk->wrk_index;
   s->opaque = rmt->opaque;
   session_set_state (s, SESSION_STATE_OPENED);
+  if (transport_connection_is_cless (tc))
+    s->flags |= SESSION_F_IS_CLESS;
   if (app_worker_init_connected (app_wrk, s))
     {
       session_free (s);
@@ -1412,13 +1432,11 @@ session_open_app (session_endpoint_cfg_t *rmt, session_handle_t *rsh)
 typedef int (*session_open_service_fn) (session_endpoint_cfg_t *,
                                        session_handle_t *);
 
-/* *INDENT-OFF* */
 static session_open_service_fn session_open_srv_fns[TRANSPORT_N_SERVICES] = {
   session_open_vc,
   session_open_cl,
   session_open_app,
 };
-/* *INDENT-ON* */
 
 /**
  * Ask transport to open connection to remote transport endpoint.
@@ -1470,6 +1488,8 @@ session_listen (session_t * ls, session_endpoint_cfg_t * sep)
   ls = listen_session_get (s_index);
   ls->connection_index = tc_index;
   ls->opaque = sep->opaque;
+  if (transport_connection_is_cless (session_get_transport (ls)))
+    ls->flags |= SESSION_F_IS_CLESS;
 
   return 0;
 }
@@ -1749,14 +1769,12 @@ session_get_original_dst (transport_endpoint_t *i2o_src,
                            original_dst_port);
 }
 
-/* *INDENT-OFF* */
 static session_fifo_rx_fn *session_tx_fns[TRANSPORT_TX_N_FNS] = {
     session_tx_fifo_peek_and_snd,
     session_tx_fifo_dequeue_and_snd,
     session_tx_fifo_dequeue_internal,
     session_tx_fifo_dequeue_and_snd
 };
-/* *INDENT-ON* */
 
 void
 session_register_transport (transport_proto_t transport_proto,