session: Add session_sapi_enable_disable
Type: feature
This adds an API message to do the switch
at runtime.
Change-Id: Ice6b69c57f0bfbf5668182e25593362ff4133615
Signed-off-by: Nathan Skrzypczak <nathan.skrzypczak@gmail.com>
diff --git a/src/vnet/session/application_namespace.c b/src/vnet/session/application_namespace.c
index bece746..cd2636c 100644
--- a/src/vnet/session/application_namespace.c
+++ b/src/vnet/session/application_namespace.c
@@ -222,10 +222,15 @@
return session_table_get (app_ns->local_table_index);
}
-void
-appns_sapi_enable (void)
+int
+appns_sapi_enable_disable (int is_enable)
{
- app_sapi_enabled = 1;
+ /* This cannot be called with active sockets */
+ if (pool_elts (app_namespace_pool))
+ return -1;
+
+ app_sapi_enabled = is_enable;
+ return 0;
}
u8
diff --git a/src/vnet/session/application_namespace.h b/src/vnet/session/application_namespace.h
index 14e6a65..1750d41 100644
--- a/src/vnet/session/application_namespace.h
+++ b/src/vnet/session/application_namespace.h
@@ -162,7 +162,7 @@
int appns_sapi_add_ns_socket (app_namespace_t * app_ns);
void appns_sapi_del_ns_socket (app_namespace_t *app_ns);
u8 appns_sapi_enabled (void);
-void appns_sapi_enable (void);
+int appns_sapi_enable_disable (int is_enable);
#endif /* SRC_VNET_SESSION_APPLICATION_NAMESPACE_H_ */
diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api
index 0eb773c..d2a942f 100644
--- a/src/vnet/session/session.api
+++ b/src/vnet/session/session.api
@@ -203,6 +203,18 @@
bool is_enable [default=true];
};
+/** \brief enable/disable session layer socket api
+ @param client_index - opaque cookie to identify the sender
+ client to vpp direction only
+ @param context - sender context, to match reply w/ request
+ @param is_enable - disable session layer if 0, enable otherwise
+*/
+autoreply define session_sapi_enable_disable {
+ u32 client_index;
+ u32 context;
+ bool is_enable [default=true];
+};
+
/** \brief add/del application namespace
@param client_index - opaque cookie to identify the sender
client to vpp direction only
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 0571218..f33dbea 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -2069,7 +2069,7 @@
else if (unformat (input, "segment-baseva 0x%lx", &smm->session_baseva))
;
else if (unformat (input, "use-app-socket-api"))
- appns_sapi_enable ();
+ (void) appns_sapi_enable_disable (1 /* is_enable */);
else if (unformat (input, "poll-main"))
smm->poll_main = 1;
else if (unformat (input, "use-private-rx-mqs"))
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index c031545..2121d20 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -602,6 +602,17 @@
}
static void
+vl_api_session_sapi_enable_disable_t_handler (
+ vl_api_session_sapi_enable_disable_t *mp)
+{
+ vl_api_session_sapi_enable_disable_reply_t *rmp;
+ int rv = 0;
+
+ rv = appns_sapi_enable_disable (mp->is_enable);
+ REPLY_MACRO (VL_API_SESSION_SAPI_ENABLE_DISABLE_REPLY);
+}
+
+static void
vl_api_app_attach_t_handler (vl_api_app_attach_t * mp)
{
int rv = 0, *fds = 0, n_fds = 0, n_workers, i;