aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session/session_api.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session/session_api.c')
-rw-r--r--src/vnet/session/session_api.c81
1 files changed, 70 insertions, 11 deletions
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 371fcfc9271..c0ed1250dab 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -834,6 +834,8 @@ vl_api_app_namespace_add_del_t_handler (vl_api_app_namespace_add_del_t * mp)
vnet_app_namespace_add_del_args_t args = {
.ns_id = ns_id,
+ .netns = 0,
+ .sock_name = 0,
.secret = clib_net_to_host_u64 (mp->secret),
.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
.ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
@@ -884,6 +886,7 @@ vl_api_app_namespace_add_del_v2_t_handler (
vnet_app_namespace_add_del_args_t args = {
.ns_id = ns_id,
.netns = netns,
+ .sock_name = 0,
.secret = clib_net_to_host_u64 (mp->secret),
.sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
.ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
@@ -896,7 +899,7 @@ vl_api_app_namespace_add_del_v2_t_handler (
appns_index = app_namespace_index_from_id (ns_id);
if (appns_index == APP_NAMESPACE_INVALID_INDEX)
{
- clib_warning ("app ns lookup failed");
+ clib_warning ("app ns lookup failed id:%s", ns_id);
rv = VNET_API_ERROR_UNSPECIFIED;
}
}
@@ -911,6 +914,54 @@ done:
}
static void
+vl_api_app_namespace_add_del_v3_t_handler (
+ vl_api_app_namespace_add_del_v3_t *mp)
+{
+ vl_api_app_namespace_add_del_v3_reply_t *rmp;
+ u8 *ns_id = 0, *netns = 0, *sock_name = 0;
+ u32 appns_index = 0;
+ int rv = 0;
+ if (session_main_is_enabled () == 0)
+ {
+ rv = VNET_API_ERROR_FEATURE_DISABLED;
+ goto done;
+ }
+ mp->namespace_id[sizeof (mp->namespace_id) - 1] = 0;
+ mp->netns[sizeof (mp->netns) - 1] = 0;
+ ns_id = format (0, "%s", &mp->namespace_id);
+ netns = format (0, "%s", &mp->netns);
+ sock_name = format (0, "%s", &mp->sock_name);
+ vnet_app_namespace_add_del_args_t args = {
+ .ns_id = ns_id,
+ .netns = netns,
+ .sock_name = sock_name,
+ .secret = clib_net_to_host_u64 (mp->secret),
+ .sw_if_index = clib_net_to_host_u32 (mp->sw_if_index),
+ .ip4_fib_id = clib_net_to_host_u32 (mp->ip4_fib_id),
+ .ip6_fib_id = clib_net_to_host_u32 (mp->ip6_fib_id),
+ .is_add = mp->is_add,
+ };
+ rv = vnet_app_namespace_add_del (&args);
+ if (!rv && mp->is_add)
+ {
+ appns_index = app_namespace_index_from_id (ns_id);
+ if (appns_index == APP_NAMESPACE_INVALID_INDEX)
+ {
+ clib_warning ("app ns lookup failed id:%s", ns_id);
+ rv = VNET_API_ERROR_UNSPECIFIED;
+ }
+ }
+ vec_free (ns_id);
+ vec_free (netns);
+ vec_free (sock_name);
+done:
+ REPLY_MACRO2 (VL_API_APP_NAMESPACE_ADD_DEL_V3_REPLY, ({
+ if (!rv)
+ rmp->appns_index = clib_host_to_net_u32 (appns_index);
+ }));
+}
+
+static void
vl_api_session_rule_add_del_t_handler (vl_api_session_rule_add_del_t * mp)
{
vl_api_session_rule_add_del_reply_t *rmp;
@@ -1722,19 +1773,27 @@ appns_sapi_add_ns_socket (app_namespace_t * app_ns)
clib_socket_t *cs;
char dir[4096];
- snprintf (dir, sizeof (dir), "%s%s", vlib_unix_get_runtime_dir (), subdir);
- err = vlib_unix_recursive_mkdir ((char *) dir);
- if (err)
+ if (app_ns->netns)
{
- clib_error_report (err);
- return -1;
+ if (!app_ns->sock_name)
+ app_ns->sock_name = format (0, "@vpp/session/%v%c", app_ns->ns_id, 0);
+ if (app_ns->sock_name[0] != '@')
+ return VNET_API_ERROR_INVALID_VALUE;
}
-
- /* Use abstract sockets if a netns was provided */
- if (app_ns->netns)
- app_ns->sock_name = format (0, "@vpp/session/%v%c", app_ns->ns_id, 0);
else
- app_ns->sock_name = format (0, "%s%v%c", dir, app_ns->ns_id, 0);
+ {
+ snprintf (dir, sizeof (dir), "%s%s", vlib_unix_get_runtime_dir (),
+ subdir);
+ err = vlib_unix_recursive_mkdir ((char *) dir);
+ if (err)
+ {
+ clib_error_report (err);
+ return VNET_API_ERROR_SYSCALL_ERROR_1;
+ }
+
+ if (!app_ns->sock_name)
+ app_ns->sock_name = format (0, "%s%v%c", dir, app_ns->ns_id, 0);
+ }
/*
* Create and initialize socket to listen on