aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/session/application_local.c2
-rw-r--r--src/vnet/session/session.api1
-rw-r--r--src/vnet/session/session.c26
-rw-r--r--src/vnet/session/session.h20
-rw-r--r--src/vnet/session/session_api.c6
-rw-r--r--src/vnet/session/session_cli.c16
-rw-r--r--src/vnet/session/session_table.c3
-rw-r--r--src/vnet/session/session_table.h2
-rw-r--r--src/vnet/session/transport.c112
-rw-r--r--src/vnet/session/transport.h14
-rw-r--r--src/vnet/session/transport_types.h3
-rw-r--r--src/vnet/tcp/tcp.c2
-rw-r--r--src/vnet/tls/tls.c2
-rw-r--r--src/vnet/udp/udp.c4
14 files changed, 136 insertions, 77 deletions
diff --git a/src/vnet/session/application_local.c b/src/vnet/session/application_local.c
index cc02026e3bb..e2c1082d0b7 100644
--- a/src/vnet/session/application_local.c
+++ b/src/vnet/session/application_local.c
@@ -558,6 +558,8 @@ static const transport_proto_vft_t cut_thru_proto = {
.format_listener = format_ct_listener,
.format_connection = format_ct_session,
.transport_options = {
+ .name = "ct",
+ .short_name = "C",
.tx_type = TRANSPORT_TX_INTERNAL,
.service_type = TRANSPORT_SERVICE_APP,
},
diff --git a/src/vnet/session/session.api b/src/vnet/session/session.api
index 4ff6367fa27..905ab5630d9 100644
--- a/src/vnet/session/session.api
+++ b/src/vnet/session/session.api
@@ -23,7 +23,6 @@ enum transport_proto : u8
{
TRANSPORT_PROTO_API_TCP,
TRANSPORT_PROTO_API_UDP,
- TRANSPORT_PROTO_API_SCTP,
TRANSPORT_PROTO_API_NONE,
TRANSPORT_PROTO_API_TLS,
TRANSPORT_PROTO_API_UDPC,
diff --git a/src/vnet/session/session.c b/src/vnet/session/session.c
index bd69f752de4..fa4cd85e5e4 100644
--- a/src/vnet/session/session.c
+++ b/src/vnet/session/session.c
@@ -1469,12 +1469,6 @@ static session_fifo_rx_fn *session_tx_fns[TRANSPORT_TX_N_FNS] = {
};
/* *INDENT-ON* */
-/**
- * Initialize session layer for given transport proto and ip version
- *
- * Allocates per session type (transport proto + ip version) data structures
- * and adds arc from session queue node to session type output node.
- */
void
session_register_transport (transport_proto_t transport_proto,
const transport_proto_vft_t * vft, u8 is_ip4,
@@ -1505,6 +1499,24 @@ session_register_transport (transport_proto_t transport_proto,
session_tx_fns[vft->transport_options.tx_type];
}
+transport_proto_t
+session_add_transport_proto (void)
+{
+ session_main_t *smm = &session_main;
+ session_worker_t *wrk;
+ u32 thread;
+
+ smm->last_transport_proto_type += 1;
+
+ for (thread = 0; thread < vec_len (smm->wrk); thread++)
+ {
+ wrk = session_main_get_worker (thread);
+ vec_validate (wrk->session_to_enqueue, smm->last_transport_proto_type);
+ }
+
+ return smm->last_transport_proto_type;
+}
+
transport_connection_t *
session_get_transport (session_t * s)
{
@@ -1558,6 +1570,7 @@ session_manager_main_enable (vlib_main_t * vm)
if (num_threads < 1)
return clib_error_return (0, "n_thread_stacks not set");
+ smm->last_transport_proto_type = TRANSPORT_PROTO_QUIC;
/* Allocate cache line aligned worker contexts */
vec_validate_aligned (smm->wrk, num_threads - 1, CLIB_CACHE_LINE_BYTES);
@@ -1570,6 +1583,7 @@ session_manager_main_enable (vlib_main_t * vm)
wrk->vm = vlib_mains[i];
wrk->last_vlib_time = vlib_time_now (vlib_mains[i]);
wrk->last_vlib_us_time = wrk->last_vlib_time * CLIB_US_TIME_FREQ;
+ vec_validate (wrk->session_to_enqueue, smm->last_transport_proto_type);
if (num_threads > 1)
clib_rwlock_init (&smm->wrk[i].peekers_rw_locks);
diff --git a/src/vnet/session/session.h b/src/vnet/session/session.h
index 486c976cdf5..0a72f97a2f8 100644
--- a/src/vnet/session/session.h
+++ b/src/vnet/session/session.h
@@ -91,7 +91,7 @@ typedef struct session_worker_
vlib_main_t *vm;
/** Per-proto vector of sessions to enqueue */
- u32 *session_to_enqueue[TRANSPORT_N_PROTO];
+ u32 **session_to_enqueue;
/** Context for session tx */
session_tx_context_t ctx;
@@ -158,6 +158,8 @@ typedef struct session_main_
* Trade memory for speed, for now */
u32 *session_type_to_next;
+ transport_proto_t last_transport_proto_type;
+
/*
* Config parameters
*/
@@ -203,6 +205,9 @@ extern vlib_node_registration_t session_queue_pre_input_node;
#define SESSION_Q_PROCESS_FLUSH_FRAMES 1
#define SESSION_Q_PROCESS_STOP 2
+#define TRANSPORT_PROTO_INVALID (session_main.last_transport_proto_type + 1)
+#define TRANSPORT_N_PROTOS (session_main.last_transport_proto_type + 1)
+
static inline session_evt_elt_t *
session_evt_elt_alloc (session_worker_t * wrk)
{
@@ -459,9 +464,22 @@ void session_transport_closed_notify (transport_connection_t * tc);
void session_transport_reset_notify (transport_connection_t * tc);
int session_stream_accept (transport_connection_t * tc, u32 listener_index,
u32 thread_index, u8 notify);
+/**
+ * Initialize session layer for given transport proto and ip version
+ *
+ * Allocates per session type (transport proto + ip version) data structures
+ * and adds arc from session queue node to session type output node.
+ *
+ * @param transport_proto transport proto to be registered
+ * @param vft virtual function table for transport
+ * @param is_ip4 flag that indicates if transports uses ipv4
+ * as underlying network layer
+ * @param output_node output node for transport
+ */
void session_register_transport (transport_proto_t transport_proto,
const transport_proto_vft_t * vft, u8 is_ip4,
u32 output_node);
+transport_proto_t session_add_transport_proto (void);
int session_tx_fifo_peek_bytes (transport_connection_t * tc, u8 * buffer,
u32 offset, u32 max_bytes);
u32 session_tx_fifo_dequeue_drop (transport_connection_t * tc, u32 max_bytes);
diff --git a/src/vnet/session/session_api.c b/src/vnet/session/session_api.c
index eb5b2c36f99..88deafe13e5 100644
--- a/src/vnet/session/session_api.c
+++ b/src/vnet/session/session_api.c
@@ -74,8 +74,6 @@ api_session_transport_proto_decode (const vl_api_transport_proto_t * api_tp)
return TRANSPORT_PROTO_TCP;
case TRANSPORT_PROTO_API_UDP:
return TRANSPORT_PROTO_UDP;
- case TRANSPORT_PROTO_API_SCTP:
- return TRANSPORT_PROTO_SCTP;
case TRANSPORT_PROTO_API_TLS:
return TRANSPORT_PROTO_TLS;
case TRANSPORT_PROTO_API_UDPC:
@@ -96,8 +94,6 @@ api_session_transport_proto_encode (const transport_proto_t tp)
return TRANSPORT_PROTO_API_TCP;
case TRANSPORT_PROTO_UDP:
return TRANSPORT_PROTO_API_UDP;
- case TRANSPORT_PROTO_SCTP:
- return TRANSPORT_PROTO_API_SCTP;
case TRANSPORT_PROTO_TLS:
return TRANSPORT_PROTO_API_TLS;
case TRANSPORT_PROTO_UDPC:
@@ -1517,7 +1513,7 @@ vl_api_session_rules_dump_t_handler (vl_api_one_map_server_dump_t * mp)
/* *INDENT-OFF* */
session_table_foreach (st, ({
- for (tp = 0; tp < TRANSPORT_N_PROTO; tp++)
+ for (tp = 0; tp < TRANSPORT_N_PROTOS; tp++)
{
send_session_rules_table_details (&st->session_rules[tp],
st->active_fib_proto, tp,
diff --git a/src/vnet/session/session_cli.c b/src/vnet/session/session_cli.c
index aba1c610e18..682249ae60f 100644
--- a/src/vnet/session/session_cli.c
+++ b/src/vnet/session/session_cli.c
@@ -372,7 +372,7 @@ session_cli_filter_check (session_t * s, session_state_t * states,
check_transport:
- if (tp != TRANSPORT_N_PROTO && session_get_transport_proto (s) != tp)
+ if (tp != TRANSPORT_PROTO_INVALID && session_get_transport_proto (s) != tp)
return 0;
return 1;
@@ -398,7 +398,7 @@ session_cli_show_session_filter (vlib_main_t * vm, u32 thread_index,
pool = wrk->sessions;
- if (tp == TRANSPORT_N_PROTO && states == 0 && !verbose
+ if (tp == TRANSPORT_PROTO_INVALID && states == 0 && !verbose
&& (start == 0 && end == ~0))
{
vlib_cli_output (vm, "Thread %d: %u sessions", thread_index,
@@ -473,14 +473,6 @@ session_cli_show_events (vlib_main_t * vm, u32 thread_index)
}
static void
-session_cli_print_transport_protos (vlib_main_t * vm)
-{
-#define _(sym, str, sstr) vlib_cli_output (vm, str);
- foreach_transport_proto
-#undef _
-}
-
-static void
session_cli_print_session_states (vlib_main_t * vm)
{
#define _(sym, str) vlib_cli_output (vm, str);
@@ -495,7 +487,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
u8 one_session = 0, do_listeners = 0, sst, do_elog = 0, do_filter = 0;
u32 track_index, thread_index = 0, start = 0, end = ~0, session_index;
unformat_input_t _line_input, *line_input = &_line_input;
- transport_proto_t transport_proto = TRANSPORT_N_PROTO;
+ transport_proto_t transport_proto = TRANSPORT_PROTO_INVALID;
session_state_t state = SESSION_N_STATES, *states = 0;
session_main_t *smm = &session_main;
clib_error_t *error = 0;
@@ -585,7 +577,7 @@ show_session_command_fn (vlib_main_t * vm, unformat_input_t * input,
do_elog = 1;
else if (unformat (line_input, "protos"))
{
- session_cli_print_transport_protos (vm);
+ vlib_cli_output (vm, "%U", format_transport_protos);
goto done;
}
else if (unformat (line_input, "states"))
diff --git a/src/vnet/session/session_table.c b/src/vnet/session/session_table.c
index d619fa580d8..d0b576fda7b 100644
--- a/src/vnet/session/session_table.c
+++ b/src/vnet/session/session_table.c
@@ -129,7 +129,8 @@ session_table_init (session_table_t * slt, u8 fib_proto)
clib_bihash_init2_48_8 (a);
}
- for (i = 0; i < TRANSPORT_N_PROTO; i++)
+ vec_validate (slt->session_rules, TRANSPORT_N_PROTOS - 1);
+ for (i = 0; i < TRANSPORT_N_PROTOS; i++)
session_rules_table_init (&slt->session_rules[i]);
}
diff --git a/src/vnet/session/session_table.h b/src/vnet/session/session_table.h
index d3af566a77d..cf4e9698e3a 100644
--- a/src/vnet/session/session_table.h
+++ b/src/vnet/session/session_table.h
@@ -37,7 +37,7 @@ typedef struct _session_lookup_table
/**
* Per fib proto and transport proto session rules tables
*/
- session_rules_table_t session_rules[TRANSPORT_N_PROTO];
+ session_rules_table_t *session_rules;
/** Flag that indicates if table has local scope */
u8 is_local;
diff --git a/src/vnet/session/transport.c b/src/vnet/session/transport.c
index 16f4f02cbe3..d9a54fff64f 100644
--- a/src/vnet/session/transport.c
+++ b/src/vnet/session/transport.c
@@ -46,18 +46,12 @@ u8 *
format_transport_proto (u8 * s, va_list * args)
{
u32 transport_proto = va_arg (*args, u32);
- switch (transport_proto)
- {
-#define _(sym, str, sstr) \
- case TRANSPORT_PROTO_ ## sym: \
- s = format (s, str); \
- break;
- foreach_transport_proto
-#undef _
- default:
- s = format (s, "UNKNOWN");
- break;
- }
+
+ if (tp_vfts[transport_proto].transport_options.name)
+ s = format (s, "%s", tp_vfts[transport_proto].transport_options.name);
+ else
+ s = format (s, "n/a");
+
return s;
}
@@ -65,18 +59,14 @@ u8 *
format_transport_proto_short (u8 * s, va_list * args)
{
u32 transport_proto = va_arg (*args, u32);
- switch (transport_proto)
- {
-#define _(sym, str, sstr) \
- case TRANSPORT_PROTO_ ## sym: \
- s = format (s, sstr); \
- break;
- foreach_transport_proto
-#undef _
- default:
- s = format (s, "?");
- break;
- }
+ char *short_name;
+
+ short_name = tp_vfts[transport_proto].transport_options.short_name;
+ if (short_name)
+ s = format (s, "%s", short_name);
+ else
+ s = format (s, "NA");
+
return s;
}
@@ -158,23 +148,29 @@ uword
unformat_transport_proto (unformat_input_t * input, va_list * args)
{
u32 *proto = va_arg (*args, u32 *);
+ transport_proto_vft_t *tp_vft;
u8 longest_match = 0, match;
- char *str_match = 0;
-
-#define _(sym, str, sstr) \
- if (unformat_transport_str_match (input, str)) \
- { \
- match = strlen (str); \
- if (match > longest_match) \
- { \
- *proto = TRANSPORT_PROTO_ ## sym; \
- longest_match = match; \
- str_match = str; \
- } \
+ char *str, *str_match = 0;
+ transport_proto_t tp;
+
+ for (tp = 0; tp < vec_len (tp_vfts); tp++)
+ {
+ tp_vft = &tp_vfts[tp];
+ str = tp_vft->transport_options.name;
+ if (!str)
+ continue;
+ if (unformat_transport_str_match (input, str))
+ {
+ match = strlen (str);
+ if (match > longest_match)
+ {
+ *proto = tp;
+ longest_match = match;
+ str_match = str;
+ }
+ }
}
- foreach_transport_proto
-#undef _
- if (longest_match)
+ if (longest_match)
{
unformat (input, str_match);
return 1;
@@ -183,6 +179,17 @@ unformat_transport_proto (unformat_input_t * input, va_list * args)
return 0;
}
+u8 *
+format_transport_protos (u8 * s, va_list * args)
+{
+ transport_proto_vft_t *tp_vft;
+
+ vec_foreach (tp_vft, tp_vfts)
+ s = format (s, "%s\n", tp_vft->transport_options.name);
+
+ return s;
+}
+
u32
transport_endpoint_lookup (transport_endpoint_table_t * ht, u8 proto,
ip46_address_t * ip, u16 port)
@@ -228,15 +235,6 @@ transport_endpoint_table_del (transport_endpoint_table_t * ht, u8 proto,
clib_bihash_add_del_24_8 (ht, &kv, 0);
}
-/**
- * Register transport virtual function table.
- *
- * @param transport_proto - transport protocol type (i.e., TCP, UDP ..)
- * @param vft - virtual function table for transport proto
- * @param fib_proto - network layer protocol
- * @param output_node - output node index that session layer will hand off
- * buffers to, for requested fib proto
- */
void
transport_register_protocol (transport_proto_t transport_proto,
const transport_proto_vft_t * vft,
@@ -250,6 +248,24 @@ transport_register_protocol (transport_proto_t transport_proto,
session_register_transport (transport_proto, vft, is_ip4, output_node);
}
+transport_proto_t
+transport_register_new_protocol (const transport_proto_vft_t * vft,
+ fib_protocol_t fib_proto, u32 output_node)
+{
+ transport_proto_t transport_proto;
+ u8 is_ip4;
+
+ transport_proto = session_add_transport_proto ();
+ is_ip4 = fib_proto == FIB_PROTOCOL_IP4;
+
+ vec_validate (tp_vfts, transport_proto);
+ tp_vfts[transport_proto] = *vft;
+
+ session_register_transport (transport_proto, vft, is_ip4, output_node);
+
+ return transport_proto;
+}
+
/**
* Get transport virtual function table
*
diff --git a/src/vnet/session/transport.h b/src/vnet/session/transport.h
index 3c4e15a9a6b..e5c09cd767d 100644
--- a/src/vnet/session/transport.h
+++ b/src/vnet/session/transport.h
@@ -27,6 +27,8 @@
typedef struct _transport_options_t
{
+ char *name;
+ char *short_name;
transport_tx_fn_type_t tx_type;
transport_service_type_t service_type;
u8 half_open_has_fifos;
@@ -195,9 +197,21 @@ transport_connection_deschedule (transport_connection_t * tc)
void transport_connection_reschedule (transport_connection_t * tc);
+/**
+ * Register transport virtual function table.
+ *
+ * @param transport_proto - transport protocol type (i.e., TCP, UDP ..)
+ * @param vft - virtual function table for transport proto
+ * @param fib_proto - network layer protocol
+ * @param output_node - output node index that session layer will hand off
+ * buffers to, for requested fib proto
+ */
void transport_register_protocol (transport_proto_t transport_proto,
const transport_proto_vft_t * vft,
fib_protocol_t fib_proto, u32 output_node);
+transport_proto_t
+transport_register_new_protocol (const transport_proto_vft_t * vft,
+ fib_protocol_t fib_proto, u32 output_node);
transport_proto_vft_t *transport_protocol_get_vft (transport_proto_t tp);
void transport_update_time (clib_time_type_t time_now, u8 thread_index);
diff --git a/src/vnet/session/transport_types.h b/src/vnet/session/transport_types.h
index 323d261ad89..44934daf0f0 100644
--- a/src/vnet/session/transport_types.h
+++ b/src/vnet/session/transport_types.h
@@ -151,7 +151,6 @@ STATIC_ASSERT (sizeof (transport_connection_t) <= 128,
#define foreach_transport_proto \
_(TCP, "tcp", "T") \
_(UDP, "udp", "U") \
- _(SCTP, "sctp", "S") \
_(NONE, "ct", "C") \
_(TLS, "tls", "J") \
_(UDPC, "udpc", "U") \
@@ -162,7 +161,6 @@ typedef enum _transport_proto
#define _(sym, str, sstr) TRANSPORT_PROTO_ ## sym,
foreach_transport_proto
#undef _
- TRANSPORT_N_PROTO
} transport_proto_t;
u8 *format_transport_proto (u8 * s, va_list * args);
@@ -172,6 +170,7 @@ u8 *format_transport_listen_connection (u8 * s, va_list * args);
u8 *format_transport_half_open_connection (u8 * s, va_list * args);
uword unformat_transport_proto (unformat_input_t * input, va_list * args);
+u8 *format_transport_protos (u8 * s, va_list * args);
#define foreach_transport_endpoint_fields \
_(ip46_address_t, ip) /**< ip address in net order */ \
diff --git a/src/vnet/tcp/tcp.c b/src/vnet/tcp/tcp.c
index 8a09b565ffa..25a3a446463 100644
--- a/src/vnet/tcp/tcp.c
+++ b/src/vnet/tcp/tcp.c
@@ -1548,6 +1548,8 @@ const static transport_proto_vft_t tcp_proto = {
.format_listener = format_tcp_listener_session,
.format_half_open = format_tcp_half_open_session,
.transport_options = {
+ .name = "tcp",
+ .short_name = "T",
.tx_type = TRANSPORT_TX_PEEK,
.service_type = TRANSPORT_SERVICE_VC,
},
diff --git a/src/vnet/tls/tls.c b/src/vnet/tls/tls.c
index 73a54c86282..88ce3591bb6 100644
--- a/src/vnet/tls/tls.c
+++ b/src/vnet/tls/tls.c
@@ -869,6 +869,8 @@ static const transport_proto_vft_t tls_proto = {
.get_transport_endpoint = tls_transport_endpoint_get,
.get_transport_listener_endpoint = tls_transport_listener_endpoint_get,
.transport_options = {
+ .name = "tls",
+ .short_name = "J",
.tx_type = TRANSPORT_TX_INTERNAL,
.service_type = TRANSPORT_SERVICE_APP,
},
diff --git a/src/vnet/udp/udp.c b/src/vnet/udp/udp.c
index 109f4683e7f..8fa1147b030 100644
--- a/src/vnet/udp/udp.c
+++ b/src/vnet/udp/udp.c
@@ -361,6 +361,8 @@ static const transport_proto_vft_t udp_proto = {
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
.transport_options = {
+ .name = "udp",
+ .short_name = "U",
.tx_type = TRANSPORT_TX_DGRAM,
.service_type = TRANSPORT_SERVICE_CL,
},
@@ -415,6 +417,8 @@ static const transport_proto_vft_t udpc_proto = {
.format_half_open = format_udp_half_open_session,
.format_listener = format_udp_listener_session,
.transport_options = {
+ .name = "udpc",
+ .short_name = "U",
.tx_type = TRANSPORT_TX_DGRAM,
.service_type = TRANSPORT_SERVICE_VC,
.half_open_has_fifos = 1