summaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session.h
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2021-05-07 19:39:43 -0700
committerFlorin Coras <florin.coras@gmail.com>2021-05-10 20:53:32 +0000
commitea72764204dac0a1ab6412bc27b758faead2ca10 (patch)
treed22e849e0e0a84b11c42373c1b97fb6b715d3098 /src/vnet/session/session.h
parente2272ac27c31b8cf7ecf0ff8d4244f90034a09f4 (diff)
session: use half-open sessions for vc establishment
Use half-open sessions to track virtual circuit connection establishment. These sesssions can only be allocated and freed by the thread that allocates half-open connections (main). Consequently, they can only be freed on half-open cleanup notifications from transports. Goal is to simplify state tracking within the session layer but it's also a first step towards allowing builtin apps to track and cleanup outstanding connects. Type: improvement Signed-off-by: Florin Coras <fcoras@cisco.com> Change-Id: I8a535906d13eb7f8966deb82333839de80f8049f
Diffstat (limited to 'src/vnet/session/session.h')
-rw-r--r--src/vnet/session/session.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 8b591339edb..1a59d7df403 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -331,8 +331,7 @@ int session_wrk_handle_mq (session_worker_t *wrk, svm_msg_q_t *mq);
session_t *session_alloc (u32 thread_index);
void session_free (session_t * s);
void session_free_w_fifos (session_t * s);
-void session_cleanup_half_open (transport_proto_t tp,
- session_handle_t ho_handle);
+void session_cleanup_half_open (session_handle_t ho_handle);
u8 session_is_valid (u32 si, u8 thread_index);
always_inline session_t *
@@ -504,8 +503,7 @@ int session_dgram_connect_notify (transport_connection_t * tc,
int session_stream_accept_notify (transport_connection_t * tc);
void session_transport_closing_notify (transport_connection_t * tc);
void session_transport_delete_notify (transport_connection_t * tc);
-void session_half_open_delete_notify (transport_proto_t tp,
- session_handle_t ho_handle);
+void session_half_open_delete_notify (transport_connection_t *tc);
void session_transport_closed_notify (transport_connection_t * tc);
void session_transport_reset_notify (transport_connection_t * tc);
int session_stream_accept (transport_connection_t * tc, u32 listener_index,
@@ -656,6 +654,30 @@ listen_session_free (session_t * s)
session_free (s);
}
+always_inline session_t *
+ho_session_alloc (void)
+{
+ session_t *s;
+ ASSERT (vlib_get_thread_index () == 0);
+ s = session_alloc (0);
+ s->session_state = SESSION_STATE_CONNECTING;
+ s->flags |= SESSION_F_HALF_OPEN;
+ return s;
+}
+
+always_inline session_t *
+ho_session_get (u32 ho_index)
+{
+ return session_get (ho_index, 0 /* half-open thread */);
+}
+
+always_inline void
+ho_session_free (session_t *s)
+{
+ ASSERT (!s->rx_fifo && s->thread_index == 0);
+ session_free (s);
+}
+
transport_connection_t *listen_session_get_transport (session_t * s);
/*