diff options
author | Florin Coras <fcoras@cisco.com> | 2017-10-31 01:51:04 -0700 |
---|---|---|
committer | Damjan Marion <dmarion.lists@gmail.com> | 2017-11-01 09:29:25 +0000 |
commit | 7999e83a41ebad8a3f02cfcb2809cdb3aae919ba (patch) | |
tree | 58d7c95c87c3bb27bbeb045e22b4c6967defccc3 /src/vnet/session/application_interface.c | |
parent | df36f2176d7e90dcd3e895b08ee2d69f42d15426 (diff) |
session: add support for proxying apps
To enable this, applications set the proxy flag in their attach requests
and pass the transport protocols they want to act as proxies for as part
of the attach options.
When proxy is enabled, session rules that point incoming packets to the
proxy app are addedd to the local and global session tables, if these
scopes are accessible to the app. In particular, in case of the former,
the rule accepts packets from all sources and all ports destined to the
namespace's supporting interface address on any port. While in case of
the latter, a generic any destination and any port rule is addedd.
Change-Id: I791f8c1cc083350f02e26a2ac3bdbbfbfa19ece3
Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session/application_interface.c')
-rw-r--r-- | src/vnet/session/application_interface.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c index 8599c74fe46..a9dda022751 100644 --- a/src/vnet/session/application_interface.c +++ b/src/vnet/session/application_interface.c @@ -206,7 +206,7 @@ vnet_connect_i (u32 app_index, u32 api_context, session_endpoint_t * sep, void *mp) { application_t *server, *app; - u32 table_index; + u32 table_index, server_index; stream_session_t *listener; if (session_endpoint_is_zero (sep)) @@ -223,14 +223,23 @@ vnet_connect_i (u32 app_index, u32 api_context, session_endpoint_t * sep, if (application_has_local_scope (app)) { table_index = application_local_session_table (app); - app_index = session_lookup_local_session_endpoint (table_index, sep); - server = application_get (app_index); + server_index = session_lookup_local_session_endpoint (table_index, sep); + /* - * Server is willing to have a direct fifo connection created - * instead of going through the state machine, etc. + * Break loop if rule in local table points to connecting app. This + * can happen if client is a generic proxy. Route connect through + * global table instead. */ - if (server && (server->flags & APP_OPTIONS_FLAGS_ACCEPT_REDIRECT)) - return app_connect_redirect (server, mp); + if (server_index != app_index) + { + server = application_get (server_index); + /* + * Server is willing to have a direct fifo connection created + * instead of going through the state machine, etc. + */ + if (server && (server->flags & APP_OPTIONS_FLAGS_ACCEPT_REDIRECT)) + return app_connect_redirect (server, mp); + } } /* @@ -414,6 +423,9 @@ vnet_application_attach (vnet_app_attach_args_t * a) segment_manager_get_segment_info (sm->segment_indices[0], &seg_name, &a->segment_size); + if (application_is_proxy (app)) + application_setup_proxy (app); + a->segment_name_length = vec_len (seg_name); a->segment_name = seg_name; ASSERT (vec_len (a->segment_name) <= 128); |