session: add half_open_has_fifos for UDPC 58/20358/5
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>
Wed, 26 Jun 2019 11:53:08 +0000 (13:53 +0200)
committerFlorin Coras <florin.coras@gmail.com>
Fri, 28 Jun 2019 16:56:15 +0000 (16:56 +0000)
Type: fix

Change-Id: Iede83a4e72b88fd55bf56ec0ca71c9196ce743cd
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
src/vnet/session/session.c
src/vnet/session/transport.c
src/vnet/session/transport.h
src/vnet/session/transport_types.h
src/vnet/udp/udp.c

index 0e5fb8e..3a6d7e2 100644 (file)
@@ -601,8 +601,9 @@ session_main_flush_all_enqueue_events (u8 transport_proto)
   return errors;
 }
 
-int
-session_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
+static inline int
+session_stream_connect_notify_inline (transport_connection_t * tc, u8 is_fail,
+                                     session_state_t opened_state)
 {
   u32 opaque = 0, new_ti, new_si;
   app_worker_t *app_wrk;
@@ -645,6 +646,10 @@ session_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
       return -1;
     }
 
+  s = session_get (new_si, new_ti);
+  s->session_state = opened_state;
+  session_lookup_add_connection (tc, session_handle (s));
+
   if (app_worker_connect_notify (app_wrk, s, opaque))
     {
       s = session_get (new_si, new_ti);
@@ -652,13 +657,23 @@ session_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
       return -1;
     }
 
-  s = session_get (new_si, new_ti);
-  s->session_state = SESSION_STATE_READY;
-  session_lookup_add_connection (tc, session_handle (s));
-
   return 0;
 }
 
+int
+session_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
+{
+  return session_stream_connect_notify_inline (tc, is_fail,
+                                              SESSION_STATE_READY);
+}
+
+int
+session_ho_stream_connect_notify (transport_connection_t * tc, u8 is_fail)
+{
+  return session_stream_connect_notify_inline (tc, is_fail,
+                                              SESSION_STATE_OPENED);
+}
+
 typedef struct _session_switch_pool_args
 {
   u32 session_index;
@@ -966,6 +981,8 @@ session_open_vc (u32 app_wrk_index, session_endpoint_t * rmt, u32 opaque)
    * thing but better than allocating a separate half-open pool.
    */
   tc->s_index = opaque;
+  if (transport_half_open_has_fifos (rmt->transport_proto))
+    return session_ho_stream_connect_notify (tc, 0 /* is_fail */ );
   return 0;
 }
 
index f971288..bb4c681 100644 (file)
@@ -288,6 +288,12 @@ transport_protocol_get_vft (transport_proto_t transport_proto)
   return &tp_vfts[transport_proto];
 }
 
+u8
+transport_half_open_has_fifos (transport_proto_t tp)
+{
+  return tp_vfts[tp].transport_options.half_open_has_fifos;
+}
+
 transport_service_type_t
 transport_protocol_service_type (transport_proto_t tp)
 {
index 978e3f0..6e2feb0 100644 (file)
@@ -23,6 +23,7 @@ typedef struct _transport_options_t
 {
   transport_tx_fn_type_t tx_type;
   transport_service_type_t service_type;
+  u8 half_open_has_fifos;
 } transport_options_t;
 
 /*
index e262dda..87daa76 100644 (file)
@@ -184,6 +184,7 @@ transport_endpoint_fib_proto (transport_endpoint_t * tep)
 }
 
 u8 transport_protocol_is_cl (transport_proto_t tp);
+u8 transport_half_open_has_fifos (transport_proto_t tp);
 transport_service_type_t transport_protocol_service_type (transport_proto_t);
 transport_tx_fn_type_t transport_protocol_tx_fn_type (transport_proto_t tp);
 
index d0c515a..1fb7a50 100644 (file)
@@ -393,6 +393,7 @@ static const transport_proto_vft_t udpc_proto = {
   .transport_options = {
     .tx_type = TRANSPORT_TX_DGRAM,
     .service_type = TRANSPORT_SERVICE_VC,
+    .half_open_has_fifos = 1
   },
 };
 /* *INDENT-ON* */