summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-02-03 15:26:14 -0800
committerDave Barach <openvpp@barachs.net>2019-02-04 22:00:54 +0000
commit288eaab5964b9211350acad8d742fae4789577fe (patch)
treebdc12155958c6fedf4e976791529fc8a6590d70e /src/plugins
parent8d991d923b52a2692370bfa33902d29ff5d2f826 (diff)
session: cleanup part 1
Rename core data structures. This will break compatibility for out of tree builtin apps. - stream_session_t to session_t - server_rx/tx_fifo to rx/tx_fifo - stream_session.h to session_types.h - update copyright Change-Id: I414097c6e28bcbea866fbf13b8773c7db3f49325 Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/tlsmbedtls/tls_mbedtls.c33
-rw-r--r--src/plugins/tlsopenssl/tls_async.c2
-rw-r--r--src/plugins/tlsopenssl/tls_openssl.c36
-rw-r--r--src/plugins/tlsopenssl/tls_openssl.h3
-rw-r--r--src/plugins/unittest/session_test.c18
-rw-r--r--src/plugins/unittest/tcp_test.c2
6 files changed, 45 insertions, 49 deletions
diff --git a/src/plugins/tlsmbedtls/tls_mbedtls.c b/src/plugins/tlsmbedtls/tls_mbedtls.c
index 52d124eb84e..93beebe418c 100644
--- a/src/plugins/tlsmbedtls/tls_mbedtls.c
+++ b/src/plugins/tlsmbedtls/tls_mbedtls.c
@@ -158,7 +158,7 @@ tls_get_ctr_drbg ()
static int
tls_net_send (void *ctx_indexp, const unsigned char *buf, size_t len)
{
- stream_session_t *tls_session;
+ session_t *tls_session;
uword ctx_index;
tls_ctx_t *ctx;
int rv;
@@ -166,7 +166,7 @@ tls_net_send (void *ctx_indexp, const unsigned char *buf, size_t len)
ctx_index = pointer_to_uword (ctx_indexp);
ctx = mbedtls_ctx_get (ctx_index);
tls_session = session_get_from_handle (ctx->tls_session_handle);
- rv = svm_fifo_enqueue_nowait (tls_session->server_tx_fifo, len, buf);
+ rv = svm_fifo_enqueue_nowait (tls_session->tx_fifo, len, buf);
if (rv < 0)
return MBEDTLS_ERR_SSL_WANT_WRITE;
tls_add_vpp_q_tx_evt (tls_session);
@@ -176,7 +176,7 @@ tls_net_send (void *ctx_indexp, const unsigned char *buf, size_t len)
static int
tls_net_recv (void *ctx_indexp, unsigned char *buf, size_t len)
{
- stream_session_t *tls_session;
+ session_t *tls_session;
uword ctx_index;
tls_ctx_t *ctx;
int rv;
@@ -184,7 +184,7 @@ tls_net_recv (void *ctx_indexp, unsigned char *buf, size_t len)
ctx_index = pointer_to_uword (ctx_indexp);
ctx = mbedtls_ctx_get (ctx_index);
tls_session = session_get_from_handle (ctx->tls_session_handle);
- rv = svm_fifo_dequeue_nowait (tls_session->server_rx_fifo, len, buf);
+ rv = svm_fifo_dequeue_nowait (tls_session->rx_fifo, len, buf);
return (rv < 0) ? 0 : rv;
}
@@ -427,23 +427,23 @@ mbedtls_ctx_handshake_rx (tls_ctx_t * ctx)
}
static int
-mbedtls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
+mbedtls_ctx_write (tls_ctx_t * ctx, session_t * app_session)
{
mbedtls_ctx_t *mc = (mbedtls_ctx_t *) ctx;
u8 thread_index = ctx->c_thread_index;
mbedtls_main_t *mm = &mbedtls_main;
u32 enq_max, deq_max, deq_now;
- stream_session_t *tls_session;
+ session_t *tls_session;
int wrote;
ASSERT (mc->ssl.state == MBEDTLS_SSL_HANDSHAKE_OVER);
- deq_max = svm_fifo_max_dequeue (app_session->server_tx_fifo);
+ deq_max = svm_fifo_max_dequeue (app_session->tx_fifo);
if (!deq_max)
return 0;
tls_session = session_get_from_handle (ctx->tls_session_handle);
- enq_max = svm_fifo_max_enqueue (tls_session->server_tx_fifo);
+ enq_max = svm_fifo_max_enqueue (tls_session->tx_fifo);
deq_now = clib_min (deq_max, TLS_CHUNK_SIZE);
if (PREDICT_FALSE (enq_max == 0))
@@ -453,8 +453,7 @@ mbedtls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
}
vec_validate (mm->tx_bufs[thread_index], deq_now);
- svm_fifo_peek (app_session->server_tx_fifo, 0, deq_now,
- mm->tx_bufs[thread_index]);
+ svm_fifo_peek (app_session->tx_fifo, 0, deq_now, mm->tx_bufs[thread_index]);
wrote = mbedtls_ssl_write (&mc->ssl, mm->tx_bufs[thread_index], deq_now);
if (wrote <= 0)
@@ -463,7 +462,7 @@ mbedtls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
return 0;
}
- svm_fifo_dequeue_drop (app_session->server_tx_fifo, wrote);
+ svm_fifo_dequeue_drop (app_session->tx_fifo, wrote);
vec_reset_length (mm->tx_bufs[thread_index]);
tls_add_vpp_q_tx_evt (tls_session);
@@ -474,13 +473,13 @@ mbedtls_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
}
static int
-mbedtls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
+mbedtls_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
{
mbedtls_ctx_t *mc = (mbedtls_ctx_t *) ctx;
mbedtls_main_t *mm = &mbedtls_main;
u8 thread_index = ctx->c_thread_index;
u32 deq_max, enq_max, enq_now;
- stream_session_t *app_session;
+ session_t *app_session;
int read, enq;
if (PREDICT_FALSE (mc->ssl.state != MBEDTLS_SSL_HANDSHAKE_OVER))
@@ -489,12 +488,12 @@ mbedtls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
return 0;
}
- deq_max = svm_fifo_max_dequeue (tls_session->server_rx_fifo);
+ deq_max = svm_fifo_max_dequeue (tls_session->rx_fifo);
if (!deq_max)
return 0;
app_session = session_get_from_handle (ctx->app_session_handle);
- enq_max = svm_fifo_max_enqueue (app_session->server_rx_fifo);
+ enq_max = svm_fifo_max_enqueue (app_session->rx_fifo);
enq_now = clib_min (enq_max, TLS_CHUNK_SIZE);
if (PREDICT_FALSE (enq_now == 0))
@@ -511,12 +510,12 @@ mbedtls_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
return 0;
}
- enq = svm_fifo_enqueue_nowait (app_session->server_rx_fifo, read,
+ enq = svm_fifo_enqueue_nowait (app_session->rx_fifo, read,
mm->rx_bufs[thread_index]);
ASSERT (enq == read);
vec_reset_length (mm->rx_bufs[thread_index]);
- if (svm_fifo_max_dequeue (tls_session->server_rx_fifo))
+ if (svm_fifo_max_dequeue (tls_session->rx_fifo))
tls_add_vpp_q_builtin_rx_evt (tls_session);
if (enq > 0)
diff --git a/src/plugins/tlsopenssl/tls_async.c b/src/plugins/tlsopenssl/tls_async.c
index facb94ec253..ade073c66bc 100644
--- a/src/plugins/tlsopenssl/tls_async.c
+++ b/src/plugins/tlsopenssl/tls_async.c
@@ -342,7 +342,7 @@ event_handler (void *tls_async)
openssl_resume_handler *handler;
openssl_evt_t *callback;
- stream_session_t *tls_session;
+ session_t *tls_session;
int thread_index;
tls_ctx_t *ctx;
diff --git a/src/plugins/tlsopenssl/tls_openssl.c b/src/plugins/tlsopenssl/tls_openssl.c
index 9585e3f828b..0a25ecfa943 100644
--- a/src/plugins/tlsopenssl/tls_openssl.c
+++ b/src/plugins/tlsopenssl/tls_openssl.c
@@ -105,14 +105,13 @@ openssl_lctx_get (u32 lctx_index)
}
static int
-openssl_try_handshake_read (openssl_ctx_t * oc,
- stream_session_t * tls_session)
+openssl_try_handshake_read (openssl_ctx_t * oc, session_t * tls_session)
{
u32 deq_max, deq_now;
svm_fifo_t *f;
int wrote, rv;
- f = tls_session->server_rx_fifo;
+ f = tls_session->rx_fifo;
deq_max = svm_fifo_max_dequeue (f);
if (!deq_max)
return 0;
@@ -137,8 +136,7 @@ openssl_try_handshake_read (openssl_ctx_t * oc,
}
static int
-openssl_try_handshake_write (openssl_ctx_t * oc,
- stream_session_t * tls_session)
+openssl_try_handshake_write (openssl_ctx_t * oc, session_t * tls_session)
{
u32 enq_max, deq_now;
svm_fifo_t *f;
@@ -147,7 +145,7 @@ openssl_try_handshake_write (openssl_ctx_t * oc,
if (BIO_ctrl_pending (oc->rbio) <= 0)
return 0;
- f = tls_session->server_tx_fifo;
+ f = tls_session->tx_fifo;
enq_max = svm_fifo_max_enqueue (f);
if (!enq_max)
return 0;
@@ -207,7 +205,7 @@ vpp_ssl_async_retry_func (tls_ctx_t * ctx, openssl_resume_handler * handler)
#endif
int
-openssl_ctx_handshake_rx (tls_ctx_t * ctx, stream_session_t * tls_session)
+openssl_ctx_handshake_rx (tls_ctx_t * ctx, session_t * tls_session)
{
openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
int rv = 0, err;
@@ -299,15 +297,15 @@ openssl_ctx_handshake_rx (tls_ctx_t * ctx, stream_session_t * tls_session)
}
static inline int
-openssl_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
+openssl_ctx_write (tls_ctx_t * ctx, session_t * app_session)
{
openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
int wrote = 0, rv, read, max_buf = 100 * TLS_CHUNK_SIZE, max_space;
u32 enq_max, deq_max, deq_now, to_write;
- stream_session_t *tls_session;
+ session_t *tls_session;
svm_fifo_t *f;
- f = app_session->server_tx_fifo;
+ f = app_session->tx_fifo;
deq_max = svm_fifo_max_dequeue (f);
if (!deq_max)
goto check_tls_fifo;
@@ -322,14 +320,14 @@ openssl_ctx_write (tls_ctx_t * ctx, stream_session_t * app_session)
tls_add_vpp_q_builtin_tx_evt (app_session);
goto check_tls_fifo;
}
- svm_fifo_dequeue_drop (app_session->server_tx_fifo, wrote);
+ svm_fifo_dequeue_drop (app_session->tx_fifo, wrote);
if (wrote < deq_now)
{
to_write = clib_min (svm_fifo_max_read_chunk (f), deq_now - wrote);
rv = SSL_write (oc->ssl, svm_fifo_head (f), to_write);
if (rv > 0)
{
- svm_fifo_dequeue_drop (app_session->server_tx_fifo, rv);
+ svm_fifo_dequeue_drop (app_session->tx_fifo, rv);
wrote += rv;
}
}
@@ -343,7 +341,7 @@ check_tls_fifo:
return wrote;
tls_session = session_get_from_handle (ctx->tls_session_handle);
- f = tls_session->server_tx_fifo;
+ f = tls_session->tx_fifo;
enq_max = svm_fifo_max_enqueue (f);
if (!enq_max)
{
@@ -377,12 +375,12 @@ check_tls_fifo:
}
static inline int
-openssl_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
+openssl_ctx_read (tls_ctx_t * ctx, session_t * tls_session)
{
int read, wrote = 0, max_space, max_buf = 100 * TLS_CHUNK_SIZE, rv;
openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
u32 deq_max, enq_max, deq_now, to_read;
- stream_session_t *app_session;
+ session_t *app_session;
svm_fifo_t *f;
if (PREDICT_FALSE (SSL_in_init (oc->ssl)))
@@ -391,7 +389,7 @@ openssl_ctx_read (tls_ctx_t * ctx, stream_session_t * tls_session)
return 0;
}
- f = tls_session->server_rx_fifo;
+ f = tls_session->rx_fifo;
deq_max = svm_fifo_max_dequeue (f);
max_space = max_buf - BIO_ctrl_pending (oc->wbio);
max_space = max_space < 0 ? 0 : max_space;
@@ -426,7 +424,7 @@ check_app_fifo:
return wrote;
app_session = session_get_from_handle (ctx->app_session_handle);
- f = app_session->server_rx_fifo;
+ f = app_session->rx_fifo;
enq_max = svm_fifo_max_enqueue (f);
if (!enq_max)
{
@@ -463,7 +461,7 @@ openssl_ctx_init_client (tls_ctx_t * ctx)
long flags = SSL_OP_NO_SSLv2 | SSL_OP_NO_SSLv3 | SSL_OP_NO_COMPRESSION;
openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
openssl_main_t *om = &openssl_main;
- stream_session_t *tls_session;
+ session_t *tls_session;
const SSL_METHOD *method;
int rv, err;
#ifdef HAVE_OPENSSL_ASYNC
@@ -662,7 +660,7 @@ openssl_ctx_init_server (tls_ctx_t * ctx)
openssl_ctx_t *oc = (openssl_ctx_t *) ctx;
u32 olc_index = ctx->tls_ssl_ctx;
openssl_listen_ctx_t *olc;
- stream_session_t *tls_session;
+ session_t *tls_session;
int rv, err;
#ifdef HAVE_OPENSSL_ASYNC
openssl_resume_handler *handler;
diff --git a/src/plugins/tlsopenssl/tls_openssl.h b/src/plugins/tlsopenssl/tls_openssl.h
index 712b4cac628..66e0b364cba 100644
--- a/src/plugins/tlsopenssl/tls_openssl.h
+++ b/src/plugins/tlsopenssl/tls_openssl.h
@@ -57,8 +57,7 @@ typedef struct openssl_tls_callback_
void *arg;
} openssl_tls_callback_t;
-typedef int openssl_resume_handler (tls_ctx_t * ctx,
- stream_session_t * tls_session);
+typedef int openssl_resume_handler (tls_ctx_t * ctx, session_t * tls_session);
tls_ctx_t *openssl_ctx_get_w_thread (u32 ctx_index, u8 thread_index);
openssl_tls_callback_t *vpp_add_async_pending_event (tls_ctx_t * ctx,
diff --git a/src/plugins/unittest/session_test.c b/src/plugins/unittest/session_test.c
index cc273321d32..1689709728e 100644
--- a/src/plugins/unittest/session_test.c
+++ b/src/plugins/unittest/session_test.c
@@ -41,7 +41,7 @@
}
void
-dummy_session_reset_callback (stream_session_t * s)
+dummy_session_reset_callback (session_t * s)
{
clib_warning ("called...");
}
@@ -50,7 +50,7 @@ volatile u32 connected_session_index = ~0;
volatile u32 connected_session_thread = ~0;
int
dummy_session_connected_callback (u32 app_index, u32 api_context,
- stream_session_t * s, u8 is_fail)
+ session_t * s, u8 is_fail)
{
if (s)
{
@@ -77,7 +77,7 @@ dummy_del_segment_callback (u32 client_index, u64 segment_handle)
}
void
-dummy_session_disconnect_callback (stream_session_t * s)
+dummy_session_disconnect_callback (session_t * s)
{
clib_warning ("called...");
}
@@ -87,7 +87,7 @@ volatile u32 accepted_session_index;
volatile u32 accepted_session_thread;
int
-dummy_session_accept_callback (stream_session_t * s)
+dummy_session_accept_callback (session_t * s)
{
dummy_accept = 1;
accepted_session_index = s->session_index;
@@ -97,7 +97,7 @@ dummy_session_accept_callback (stream_session_t * s)
}
int
-dummy_server_rx_callback (stream_session_t * s)
+dummy_server_rx_callback (session_t * s)
{
clib_warning ("called...");
return -1;
@@ -276,7 +276,7 @@ session_test_endpoint_cfg (vlib_main_t * vm, unformat_input_t * input)
session_endpoint_t server_sep = SESSION_ENDPOINT_NULL;
ip4_address_t intf_addr[3];
transport_connection_t *tc;
- stream_session_t *s;
+ session_t *s;
clib_error_t *error;
u8 *appns_id;
@@ -428,7 +428,7 @@ session_test_namespace (vlib_main_t * vm, unformat_input_t * input)
u8 *ns_id = format (0, "appns1");
app_namespace_t *app_ns;
application_t *server;
- stream_session_t *s;
+ session_t *s;
u64 handle;
int code;
@@ -1025,7 +1025,7 @@ session_test_rules (vlib_main_t * vm, unformat_input_t * input)
u32 dummy_port = 1111;
clib_error_t *error = 0;
u8 is_filtered = 0, *ns_id = format (0, "appns1");
- stream_session_t *listener, *s;
+ session_t *listener, *s;
app_namespace_t *default_ns = app_namespace_get_default ();
u32 local_ns_index = default_ns->local_table_index;
int verbose = 0, rv;
@@ -1589,7 +1589,7 @@ session_test_proxy (vlib_main_t * vm, unformat_input_t * input)
u32 dummy_server_api_index = ~0, sw_if_index = 0;
clib_error_t *error = 0;
u8 is_filtered = 0;
- stream_session_t *s;
+ session_t *s;
transport_connection_t *tc;
u16 lcl_port = 1234, rmt_port = 4321;
app_namespace_t *app_ns;
diff --git a/src/plugins/unittest/tcp_test.c b/src/plugins/unittest/tcp_test.c
index 66260df2ff6..5905dc2adab 100644
--- a/src/plugins/unittest/tcp_test.c
+++ b/src/plugins/unittest/tcp_test.c
@@ -1639,7 +1639,7 @@ tcp_test_lookup (vlib_main_t * vm, unformat_input_t * input)
tcp_main_t *tm = &tcp_main;
transport_connection_t _tc1, *tc1 = &_tc1, _tc2, *tc2 = &_tc2, *tconn;
tcp_connection_t *tc;
- stream_session_t *s, *s1;
+ session_t *s, *s1;
u8 cmp = 0, is_filtered = 0;
u32 sidx;