aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorNathan Skrzypczak <nathan.skrzypczak@gmail.com>2021-07-28 14:09:50 +0200
committerFlorin Coras <florin.coras@gmail.com>2021-10-05 19:13:13 +0000
commit7b3a3df263c7a5bf549f350553cbd9bce7ee40b3 (patch)
tree6c42695ee8e90c93bbe49c3cded4f35262322bc6 /src/vnet/session
parent5546e43f7943d6edff6c6587ed4e7233e8002e28 (diff)
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>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application_namespace.c11
-rw-r--r--src/vnet/session/application_namespace.h2
-rw-r--r--src/vnet/session/session.api12
-rw-r--r--src/vnet/session/session.c2
-rw-r--r--src/vnet/session/session_api.c11
5 files changed, 33 insertions, 5 deletions
diff --git a/src/vnet/session/application_namespace.c b/src/vnet/session/application_namespace.c
index bece746a757..cd2636cff32 100644
--- a/src/vnet/session/application_namespace.c
+++ b/src/vnet/session/application_namespace.c
@@ -222,10 +222,15 @@ app_namespace_get_local_table (app_namespace_t * app_ns)
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 14e6a650e56..1750d41fff8 100644
--- a/src/vnet/session/application_namespace.h
+++ b/src/vnet/session/application_namespace.h
@@ -162,7 +162,7 @@ appns_sapi_handle_sock_index (u32 sapi_sock_handle)
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 0eb773c0c28..d2a942fb68b 100644
--- a/src/vnet/session/session.api
+++ b/src/vnet/session/session.api
@@ -203,6 +203,18 @@ autoreply define session_enable_disable {
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 05712181ab0..f33dbea9a1e 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -2069,7 +2069,7 @@ session_config_fn (vlib_main_t * vm, unformat_input_t * input)
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 c031545323e..2121d2075e6 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -602,6 +602,17 @@ vl_api_session_enable_disable_t_handler (vl_api_session_enable_disable_t * mp)
}
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;