aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2017-08-07 09:35:25 -0400
committerDave Wallace <dwallacelf@gmail.com>2017-08-10 00:13:08 +0000
commit52851e6aa9304054fd1059c8dd284abf8e532bf2 (patch)
treeefe4334245044e342817b28d69ee208fba9952ec /src/vnet/session
parentb639b593372612fd3a55b3137b4fdd62df775d96 (diff)
TCP proxy prototype
- Clean up internal API client registration - Add proxy server - Add a reference count to the svm fifo Change-Id: I5ace1c85497062ed412d26ae76a9e6741af1e984 Signed-off-by: Dave Barach <dave@barachs.net> Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c6
-rw-r--r--src/vnet/session/application.h1
-rw-r--r--src/vnet/session/application_interface.h4
-rw-r--r--src/vnet/session/session.c43
-rw-r--r--src/vnet/session/session.h8
-rw-r--r--src/vnet/session/stream_session.h5
6 files changed, 44 insertions, 23 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 076c66f1fff..78c41b938cf 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -367,6 +367,12 @@ app_get_name_from_reg_index (application_t * app)
return app_name;
}
+int
+application_is_proxy (application_t * app)
+{
+ return !(app->flags & APP_OPTIONS_FLAGS_IS_PROXY);
+}
+
u8 *
format_application_listener (u8 * s, va_list * args)
{
diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h
index 35caae85dbb..29d37a06b18 100644
--- a/src/vnet/session/application.h
+++ b/src/vnet/session/application.h
@@ -116,6 +116,7 @@ segment_manager_t *application_get_listen_segment_manager (application_t *
s);
segment_manager_t *application_get_connect_segment_manager (application_t *
app);
+int application_is_proxy (application_t * app);
#endif /* SRC_VNET_SESSION_APPLICATION_H_ */
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index ed9f89b361e..1d63f6cc102 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -100,6 +100,9 @@ typedef struct _vnet_connect_args
/* Used for redirects */
void *mp;
+
+ /* used for proxy connections */
+ u64 server_handle;
} vnet_connect_args_t;
typedef struct _vnet_disconnect_args_t
@@ -129,6 +132,7 @@ typedef enum
_(USE_FIFO, "Use FIFO with redirects") \
_(ADD_SEGMENT, "Add segment and signal app if needed") \
_(BUILTIN_APP, "Application is builtin") \
+ _(IS_PROXY, "Application is proxying")
typedef enum _app_options
{
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 4ba152917ac..991bcd5a53f 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -30,7 +30,7 @@ extern transport_proto_vft_t *tp_vfts;
int
stream_session_create_i (segment_manager_t * sm, transport_connection_t * tc,
- stream_session_t ** ret_s)
+ u8 alloc_fifos, stream_session_t ** ret_s)
{
session_manager_main_t *smm = &session_manager_main;
svm_fifo_t *server_rx_fifo = 0, *server_tx_fifo = 0;
@@ -43,31 +43,37 @@ stream_session_create_i (segment_manager_t * sm, transport_connection_t * tc,
ASSERT (thread_index == vlib_get_thread_index ());
- if ((rv = segment_manager_alloc_session_fifos (sm, &server_rx_fifo,
- &server_tx_fifo,
- &fifo_segment_index)))
- return rv;
-
/* Create the session */
pool_get_aligned (smm->sessions[thread_index], s, CLIB_CACHE_LINE_BYTES);
memset (s, 0, sizeof (*s));
-
- /* Initialize backpointers */
pool_index = s - smm->sessions[thread_index];
- server_rx_fifo->master_session_index = pool_index;
- server_rx_fifo->master_thread_index = thread_index;
- server_tx_fifo->master_session_index = pool_index;
- server_tx_fifo->master_thread_index = thread_index;
+ /* Allocate fifos */
+ if (alloc_fifos)
+ {
+ if ((rv = segment_manager_alloc_session_fifos (sm, &server_rx_fifo,
+ &server_tx_fifo,
+ &fifo_segment_index)))
+ {
+ pool_put (smm->sessions[thread_index], s);
+ return rv;
+ }
+ /* Initialize backpointers */
+ server_rx_fifo->master_session_index = pool_index;
+ server_rx_fifo->master_thread_index = thread_index;
+
+ server_tx_fifo->master_session_index = pool_index;
+ server_tx_fifo->master_thread_index = thread_index;
- s->server_rx_fifo = server_rx_fifo;
- s->server_tx_fifo = server_tx_fifo;
+ s->server_rx_fifo = server_rx_fifo;
+ s->server_tx_fifo = server_tx_fifo;
+ s->svm_segment_index = fifo_segment_index;
+ }
/* Initialize state machine, such as it is... */
s->session_type = session_type_from_proto_and_ip (tc->transport_proto,
tc->is_ip4);
s->session_state = SESSION_STATE_CONNECTING;
- s->svm_segment_index = fifo_segment_index;
s->thread_index = thread_index;
s->session_index = pool_index;
@@ -379,10 +385,11 @@ stream_session_connect_notify (transport_connection_t * tc, u8 is_fail)
if (!is_fail)
{
segment_manager_t *sm;
+ u8 alloc_fifos;
sm = application_get_connect_segment_manager (app);
-
+ alloc_fifos = application_is_proxy (app);
/* Create new session (svm segments are allocated if needed) */
- if (stream_session_create_i (sm, tc, &new_s))
+ if (stream_session_create_i (sm, tc, alloc_fifos, &new_s))
{
is_fail = 1;
error = -1;
@@ -515,7 +522,7 @@ stream_session_accept (transport_connection_t * tc, u32 listener_index,
server = application_get (listener->app_index);
sm = application_get_listen_segment_manager (server, listener);
- if ((rv = stream_session_create_i (sm, tc, &s)))
+ if ((rv = stream_session_create_i (sm, tc, 1, &s)))
return rv;
s->app_index = server->index;
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 538433da0f2..74d82a408dc 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -183,10 +183,10 @@ stream_session_is_valid (u32 si, u8 thread_index)
stream_session_t *s;
s = pool_elt_at_index (session_manager_main.sessions[thread_index], si);
if (s->thread_index != thread_index || s->session_index != si
- || s->server_rx_fifo->master_session_index != si
- || s->server_tx_fifo->master_session_index != si
- || s->server_rx_fifo->master_thread_index != thread_index
- || s->server_tx_fifo->master_thread_index != thread_index)
+ /* || s->server_rx_fifo->master_session_index != si
+ || s->server_tx_fifo->master_session_index != si
+ || s->server_rx_fifo->master_thread_index != thread_index
+ || s->server_tx_fifo->master_thread_index != thread_index */ )
return 0;
return 1;
}
diff --git a/src/vnet/session/stream_session.h b/src/vnet/session/stream_session.h
index 82bbf521ce9..4c26321194d 100644
--- a/src/vnet/session/stream_session.h
+++ b/src/vnet/session/stream_session.h
@@ -83,8 +83,11 @@ typedef struct _stream_session_t
u32 opaque2;
+ /** connected (server) session handle */
+ u64 server_session_handle;
+
/** Opaque, pad to a 64-octet boundary */
- u64 opaque[2];
+ u64 opaque[1];
} stream_session_t;
#endif /* SRC_VNET_SESSION_STREAM_SESSION_H_ */