summaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c27
-rw-r--r--src/vnet/session/application.h1
-rw-r--r--src/vnet/session/application_interface.c6
-rw-r--r--src/vnet/session/node.c57
-rw-r--r--src/vnet/session/session.api22
-rw-r--r--src/vnet/session/session.c86
-rw-r--r--src/vnet/session/session.h23
-rw-r--r--src/vnet/session/session_api.c59
-rw-r--r--src/vnet/session/session_cli.c63
9 files changed, 278 insertions, 66 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index a561e7d17f0..a542eebe43f 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -154,6 +154,15 @@ application_get (u32 index)
return pool_elt_at_index (app_pool, index);
}
+application_t *
+application_get_if_valid (u32 index)
+{
+ if (pool_is_free_index (app_pool, index))
+ return 0;
+
+ return pool_elt_at_index (app_pool, index);
+}
+
u32
application_get_index (application_t * app)
{
@@ -209,7 +218,7 @@ format_application_server (u8 * s, va_list * args)
regp = vl_api_client_index_to_registration (srv->api_client_index);
if (!regp)
- server_name = format (0, "%s%c", regp->name, 0);
+ server_name = format (0, "builtin-%d%c", srv->index, 0);
else
server_name = regp->name;
@@ -269,11 +278,17 @@ static clib_error_t *
show_app_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
+ session_manager_main_t *smm = &session_manager_main;
application_t *app;
int do_server = 0;
int do_client = 0;
int verbose = 0;
+ if (!smm->is_enabled)
+ {
+ clib_error_return (0, "session layer is not enabled");
+ }
+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "server"))
@@ -323,16 +338,20 @@ show_app_command_fn (vlib_main_t * vm, unformat_input_t * input,
/* *INDENT-ON* */
}
else
- vlib_cli_output (vm, "No active server bindings");
+ vlib_cli_output (vm, "No active client bindings");
}
return 0;
}
+/* *INDENT-OFF* */
VLIB_CLI_COMMAND (show_app_command, static) =
{
-.path = "show app",.short_help =
- "show app [server|client] [verbose]",.function = show_app_command_fn,};
+ .path = "show app",
+ .short_help = "show app [server|client] [verbose]",
+ .function = show_app_command_fn,
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON
diff --git a/src/vnet/session/application.h b/src/vnet/session/application.h
index 027d6967fd7..480828f7b34 100644
--- a/src/vnet/session/application.h
+++ b/src/vnet/session/application.h
@@ -100,6 +100,7 @@ application_t *application_new (application_type_t type, session_type_t sst,
session_cb_vft_t * cb_fns);
void application_del (application_t * app);
application_t *application_get (u32 index);
+application_t *application_get_if_valid (u32 index);
application_t *application_lookup (u32 api_client_index);
u32 application_get_index (application_t * app);
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index 0ea77fd8c4e..6ddfb70f609 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -51,7 +51,7 @@ ip_is_local (ip46_address_t * ip46_address, u8 is_ip4)
prefix.fp_proto = FIB_PROTOCOL_IP6;
}
- clib_memcpy (&prefix.fp_addr, ip46_address, sizeof (ip46_address));
+ clib_memcpy (&prefix.fp_addr, ip46_address, sizeof (ip46_address_t));
fei = fib_table_lookup (0, &prefix);
flags = fib_entry_get_flags (fei);
@@ -186,9 +186,7 @@ vnet_connect_i (u32 api_client_index, u32 api_context, session_type_t sst,
/*
* Not connecting to a local server. Create regular session
*/
- stream_session_open (sst, ip46, port, app->index);
-
- return 0;
+ return stream_session_open (sst, ip46, port, app->index);
}
/**
diff --git a/src/vnet/session/node.c b/src/vnet/session/node.c
index e467f4e99e2..399077decb0 100644
--- a/src/vnet/session/node.c
+++ b/src/vnet/session/node.c
@@ -104,9 +104,13 @@ session_fifo_rx_i (vlib_main_t * vm, vlib_node_runtime_t * node,
snd_space0 = transport_vft->send_space (tc0);
snd_mss0 = transport_vft->send_mss (tc0);
+ /* Can't make any progress */
if (snd_space0 == 0 || svm_fifo_max_dequeue (s0->server_tx_fifo) == 0
|| snd_mss0 == 0)
- return 0;
+ {
+ vec_add1 (smm->evts_partially_read[thread_index], *e0);
+ return 0;
+ }
ASSERT (e0->enqueue_length > 0);
@@ -143,7 +147,12 @@ session_fifo_rx_i (vlib_main_t * vm, vlib_node_runtime_t * node,
if (PREDICT_FALSE (n_bufs < 0.9 * VLIB_FRAME_SIZE))
{
/* Keep track of how much we've dequeued and exit */
- e0->enqueue_length -= max_len_to_snd0 - left_to_snd0;
+ if (left_to_snd0 != max_len_to_snd0)
+ {
+ e0->enqueue_length -= max_len_to_snd0 - left_to_snd0;
+ vec_add1 (smm->evts_partially_read[thread_index], *e0);
+ }
+
return -1;
}
@@ -185,12 +194,13 @@ session_fifo_rx_i (vlib_main_t * vm, vlib_node_runtime_t * node,
t0->server_thread_index = s0->thread_index;
}
+ /* *INDENT-OFF* */
if (1)
{
- ELOG_TYPE_DECLARE (e) =
- {
- .format = "evt-dequeue: id %d length %d",.format_args =
- "i4i4",};
+ ELOG_TYPE_DECLARE (e) = {
+ .format = "evt-dequeue: id %d length %d",
+ .format_args = "i4i4",
+ };
struct
{
u32 data[2];
@@ -199,6 +209,7 @@ session_fifo_rx_i (vlib_main_t * vm, vlib_node_runtime_t * node,
ed->data[0] = e0->event_id;
ed->data[1] = e0->enqueue_length;
}
+ /* *INDENT-ON* */
len_to_deq0 = (left_to_snd0 < snd_mss0) ? left_to_snd0 : snd_mss0;
@@ -289,7 +300,7 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
{
session_manager_main_t *smm = vnet_get_session_manager_main ();
session_fifo_event_t *my_fifo_events, *e;
- u32 n_to_dequeue;
+ u32 n_to_dequeue, n_events;
unix_shared_memory_queue_t *q;
int n_tx_packets = 0;
u32 my_thread_index = vm->cpu_index;
@@ -309,14 +320,16 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
/* min number of events we can dequeue without blocking */
n_to_dequeue = q->cursize;
- if (n_to_dequeue == 0)
- return 0;
-
my_fifo_events = smm->fifo_events[my_thread_index];
- /* If we didn't manage to process previous events try going
+ if (n_to_dequeue == 0 && vec_len (my_fifo_events) == 0)
+ return 0;
+
+ /*
+ * If we didn't manage to process previous events try going
* over them again without dequeuing new ones.
- * XXX: Block senders to sessions that can't keep up */
+ */
+ /* XXX: Block senders to sessions that can't keep up */
if (vec_len (my_fifo_events) >= 100)
goto skip_dequeue;
@@ -338,8 +351,8 @@ session_queue_node_fn (vlib_main_t * vm, vlib_node_runtime_t * node,
smm->fifo_events[my_thread_index] = my_fifo_events;
skip_dequeue:
-
- for (i = 0; i < n_to_dequeue; i++)
+ n_events = vec_len (my_fifo_events);
+ for (i = 0; i < n_events; i++)
{
svm_fifo_t *f0; /* $$$ prefetch 1 ahead maybe */
stream_session_t *s0;
@@ -354,8 +367,13 @@ skip_dequeue:
/* $$$ add multiple event queues, per vpp worker thread */
ASSERT (server_thread_index0 == my_thread_index);
- s0 = pool_elt_at_index (smm->sessions[my_thread_index],
- server_session_index0);
+ s0 = stream_session_get_if_valid (server_session_index0,
+ my_thread_index);
+ if (!s0)
+ {
+ clib_warning ("It's dead Jim!");
+ continue;
+ }
ASSERT (s0->thread_index == my_thread_index);
@@ -380,11 +398,11 @@ skip_dequeue:
done:
/* Couldn't process all events. Probably out of buffers */
- if (PREDICT_FALSE (i < n_to_dequeue))
+ if (PREDICT_FALSE (i < n_events))
{
session_fifo_event_t *partially_read =
smm->evts_partially_read[my_thread_index];
- vec_add (partially_read, &my_fifo_events[i], n_to_dequeue - i);
+ vec_add (partially_read, &my_fifo_events[i], n_events - i);
vec_free (my_fifo_events);
smm->fifo_events[my_thread_index] = partially_read;
smm->evts_partially_read[my_thread_index] = 0;
@@ -413,8 +431,7 @@ VLIB_REGISTER_NODE (session_queue_node) =
.n_errors = ARRAY_LEN (session_queue_error_strings),
.error_strings = session_queue_error_strings,
.n_next_nodes = SESSION_QUEUE_N_NEXT,
- /* .state = VLIB_NODE_STATE_DISABLED, enable on-demand? */
- /* edit / add dispositions here */
+ .state = VLIB_NODE_STATE_DISABLED,
.next_nodes =
{
[SESSION_QUEUE_NEXT_DROP] = "error-drop",
diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api
index a7b28c1dba0..582765b5904 100644
--- a/src/vnet/session/session.api
+++ b/src/vnet/session/session.api
@@ -422,6 +422,28 @@ define reset_sock_reply {
i32 retval;
u64 handle;
};
+
+/** \brief enable/disable session layer
+ @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
+*/
+define session_enable_disable {
+ u32 client_index;
+ u32 context;
+ u8 is_enable;
+};
+
+/** \brief Reply for session enable/disable
+ @param context - returned sender context, to match reply w/ request
+ @param retval - return code
+*/
+define session_enable_disable_reply {
+ u32 context;
+ i32 retval;
+};
+
/*
* Local Variables:
* eval: (c-set-style "gnu")
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index 539da613367..422527e0d4c 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -311,11 +311,11 @@ stream_session_half_open_lookup (session_manager_main_t * smm,
}
transport_connection_t *
-stream_session_lookup_transport4 (session_manager_main_t * smm,
- ip4_address_t * lcl, ip4_address_t * rmt,
+stream_session_lookup_transport4 (ip4_address_t * lcl, ip4_address_t * rmt,
u16 lcl_port, u16 rmt_port, u8 proto,
u32 my_thread_index)
{
+ session_manager_main_t *smm = &session_manager_main;
session_kv4_t kv4;
stream_session_t *s;
int rv;
@@ -345,11 +345,11 @@ stream_session_lookup_transport4 (session_manager_main_t * smm,
}
transport_connection_t *
-stream_session_lookup_transport6 (session_manager_main_t * smm,
- ip6_address_t * lcl, ip6_address_t * rmt,
+stream_session_lookup_transport6 (ip6_address_t * lcl, ip6_address_t * rmt,
u16 lcl_port, u16 rmt_port, u8 proto,
u32 my_thread_index)
{
+ session_manager_main_t *smm = &session_manager_main;
stream_session_t *s;
session_kv6_t kv6;
int rv;
@@ -554,7 +554,7 @@ session_manager_allocate_session_fifos (session_manager_main_t * smm,
u8 * added_a_segment)
{
svm_fifo_segment_private_t *fifo_segment;
- u32 fifo_size, default_fifo_size = 8192 /* TODO config */ ;
+ u32 fifo_size, default_fifo_size = 128 << 10; /* TODO config */
int i;
*added_a_segment = 0;
@@ -948,7 +948,7 @@ void
connects_session_manager_init (session_manager_main_t * smm, u8 session_type)
{
session_manager_t *sm;
- u32 connect_fifo_size = 8 << 10; /* Config? */
+ u32 connect_fifo_size = 256 << 10; /* Config? */
u32 default_segment_size = 1 << 20;
pool_get (smm->session_managers, sm);
@@ -1055,10 +1055,15 @@ stream_session_delete (stream_session_t * s)
svm_fifo_segment_free_fifo (fifo_segment, s->server_rx_fifo);
svm_fifo_segment_free_fifo (fifo_segment, s->server_tx_fifo);
- /* Cleanup app if client */
- app = application_get (s->app_index);
+ app = application_get_if_valid (s->app_index);
+
+ /* No app. A possibility: after disconnect application called unbind */
+ if (!app)
+ return;
+
if (app->mode == APP_CLIENT)
{
+ /* Cleanup app if client */
application_del (app);
}
else if (app->mode == APP_SERVER)
@@ -1068,6 +1073,7 @@ stream_session_delete (stream_session_t * s)
svm_fifo_t **fifos;
u32 fifo_index;
+ /* For server, see if any segments can be removed */
sm = session_manager_get (app->session_manager_index);
/* Delete fifo */
@@ -1096,10 +1102,10 @@ stream_session_delete_notify (transport_connection_t * tc)
{
stream_session_t *s;
+ /* App might've been removed already */
s = stream_session_get_if_valid (tc->s_index, tc->thread_index);
if (!s)
{
- clib_warning ("Surprised!");
return;
}
stream_session_delete (s);
@@ -1151,16 +1157,24 @@ stream_session_accept (transport_connection_t * tc, u32 listener_index,
return 0;
}
-void
+int
stream_session_open (u8 sst, ip46_address_t * addr, u16 port_host_byte_order,
u32 app_index)
{
transport_connection_t *tc;
u32 tci;
u64 value;
+ int rv;
/* Ask transport to open connection */
- tci = tp_vfts[sst].open (addr, port_host_byte_order);
+ rv = tp_vfts[sst].open (addr, port_host_byte_order);
+ if (rv < 0)
+ {
+ clib_warning ("Transport failed to open connection.");
+ return VNET_API_ERROR_SESSION_CONNECT_FAIL;
+ }
+
+ tci = rv;
/* Get transport connection */
tc = tp_vfts[sst].get_half_open (tci);
@@ -1170,6 +1184,8 @@ stream_session_open (u8 sst, ip46_address_t * addr, u16 port_host_byte_order,
/* Add to the half-open lookup table */
stream_session_half_open_table_add (sst, tc, value);
+
+ return 0;
}
/**
@@ -1216,16 +1232,13 @@ session_get_transport_vft (u8 type)
}
static clib_error_t *
-session_manager_main_init (vlib_main_t * vm)
+session_manager_main_enable (vlib_main_t * vm)
{
- u32 num_threads;
- vlib_thread_main_t *vtm = vlib_get_thread_main ();
session_manager_main_t *smm = &session_manager_main;
+ vlib_thread_main_t *vtm = vlib_get_thread_main ();
+ u32 num_threads;
int i;
- smm->vlib_main = vm;
- smm->vnet_main = vnet_get_main ();
-
num_threads = 1 /* main thread */ + vtm->n_threads;
if (num_threads < 1)
@@ -1272,11 +1285,48 @@ session_manager_main_init (vlib_main_t * vm)
for (i = 0; i < SESSION_N_TYPES; i++)
smm->connect_manager_index[i] = INVALID_INDEX;
+ smm->is_enabled = 1;
+
return 0;
}
-VLIB_INIT_FUNCTION (session_manager_main_init);
+clib_error_t *
+vnet_session_enable_disable (vlib_main_t * vm, u8 is_en)
+{
+ if (is_en)
+ {
+ if (session_manager_main.is_enabled)
+ return 0;
+
+ vlib_node_set_state (vm, session_queue_node.index,
+ VLIB_NODE_STATE_POLLING);
+
+ return session_manager_main_enable (vm);
+ }
+ else
+ {
+ session_manager_main.is_enabled = 0;
+ vlib_node_set_state (vm, session_queue_node.index,
+ VLIB_NODE_STATE_DISABLED);
+ }
+
+ return 0;
+}
+
+
+clib_error_t *
+session_manager_main_init (vlib_main_t * vm)
+{
+ session_manager_main_t *smm = &session_manager_main;
+
+ smm->vlib_main = vm;
+ smm->vnet_main = vnet_get_main ();
+ smm->is_enabled = 0;
+
+ return 0;
+}
+VLIB_INIT_FUNCTION (session_manager_main_init)
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index cf14cca9f30..46e5ce2cdd0 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -213,12 +213,15 @@ struct _session_manager_main
/** Per transport rx function that can either dequeue or peek */
session_fifo_rx_fn *session_rx_fns[SESSION_N_TYPES];
+ u8 is_enabled;
+
/* Convenience */
vlib_main_t *vlib_main;
vnet_main_t *vnet_main;
};
extern session_manager_main_t session_manager_main;
+extern vlib_node_registration_t session_queue_node;
/*
* Session manager function
@@ -276,14 +279,12 @@ stream_session_t *stream_session_lookup6 (ip6_address_t * lcl,
ip6_address_t * rmt, u16 lcl_port,
u16 rmt_port, u8, u32 thread_index);
transport_connection_t
- * stream_session_lookup_transport4 (session_manager_main_t * smm,
- ip4_address_t * lcl,
+ * stream_session_lookup_transport4 (ip4_address_t * lcl,
ip4_address_t * rmt, u16 lcl_port,
u16 rmt_port, u8 proto,
u32 thread_index);
transport_connection_t
- * stream_session_lookup_transport6 (session_manager_main_t * smm,
- ip6_address_t * lcl,
+ * stream_session_lookup_transport6 (ip6_address_t * lcl,
ip6_address_t * rmt, u16 lcl_port,
u16 rmt_port, u8 proto,
u32 thread_index);
@@ -338,6 +339,14 @@ stream_session_max_enqueue (transport_connection_t * tc)
return svm_fifo_max_enqueue (s->server_rx_fifo);
}
+always_inline u32
+stream_session_fifo_size (transport_connection_t * tc)
+{
+ stream_session_t *s = stream_session_get (tc->s_index, tc->thread_index);
+ return s->server_rx_fifo->nitems;
+}
+
+
int
stream_session_enqueue_data (transport_connection_t * tc, u8 * data, u16 len,
u8 queue_event);
@@ -356,8 +365,8 @@ void stream_session_reset_notify (transport_connection_t * tc);
int
stream_session_accept (transport_connection_t * tc, u32 listener_index,
u8 sst, u8 notify);
-void stream_session_open (u8 sst, ip46_address_t * addr,
- u16 port_host_byte_order, u32 api_client_index);
+int stream_session_open (u8 sst, ip46_address_t * addr,
+ u16 port_host_byte_order, u32 api_client_index);
void stream_session_disconnect (stream_session_t * s);
void stream_session_cleanup (stream_session_t * s);
int
@@ -369,6 +378,8 @@ u8 *format_stream_session (u8 * s, va_list * args);
void session_register_transport (u8 type, const transport_proto_vft_t * vft);
transport_proto_vft_t *session_get_transport_vft (u8 type);
+clib_error_t *vnet_session_enable_disable (vlib_main_t * vm, u8 is_en);
+
#endif /* __included_session_h__ */
/*
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index 9d068684636..8852fc6ee08 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -52,6 +52,8 @@ _(DISCONNECT_SOCK, disconnect_sock) \
_(DISCONNECT_SOCK_REPLY, disconnect_sock_reply) \
_(ACCEPT_SOCK_REPLY, accept_sock_reply) \
_(RESET_SOCK_REPLY, reset_sock_reply) \
+_(SESSION_ENABLE_DISABLE, session_enable_disable) \
+
static int
send_add_segment_callback (u32 api_client_index, const u8 * segment_name,
@@ -146,7 +148,6 @@ send_session_connected_uri_callback (u32 api_client_index,
mp = vl_msg_api_alloc (sizeof (*mp));
mp->_vl_msg_id = clib_host_to_net_u16 (VL_API_CONNECT_URI_REPLY);
mp->context = app->api_context;
- mp->retval = is_fail;
if (!is_fail)
{
vpp_queue = session_manager_get_vpp_event_queue (s->thread_index);
@@ -157,6 +158,7 @@ send_session_connected_uri_callback (u32 api_client_index,
mp->session_type = s->session_type;
mp->vpp_event_queue_address = (u64) vpp_queue;
mp->client_event_queue_address = (u64) app->event_queue;
+ mp->retval = 0;
session_manager_get_segment_info (s->server_segment_index, &seg_name,
&mp->segment_size);
@@ -164,12 +166,22 @@ send_session_connected_uri_callback (u32 api_client_index,
if (mp->segment_name_length)
clib_memcpy (mp->segment_name, seg_name, mp->segment_name_length);
}
+ else
+ {
+ mp->retval = VNET_API_ERROR_SESSION_CONNECT_FAIL;
+ }
vl_msg_api_send_shmem (q, (u8 *) & mp);
/* Remove client if connect failed */
if (is_fail)
- application_del (app);
+ {
+ application_del (app);
+ }
+ else
+ {
+ s->session_state = SESSION_STATE_READY;
+ }
return 0;
}
@@ -432,6 +444,17 @@ api_session_not_valid (u32 session_index, u32 thread_index)
}
static void
+vl_api_session_enable_disable_t_handler (vl_api_session_enable_disable_t * mp)
+{
+ vl_api_session_enable_disable_reply_t *rmp;
+ vlib_main_t *vm = vlib_get_main ();
+ int rv = 0;
+
+ vnet_session_enable_disable (vm, mp->is_enable);
+ REPLY_MACRO (VL_API_SESSION_ENABLE_DISABLE_REPLY);
+}
+
+static void
vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
{
vl_api_bind_uri_reply_t *rmp;
@@ -476,7 +499,6 @@ vl_api_bind_uri_t_handler (vl_api_bind_uri_t * mp)
}
}));
/* *INDENT-ON* */
-
}
static void
@@ -493,7 +515,9 @@ vl_api_unbind_uri_t_handler (vl_api_unbind_uri_t * mp)
static void
vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
{
+ vl_api_connect_uri_reply_t *rmp;
vnet_connect_args_t _a, *a = &_a;
+ int rv;
a->uri = (char *) mp->uri;
a->api_client_index = mp->client_index;
@@ -501,7 +525,19 @@ vl_api_connect_uri_t_handler (vl_api_connect_uri_t * mp)
a->options = mp->options;
a->session_cb_vft = &uri_session_cb_vft;
a->mp = mp;
- vnet_connect_uri (a);
+
+ rv = vnet_connect_uri (a);
+
+ if (rv == 0 || rv == VNET_CONNECT_REDIRECTED)
+ return;
+
+ /* Got some error, relay it */
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_CONNECT_URI_REPLY, ({
+ rmp->retval = rv;
+ }));
+ /* *INDENT-ON* */
}
static void
@@ -662,7 +698,9 @@ vl_api_unbind_sock_t_handler (vl_api_unbind_sock_t * mp)
static void
vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp)
{
+ vl_api_connect_sock_reply_t *rmp;
vnet_connect_args_t _a, *a = &_a;
+ int rv;
clib_memcpy (&a->tep.ip, mp->ip,
(mp->is_ip4 ? sizeof (ip4_address_t) :
@@ -675,7 +713,18 @@ vl_api_connect_sock_t_handler (vl_api_connect_sock_t * mp)
a->api_context = mp->context;
a->mp = mp;
- vnet_connect (a);
+ rv = vnet_connect (a);
+
+ if (rv == 0 || rv == VNET_CONNECT_REDIRECTED)
+ return;
+
+ /* Got some error, relay it */
+
+ /* *INDENT-OFF* */
+ REPLY_MACRO2 (VL_API_CONNECT_URI_REPLY, ({
+ rmp->retval = rv;
+ }));
+ /* *INDENT-ON* */
}
static void
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index b2943a1ccc5..b029ee6549a 100644
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -60,7 +60,7 @@ format_stream_session (u8 * s, va_list * args)
}
else
{
- clib_warning ("Session in unknown state!");
+ clib_warning ("Session in state: %d!", ss->session_state);
}
vec_free (str);
@@ -78,6 +78,11 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
stream_session_t *s;
u8 *str = 0;
+ if (!smm->is_enabled)
+ {
+ clib_error_return (0, "session layer is not enabled");
+ }
+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "verbose"))
@@ -126,11 +131,14 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
return 0;
}
-VLIB_CLI_COMMAND (show_uri_command, static) =
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_session_command, static) =
{
-.path = "show session",.short_help = "show session [verbose]",.function =
- show_session_command_fn,};
-
+ .path = "show session",
+ .short_help = "show session [verbose]",
+ .function = show_session_command_fn,
+};
+/* *INDENT-ON* */
static clib_error_t *
clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
@@ -142,6 +150,11 @@ clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
stream_session_t *pool, *session;
application_t *server;
+ if (!smm->is_enabled)
+ {
+ clib_error_return (0, "session layer is not enabled");
+ }
+
while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
{
if (unformat (input, "thread %d", &thread_index))
@@ -174,11 +187,43 @@ clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
return 0;
}
-VLIB_CLI_COMMAND (clear_uri_session_command, static) =
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (clear_session_command, static) =
+{
+ .path = "clear session",
+ .short_help = "clear session thread <thread> session <index>",
+ .function = clear_session_command_fn,
+};
+/* *INDENT-ON* */
+
+static clib_error_t *
+session_enable_disable_fn (vlib_main_t * vm, unformat_input_t * input,
+ vlib_cli_command_t * cmd)
+{
+ u8 is_en = 1;
+
+ while (unformat_check_input (input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (input, "enable"))
+ is_en = 1;
+ else if (unformat (input, "disable"))
+ is_en = 0;
+ else
+ return clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, input);
+ }
+
+ return vnet_session_enable_disable (vm, is_en);
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (session_enable_disable_command, static) =
{
-.path = "clear session",.short_help =
- "clear session thread <thread> session <index>",.function =
- clear_session_command_fn,};
+ .path = "session",
+ .short_help = "session [enable|disable]",
+ .function = session_enable_disable_fn,
+};
+/* *INDENT-ON* */
/*
* fd.io coding-style-patch-verification: ON