From ea72764204dac0a1ab6412bc27b758faead2ca10 Mon Sep 17 00:00:00 2001 From: Florin Coras Date: Fri, 7 May 2021 19:39:43 -0700 Subject: 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 Change-Id: I8a535906d13eb7f8966deb82333839de80f8049f --- src/vnet/session/session.h | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) (limited to 'src/vnet/session/session.h') 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); /* -- cgit 1.2.3-korg