summaryrefslogtreecommitdiffstats
path: root/src/vcl/vcl_private.h
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2019-05-16 14:38:44 +0200
committerFlorin Coras <florin.coras@gmail.com>2019-07-18 18:19:05 +0000
commit9fd996275c745faec2843cf3a8b1d15d6f8c9dab (patch)
tree01bd59cd9deea4994a33bce8bb4a2a7d7fa5c283 /src/vcl/vcl_private.h
parentcef02be220eff4aa32ec7ff56b1e0a552faa1280 (diff)
vcl: add QUIC support
Type: feature * Adds the concept of a "connectable listener" : a session that can be both connected and accepted on. * vppcom_session_is_connectable_listener (fd) that tells if the fd is a connectable listener * vppcom_session_listener (fd) that gives you the listener's fd that accepted the session (if any) * vppcom_session_n_accepted (fd) that gives the number of sessions a listener accepted. Change-Id: Id89d67d8339fb15a7cf7e00a9c5448175eca04fc Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
Diffstat (limited to 'src/vcl/vcl_private.h')
-rw-r--r--src/vcl/vcl_private.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/vcl/vcl_private.h b/src/vcl/vcl_private.h
index 544b2880fe1..d46208cd035 100644
--- a/src/vcl/vcl_private.h
+++ b/src/vcl/vcl_private.h
@@ -167,6 +167,10 @@ typedef struct
/* Socket configuration state */
u8 is_vep;
u8 is_vep_session;
+ /* VCL session index of the listening session (if any) */
+ u32 listener_index;
+ /* Accepted sessions on this listener */
+ int n_accepted_sessions;
u8 has_rx_evt;
u32 attr;
u64 transport_opts;
@@ -352,6 +356,7 @@ vcl_session_alloc (vcl_worker_t * wrk)
pool_get (wrk->sessions, s);
memset (s, 0, sizeof (*s));
s->session_index = s - wrk->sessions;
+ s->listener_index = VCL_INVALID_SESSION_INDEX;
return s;
}
@@ -447,6 +452,26 @@ vcl_session_table_del_listener (vcl_worker_t * wrk, u64 listener_handle)
hash_unset (wrk->session_index_by_vpp_handles, listener_handle);
}
+static inline int
+vcl_session_is_connectable_listener (vcl_worker_t * wrk,
+ vcl_session_t * session)
+{
+ /* Tell if we session_handle is a QUIC session.
+ * We can be in the following cases :
+ * Listen session <- QUIC session <- Stream session
+ * QUIC session <- Stream session
+ */
+ vcl_session_t *ls;
+ if (session->session_type != VPPCOM_PROTO_QUIC)
+ return 0;
+ if (session->listener_index == VCL_INVALID_SESSION_INDEX)
+ return !(session->session_state & STATE_LISTEN);
+ ls = vcl_session_get_w_handle (wrk, session->listener_index);
+ if (!ls)
+ return VPPCOM_EBADFD;
+ return ls->session_state & STATE_LISTEN;
+}
+
static inline vcl_session_t *
vcl_session_table_lookup_listener (vcl_worker_t * wrk, u64 handle)
{
@@ -467,7 +492,8 @@ vcl_session_table_lookup_listener (vcl_worker_t * wrk, u64 handle)
return 0;
}
- ASSERT (session->session_state & (STATE_LISTEN | STATE_LISTEN_NO_MQ));
+ ASSERT ((session->session_state & (STATE_LISTEN | STATE_LISTEN_NO_MQ)) ||
+ vcl_session_is_connectable_listener (wrk, session));
return session;
}