aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet/session
diff options
context:
space:
mode:
authorDave Barach <dbarach@cisco.com>2017-06-26 11:35:07 -0400
committerFlorin Coras <florin.coras@gmail.com>2017-07-11 15:40:19 +0000
commit2c25a62cc1cc4937165de740a3b32d78429c72d6 (patch)
treeb860025298501460e21cf8e5722c6155f87495ec /src/vnet/session
parent8af1b2fdecc883eadfec6b91434adc6044e24cb2 (diff)
Horizontal (nSessions) scaling draft
- Data structure preallocation. - Input state machine fixes for mid-stream 3-way handshake retries. - Batch connections in the builtin_client - Multiple private fifo segment support - Fix elog simultaneous event type registration - Fix sacks when segment hole is added after highest sacked - Add "accepting" session state for sessions pending accept - Add ssvm non-recursive locking - Estimate RTT for syn-ack - Don't init fifo pointers. We're using relative offsets for ooo segments - CLI to dump individual session Change-Id: Ie0598563fd246537bafba4feed7985478ea1d415 Signed-off-by: Dave Barach <dbarach@cisco.com> Signed-off-by: Florin Coras <fcoras@cisco.com>
Diffstat (limited to 'src/vnet/session')
-rw-r--r--src/vnet/session/application.c2
-rw-r--r--src/vnet/session/application_interface.c21
-rw-r--r--src/vnet/session/application_interface.h12
-rw-r--r--src/vnet/session/node.c23
-rw-r--r--src/vnet/session/segment_manager.c26
-rw-r--r--src/vnet/session/segment_manager.h4
-rw-r--r--src/vnet/session/session.c72
-rw-r--r--src/vnet/session/session.h30
-rwxr-xr-xsrc/vnet/session/session_cli.c99
-rw-r--r--src/vnet/session/transport.h6
10 files changed, 198 insertions, 97 deletions
diff --git a/src/vnet/session/application.c b/src/vnet/session/application.c
index 3cc56f3794f..8a953719f81 100644
--- a/src/vnet/session/application.c
+++ b/src/vnet/session/application.c
@@ -174,6 +174,8 @@ application_init (application_t * app, u32 api_client_index, u64 * options,
props->preallocated_fifo_pairs = options[APP_OPTIONS_PREALLOC_FIFO_PAIRS];
props->use_private_segment = options[APP_OPTIONS_FLAGS]
& APP_OPTIONS_FLAGS_BUILTIN_APP;
+ props->private_segment_count = options[APP_OPTIONS_PRIVATE_SEGMENT_COUNT];
+ props->private_segment_size = options[APP_OPTIONS_PRIVATE_SEGMENT_SIZE];
first_seg_size = options[SESSION_OPTIONS_SEGMENT_SIZE];
if ((rv = segment_manager_init (sm, props, first_seg_size)))
diff --git a/src/vnet/session/application_interface.c b/src/vnet/session/application_interface.c
index 338ae857dab..566a52d7984 100644
--- a/src/vnet/session/application_interface.c
+++ b/src/vnet/session/application_interface.c
@@ -275,27 +275,6 @@ vnet_application_detach (vnet_app_detach_args_t * a)
return 0;
}
-session_type_t
-session_type_from_proto_and_ip (session_api_proto_t proto, u8 is_ip4)
-{
- if (proto == SESSION_PROTO_TCP)
- {
- if (is_ip4)
- return SESSION_TYPE_IP4_TCP;
- else
- return SESSION_TYPE_IP6_TCP;
- }
- else
- {
- if (is_ip4)
- return SESSION_TYPE_IP4_UDP;
- else
- return SESSION_TYPE_IP6_UDP;
- }
-
- return SESSION_N_TYPES;
-}
-
int
vnet_bind_uri (vnet_bind_args_t * a)
{
diff --git a/src/vnet/session/application_interface.h b/src/vnet/session/application_interface.h
index 4d6f9def026..ed9f89b361e 100644
--- a/src/vnet/session/application_interface.h
+++ b/src/vnet/session/application_interface.h
@@ -22,12 +22,6 @@
#include <vnet/session/application.h>
#include <vnet/session/transport.h>
-typedef enum _session_api_proto
-{
- SESSION_PROTO_TCP,
- SESSION_PROTO_UDP
-} session_api_proto_t;
-
typedef struct _vnet_app_attach_args_t
{
/** Binary API client index */
@@ -65,7 +59,7 @@ typedef struct _vnet_bind_args_t
struct
{
transport_endpoint_t tep;
- session_api_proto_t proto;
+ transport_proto_t proto;
};
};
@@ -98,7 +92,7 @@ typedef struct _vnet_connect_args
struct
{
transport_endpoint_t tep;
- session_api_proto_t proto;
+ transport_proto_t proto;
};
};
u32 app_index;
@@ -120,6 +114,8 @@ typedef enum
APP_EVT_QUEUE_SIZE,
APP_OPTIONS_FLAGS,
APP_OPTIONS_PREALLOC_FIFO_PAIRS,
+ APP_OPTIONS_PRIVATE_SEGMENT_COUNT,
+ APP_OPTIONS_PRIVATE_SEGMENT_SIZE,
SESSION_OPTIONS_SEGMENT_SIZE,
SESSION_OPTIONS_ADD_SEGMENT_SIZE,
SESSION_OPTIONS_RX_FIFO_SIZE,
diff --git a/src/vnet/session/node.c b/src/vnet/session/node.c
index b24f5fd994d..56e626379a5 100644
--- a/src/vnet/session/node.c
+++ b/src/vnet/session/node.c
@@ -378,24 +378,12 @@ session_tx_fifo_dequeue_and_snd (vlib_main_t * vm, vlib_node_runtime_t * node,
n_tx_pkts, 0);
}
-stream_session_t *
-session_event_get_session (session_fifo_event_t * e0, u8 thread_index)
+always_inline stream_session_t *
+session_event_get_session (session_fifo_event_t * e, u8 thread_index)
{
- svm_fifo_t *f0;
- stream_session_t *s0;
- u32 session_index0;
-
- f0 = e0->fifo;
- session_index0 = f0->master_session_index;
-
- /* $$$ add multiple event queues, per vpp worker thread */
- ASSERT (f0->master_thread_index == thread_index);
-
- s0 = stream_session_get_if_valid (session_index0, thread_index);
-
- ASSERT (s0 == 0 || s0->thread_index == thread_index);
-
- return s0;
+ ASSERT (e->fifo->master_thread_index == thread_index);
+ return stream_session_get_if_valid (e->fifo->master_session_index,
+ thread_index);
}
void
@@ -569,7 +557,6 @@ skip_dequeue:
case FIFO_EVENT_BUILTIN_RX:
s0 = session_event_get_session (e0, my_thread_index);
svm_fifo_unset_event (s0->server_rx_fifo);
- /* Get session's server */
app = application_get (s0->app_index);
app->cb_fns.builtin_server_rx_callback (s0);
break;
diff --git a/src/vnet/session/segment_manager.c b/src/vnet/session/segment_manager.c
index dcef62615d2..262b7faab92 100644
--- a/src/vnet/session/segment_manager.c
+++ b/src/vnet/session/segment_manager.c
@@ -30,7 +30,7 @@ segment_manager_t *segment_managers = 0;
/**
* Process private segment index
*/
-u32 private_segment_index = ~0;
+u32 *private_segment_indices;
/**
* Default fifo and segment size. TODO config.
@@ -70,7 +70,8 @@ session_manager_add_segment_i (segment_manager_t * sm, u32 segment_size,
return VNET_API_ERROR_SVM_SEGMENT_CREATE_FAIL;
}
- vec_add1 (sm->segment_indices, ca->new_segment_index);
+ vec_append (sm->segment_indices, ca->new_segment_indices);
+ vec_free (ca->new_segment_indices);
return 0;
}
@@ -111,22 +112,23 @@ static void
{
svm_fifo_segment_create_args_t _a, *a = &_a;
- if (private_segment_index != ~0)
+ if (private_segment_indices)
return;
memset (a, 0, sizeof (*a));
a->segment_name = "process-private-segment";
a->segment_size = ~0;
- a->new_segment_index = ~0;
a->rx_fifo_size = props->rx_fifo_size;
a->tx_fifo_size = props->tx_fifo_size;
a->preallocated_fifo_pairs = props->preallocated_fifo_pairs;
+ a->private_segment_count = props->private_segment_count;
+ a->private_segment_size = props->private_segment_size;
if (svm_fifo_segment_create_process_private (a))
clib_warning ("Failed to create process private segment");
- private_segment_index = a->new_segment_index;
- ASSERT (private_segment_index != ~0);
+ private_segment_indices = a->new_segment_indices;
+ ASSERT (vec_len (private_segment_indices));
}
/**
@@ -156,10 +158,10 @@ segment_manager_init (segment_manager_t * sm,
}
else
{
- if (private_segment_index == ~0)
+ if (vec_len (private_segment_indices) == 0)
segment_manager_alloc_process_private_segment (properties);
- ASSERT (private_segment_index != ~0);
- vec_add1 (sm->segment_indices, private_segment_index);
+ ASSERT (vec_len (private_segment_indices));
+ vec_append (sm->segment_indices, private_segment_indices);
}
clib_spinlock_init (&sm->lockp);
@@ -320,7 +322,7 @@ again:
/* See if we're supposed to create another segment */
if (*server_rx_fifo == 0)
{
- if (sm->properties->add_segment)
+ if (sm->properties->add_segment && !sm->properties->use_private_segment)
{
if (added_a_segment)
{
@@ -379,6 +381,10 @@ segment_manager_dealloc_fifos (u32 svm_segment_index, svm_fifo_t * rx_fifo,
svm_fifo_segment_free_fifo (fifo_segment, tx_fifo,
FIFO_SEGMENT_TX_FREELIST);
+ /* Don't try to delete process-private segments */
+ if (sm->properties->private_segment_count > 0)
+ return;
+
/* Remove segment only if it holds no fifos and not the first */
if (sm->segment_indices[0] != svm_segment_index
&& !svm_fifo_segment_has_fifos (fifo_segment))
diff --git a/src/vnet/session/segment_manager.h b/src/vnet/session/segment_manager.h
index df38d2b35f9..41abeb22947 100644
--- a/src/vnet/session/segment_manager.h
+++ b/src/vnet/session/segment_manager.h
@@ -39,6 +39,10 @@ typedef struct _segment_manager_properties
/** Use private memory segment instead of shared memory */
u8 use_private_segment;
+
+ /** Use one or more private mheaps, instead of the global heap */
+ u32 private_segment_count;
+ u32 private_segment_size;
} segment_manager_properties_t;
typedef struct _segment_manager
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index fe198044db9..0a86d563f0e 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -198,21 +198,28 @@ stream_session_lookup_listener4 (ip4_address_t * lcl, u16 lcl_port, u8 proto)
*/
stream_session_t *
stream_session_lookup4 (ip4_address_t * lcl, ip4_address_t * rmt,
- u16 lcl_port, u16 rmt_port, u8 proto,
- u32 my_thread_index)
+ u16 lcl_port, u16 rmt_port, u8 proto)
{
session_manager_main_t *smm = &session_manager_main;
session_kv4_t kv4;
+ stream_session_t *s;
int rv;
/* Lookup session amongst established ones */
make_v4_ss_kv (&kv4, lcl, rmt, lcl_port, rmt_port, proto);
rv = clib_bihash_search_inline_16_8 (&smm->v4_session_hash, &kv4);
if (rv == 0)
- return stream_session_get_tsi (kv4.value, my_thread_index);
+ return stream_session_get_from_handle (kv4.value);
/* If nothing is found, check if any listener is available */
- return stream_session_lookup_listener4 (lcl, lcl_port, proto);
+ if ((s = stream_session_lookup_listener4 (lcl, lcl_port, proto)))
+ return s;
+
+ /* Finally, try half-open connections */
+ rv = clib_bihash_search_inline_16_8 (&smm->v4_half_open_hash, &kv4);
+ if (rv == 0)
+ return stream_session_get_from_handle (kv4.value);
+ return 0;
}
stream_session_t *
@@ -242,20 +249,27 @@ stream_session_lookup_listener6 (ip6_address_t * lcl, u16 lcl_port, u8 proto)
* wildcarded local source (listener bound to all interfaces) */
stream_session_t *
stream_session_lookup6 (ip6_address_t * lcl, ip6_address_t * rmt,
- u16 lcl_port, u16 rmt_port, u8 proto,
- u32 my_thread_index)
+ u16 lcl_port, u16 rmt_port, u8 proto)
{
session_manager_main_t *smm = vnet_get_session_manager_main ();
session_kv6_t kv6;
+ stream_session_t *s;
int rv;
make_v6_ss_kv (&kv6, lcl, rmt, lcl_port, rmt_port, proto);
rv = clib_bihash_search_inline_48_8 (&smm->v6_session_hash, &kv6);
if (rv == 0)
- return stream_session_get_tsi (kv6.value, my_thread_index);
+ return stream_session_get_from_handle (kv6.value);
/* If nothing is found, check if any listener is available */
- return stream_session_lookup_listener6 (lcl, lcl_port, proto);
+ if ((s = stream_session_lookup_listener6 (lcl, lcl_port, proto)))
+ return s;
+
+ /* Finally, try half-open connections */
+ rv = clib_bihash_search_inline_48_8 (&smm->v6_half_open_hash, &kv6);
+ if (rv == 0)
+ return stream_session_get_from_handle (kv6.value);
+ return 0;
}
stream_session_t *
@@ -340,7 +354,6 @@ stream_session_lookup_transport4 (ip4_address_t * lcl, ip4_address_t * rmt,
rv = clib_bihash_search_inline_16_8 (&smm->v4_half_open_hash, &kv4);
if (rv == 0)
return tp_vfts[proto].get_half_open (kv4.value & 0xFFFFFFFF);
-
return 0;
}
@@ -390,6 +403,8 @@ stream_session_create_i (segment_manager_t * sm, transport_connection_t * tc,
u32 thread_index = tc->thread_index;
int rv;
+ ASSERT (thread_index == vlib_get_thread_index ());
+
if ((rv = segment_manager_alloc_session_fifos (sm, &server_rx_fifo,
&server_tx_fifo,
&fifo_segment_index)))
@@ -854,6 +869,7 @@ stream_session_accept (transport_connection_t * tc, u32 listener_index,
s->app_index = server->index;
s->listener_index = listener_index;
+ s->session_state = SESSION_STATE_ACCEPTING;
/* Shoulder-tap the server */
if (notify)
@@ -1088,6 +1104,27 @@ session_vpp_event_queue_allocate (session_manager_main_t * smm,
}
}
+session_type_t
+session_type_from_proto_and_ip (transport_proto_t proto, u8 is_ip4)
+{
+ if (proto == TRANSPORT_PROTO_TCP)
+ {
+ if (is_ip4)
+ return SESSION_TYPE_IP4_TCP;
+ else
+ return SESSION_TYPE_IP6_TCP;
+ }
+ else
+ {
+ if (is_ip4)
+ return SESSION_TYPE_IP4_UDP;
+ else
+ return SESSION_TYPE_IP6_UDP;
+ }
+
+ return SESSION_N_TYPES;
+}
+
static clib_error_t *
session_manager_main_enable (vlib_main_t * vm)
{
@@ -1131,14 +1168,13 @@ session_manager_main_enable (vlib_main_t * vm)
session_vpp_event_queue_allocate (smm, i);
/* $$$$ preallocate hack config parameter */
- for (i = 0; i < 200000; i++)
+ for (i = 0; i < smm->preallocated_sessions; i++)
{
- stream_session_t *ss;
+ stream_session_t *ss __attribute__ ((unused));
pool_get_aligned (smm->sessions[0], ss, CLIB_CACHE_LINE_BYTES);
- memset (ss, 0, sizeof (*ss));
}
- for (i = 0; i < 200000; i++)
+ for (i = 0; i < smm->preallocated_sessions; i++)
pool_put_index (smm->sessions[0], i);
clib_bihash_init_16_8 (&smm->v4_session_hash, "v4 session table",
@@ -1208,9 +1244,10 @@ session_manager_main_init (vlib_main_t * vm)
return 0;
}
-VLIB_INIT_FUNCTION (session_manager_main_init)
- static clib_error_t *session_config_fn (vlib_main_t * vm,
- unformat_input_t * input)
+VLIB_INIT_FUNCTION (session_manager_main_init);
+
+static clib_error_t *
+session_config_fn (vlib_main_t * vm, unformat_input_t * input)
{
session_manager_main_t *smm = &session_manager_main;
u32 nitems;
@@ -1224,6 +1261,9 @@ VLIB_INIT_FUNCTION (session_manager_main_init)
else
clib_warning ("event queue length %d too small, ignored", nitems);
}
+ if (unformat (input, "preallocated-sessions %d",
+ &smm->preallocated_sessions))
+ ;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 5fa4225c4ed..b4507d4eaed 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -80,6 +80,10 @@ typedef enum
SESSION_N_TYPES,
} session_type_t;
+
+session_type_t
+session_type_from_proto_and_ip (transport_proto_t proto, u8 is_ip4);
+
/*
* Application session state
*/
@@ -87,6 +91,7 @@ typedef enum
{
SESSION_STATE_LISTENING,
SESSION_STATE_CONNECTING,
+ SESSION_STATE_ACCEPTING,
SESSION_STATE_READY,
SESSION_STATE_CLOSED,
SESSION_STATE_N_STATES,
@@ -211,8 +216,12 @@ struct _session_manager_main
/** Per transport rx function that can either dequeue or peek */
session_fifo_rx_fn *session_tx_fns[SESSION_N_TYPES];
+ /** Session manager is enabled */
u8 is_enabled;
+ /** Preallocate session config parameter */
+ u32 preallocated_sessions;
+
/* Convenience */
vlib_main_t *vlib_main;
vnet_main_t *vnet_main;
@@ -247,13 +256,12 @@ stream_session_t *stream_session_lookup_listener4 (ip4_address_t * lcl,
u16 lcl_port, u8 proto);
stream_session_t *stream_session_lookup4 (ip4_address_t * lcl,
ip4_address_t * rmt, u16 lcl_port,
- u16 rmt_port, u8 proto,
- u32 thread_index);
+ u16 rmt_port, u8 proto);
stream_session_t *stream_session_lookup_listener6 (ip6_address_t * lcl,
u16 lcl_port, u8 proto);
stream_session_t *stream_session_lookup6 (ip6_address_t * lcl,
ip6_address_t * rmt, u16 lcl_port,
- u16 rmt_port, u8, u32 thread_index);
+ u16 rmt_port, u8 proto);
transport_connection_t
* stream_session_lookup_transport4 (ip4_address_t * lcl,
ip4_address_t * rmt, u16 lcl_port,
@@ -277,9 +285,24 @@ stream_session_get_tsi (u64 ti_and_si, u32 thread_index)
ti_and_si & 0xFFFFFFFFULL);
}
+always_inline u8
+stream_session_is_valid (u32 si, u8 thread_index)
+{
+ stream_session_t *s;
+ s = pool_elt_at_index (session_manager_main.sessions[thread_index], si);
+ if (s->thread_index != thread_index || s->session_index != si
+ || s->server_rx_fifo->master_session_index != si
+ || s->server_tx_fifo->master_session_index != si
+ || s->server_rx_fifo->master_thread_index != thread_index
+ || s->server_tx_fifo->master_thread_index != thread_index)
+ return 0;
+ return 1;
+}
+
always_inline stream_session_t *
stream_session_get (u32 si, u32 thread_index)
{
+ ASSERT (stream_session_is_valid (si, thread_index));
return pool_elt_at_index (session_manager_main.sessions[thread_index], si);
}
@@ -292,6 +315,7 @@ stream_session_get_if_valid (u64 si, u32 thread_index)
if (pool_is_free_index (session_manager_main.sessions[thread_index], si))
return 0;
+ ASSERT (stream_session_is_valid (si, thread_index));
return pool_elt_at_index (session_manager_main.sessions[thread_index], si);
}
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index 6b8341aa367..e06bc586be3 100755
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -47,7 +47,8 @@ format_stream_session (u8 * s, va_list * args)
svm_fifo_max_enqueue (ss->server_tx_fifo),
stream_session_get_index (ss));
- if (ss->session_state == SESSION_STATE_READY)
+ if (ss->session_state == SESSION_STATE_READY
+ || ss->session_state == SESSION_STATE_ACCEPTING)
{
s = format (s, "%U", tp_vft->format_connection, ss->connection_index,
ss->thread_index, verbose);
@@ -68,8 +69,9 @@ format_stream_session (u8 * s, va_list * args)
}
else if (ss->session_state == SESSION_STATE_CLOSED)
{
- s = format (s, "[CL] %-40U", tp_vft->format_connection,
- ss->connection_index, ss->thread_index, verbose);
+ s =
+ format (s, "[CL] %U", tp_vft->format_connection, ss->connection_index,
+ ss->thread_index, verbose);
if (verbose == 1)
s = format (s, "%v", str);
if (verbose > 1)
@@ -93,7 +95,13 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
int verbose = 0, i;
stream_session_t *pool;
stream_session_t *s;
- u8 *str = 0;
+ u8 *str = 0, one_session = 0, proto_set = 0, proto = 0;
+ u8 is_ip4 = 0, s_type = 0;
+ ip4_address_t lcl_ip4, rmt_ip4;
+ u32 lcl_port = 0, rmt_port = 0;
+
+ memset (&lcl_ip4, 0, sizeof (lcl_ip4));
+ memset (&rmt_ip4, 0, sizeof (rmt_ip4));
if (!smm->is_enabled)
{
@@ -106,10 +114,43 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (input, "verbose"))
verbose = 1;
+ else if (unformat (input, "tcp"))
+ {
+ proto_set = 1;
+ proto = TRANSPORT_PROTO_TCP;
+ }
+ else if (unformat (input, "%U:%d->%U:%d",
+ unformat_ip4_address, &lcl_ip4, &lcl_port,
+ unformat_ip4_address, &rmt_ip4, &rmt_port))
+ {
+ one_session = 1;
+ is_ip4 = 1;
+ }
+
else
break;
}
+ if (one_session)
+ {
+ if (!proto_set)
+ {
+ vlib_cli_output (vm, "proto not set");
+ return clib_error_return (0, "proto not set");
+ }
+
+ s_type = session_type_from_proto_and_ip (proto, is_ip4);
+ s = stream_session_lookup4 (&lcl_ip4, &rmt_ip4,
+ clib_host_to_net_u16 (lcl_port),
+ clib_host_to_net_u16 (rmt_port), s_type);
+ if (s)
+ vlib_cli_output (vm, "%U", format_stream_session, s, 2);
+ else
+ vlib_cli_output (vm, "session does not exist");
+
+ return 0;
+ }
+
for (i = 0; i < vec_len (smm->sessions); i++)
{
u32 once_per_pool;
@@ -146,6 +187,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
}
else
vlib_cli_output (vm, "Thread %d: no active sessions", i);
+ vec_reset_length (str);
}
vec_free (str);
@@ -161,15 +203,22 @@ VLIB_CLI_COMMAND (show_session_command, static) =
};
/* *INDENT-ON* */
+static int
+clear_session (stream_session_t * s)
+{
+ application_t *server = application_get (s->app_index);
+ server->cb_fns.session_disconnect_callback (s);
+ return 0;
+}
+
static clib_error_t *
clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
vlib_cli_command_t * cmd)
{
session_manager_main_t *smm = &session_manager_main;
- u32 thread_index = 0;
+ u32 thread_index = 0, clear_all = 0;
u32 session_index = ~0;
- stream_session_t *pool, *session;
- application_t *server;
+ stream_session_t **pool, *session;
if (!smm->is_enabled)
{
@@ -182,28 +231,36 @@ clear_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
;
else if (unformat (input, "session %d", &session_index))
;
+ else if (unformat (input, "all"))
+ clear_all = 1;
else
return clib_error_return (0, "unknown input `%U'",
format_unformat_error, input);
}
- if (session_index == ~0)
+ if (!clear_all && session_index == ~0)
return clib_error_return (0, "session <nn> required, but not set.");
- if (thread_index > vec_len (smm->sessions))
- return clib_error_return (0, "thread %d out of range [0-%d]",
- thread_index, vec_len (smm->sessions));
-
- pool = smm->sessions[thread_index];
-
- if (pool_is_free_index (pool, session_index))
- return clib_error_return (0, "session %d not active", session_index);
-
- session = pool_elt_at_index (pool, session_index);
- server = application_get (session->app_index);
+ if (session_index != ~0)
+ {
+ session = stream_session_get_if_valid (session_index, thread_index);
+ if (!session)
+ return clib_error_return (0, "no session %d on thread %d",
+ session_index, thread_index);
+ clear_session (session);
+ }
- /* Disconnect both app and transport */
- server->cb_fns.session_disconnect_callback (session);
+ if (clear_all)
+ {
+ /* *INDENT-OFF* */
+ vec_foreach (pool, smm->sessions)
+ {
+ pool_foreach(session, *pool, ({
+ clear_session (session);
+ }));
+ };
+ /* *INDENT-ON* */
+ }
return 0;
}
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index 561a92575cb..9c38bab9c4f 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -225,6 +225,12 @@ make_v6_ss_kv_from_tc (session_kv6_t * kv, transport_connection_t * t)
t->rmt_port, t->proto);
}
+typedef enum _transport_proto
+{
+ TRANSPORT_PROTO_TCP,
+ TRANSPORT_PROTO_UDP
+} transport_proto_t;
+
typedef struct _transport_endpoint
{
ip46_address_t ip; /** ip address */