session: detect namespace for transport apps 35/14735/4
authorFlorin Coras <fcoras@cisco.com>
Fri, 7 Sep 2018 20:29:17 +0000 (13:29 -0700)
committerDamjan Marion <dmarion@me.com>
Sat, 8 Sep 2018 12:12:13 +0000 (12:12 +0000)
Change-Id: I770607cb213d538a29d7bd5762682981b01e9d18
Signed-off-by: Florin Coras <fcoras@cisco.com>
src/vnet/session/application_interface.c
src/vnet/session/application_interface.h
src/vnet/tls/tls.c

index ab87def..6c517e8 100644 (file)
@@ -130,11 +130,25 @@ api_parse_session_handle (u64 handle, u32 * session_index, u32 * thread_index)
 }
 
 static void
-session_endpoint_update_for_app (session_endpoint_t * sep,
+session_endpoint_update_for_app (session_endpoint_extended_t * sep,
                                 application_t * app)
 {
   app_namespace_t *app_ns;
-  app_ns = app_namespace_get (app->ns_index);
+  u32 ns_index;
+
+  ns_index = app->ns_index;
+
+  /* App is a transport proto, so fetch the calling app's ns */
+  if (app->flags & APP_OPTIONS_FLAGS_IS_TRANSPORT_APP)
+    {
+      app_worker_t *owner_wrk;
+      application_t *owner_app;
+
+      owner_wrk = app_worker_get (sep->app_wrk_index);
+      owner_app = application_get (owner_wrk->app_index);
+      ns_index = owner_app->ns_index;
+    }
+  app_ns = app_namespace_get (ns_index);
   if (app_ns)
     {
       /* Ask transport and network to bind to/connect using local interface
@@ -164,7 +178,7 @@ vnet_bind_inline (vnet_bind_args_t * a)
   app_wrk = application_get_worker (app, a->wrk_map_index);
   a->sep_ext.app_wrk_index = app_wrk->wrk_index;
 
-  session_endpoint_update_for_app (&a->sep, app);
+  session_endpoint_update_for_app (&a->sep_ext, app);
   if (!session_endpoint_in_ns (&a->sep))
     return VNET_API_ERROR_INVALID_VALUE_2;
 
@@ -257,7 +271,7 @@ application_connect (vnet_connect_args_t * a)
     return VNET_API_ERROR_INVALID_VALUE;
 
   client = application_get (a->app_index);
-  session_endpoint_update_for_app (&a->sep, client);
+  session_endpoint_update_for_app (&a->sep_ext, client);
   client_wrk = application_get_worker (client, a->wrk_map_index);
 
   /*
index 1eefb0c..5b28a29 100644 (file)
@@ -123,6 +123,7 @@ typedef enum
   _(ACCEPT_REDIRECT, "Use FIFO with redirects")                        \
   _(ADD_SEGMENT, "Add segment and signal app if needed")       \
   _(IS_BUILTIN, "Application is builtin")                      \
+  _(IS_TRANSPORT_APP, "Application is a transport proto")      \
   _(IS_PROXY, "Application is proxying")                       \
   _(USE_GLOBAL_SCOPE, "App can use global session scope")      \
   _(USE_LOCAL_SCOPE, "App can use local session scope")                \
index 2d7126a..a31466b 100644 (file)
@@ -714,6 +714,7 @@ tls_init (vlib_main_t * vm)
   a->options[APP_OPTIONS_TX_FIFO_SIZE] = fifo_size;
   a->options[APP_OPTIONS_FLAGS] = APP_OPTIONS_FLAGS_IS_BUILTIN;
   a->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_USE_GLOBAL_SCOPE;
+  a->options[APP_OPTIONS_FLAGS] |= APP_OPTIONS_FLAGS_IS_TRANSPORT_APP;
 
   if (vnet_application_attach (a))
     {