aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorin Coras <fcoras@cisco.com>2019-06-27 10:32:27 -0700
committerJohn Lo <loj@cisco.com>2019-06-27 21:30:36 +0000
commitb4ca8b11e4204bb95e47cd4b15f3b7430f160c00 (patch)
treec0140ec90590423f9e4454c687b78495a4b325d9
parent28fa8cbc6c635758db1a885fd5ae2ff8719569c3 (diff)
sctp: add option to enable/disable
Type: feature By default sctp is disabled to avoid wasting cycles. Change-Id: I1e2f764c7168b5c15062efbe5895de93dcc2614e Signed-off-by: Florin Coras <fcoras@cisco.com>
-rw-r--r--MAINTAINERS4
-rw-r--r--src/vnet/sctp/sctp.c99
-rw-r--r--src/vnet/sctp/sctp.h1
-rw-r--r--test/test_sctp.py1
4 files changed, 84 insertions, 21 deletions
diff --git a/MAINTAINERS b/MAINTAINERS
index ad13219c46f..a4051aaea67 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -432,6 +432,10 @@ M: Ole Troan <ot@cisco.com>
M: Paul Vinciguerra <pvinci@vinciconsulting.com>
F: src/vpp-api/python
+VNET SCTP
+I: sctp
+F: src/vnet/sctp
+
THE REST
I: misc
C: Contact vpp-dev Mailing List <vpp-dev@fd.io>
diff --git a/src/vnet/sctp/sctp.c b/src/vnet/sctp/sctp.c
index e5d6cca0fd9..e27ddb6e11b 100644
--- a/src/vnet/sctp/sctp.c
+++ b/src/vnet/sctp/sctp.c
@@ -899,7 +899,7 @@ sctp_main_enable (vlib_main_t * vm)
}
clib_error_t *
-sctp_enable_disable (vlib_main_t * vm, u8 is_en)
+sctp_transport_enable_disable (vlib_main_t * vm, u8 is_en)
{
if (is_en)
{
@@ -942,7 +942,7 @@ sctp_update_time (f64 now, u8 thread_index)
/* *INDENT-OFF* */
static const transport_proto_vft_t sctp_proto = {
- .enable = sctp_enable_disable,
+ .enable = sctp_transport_enable_disable,
.start_listen = sctp_session_bind,
.stop_listen = sctp_session_unbind,
.connect = sctp_session_open,
@@ -966,32 +966,49 @@ static const transport_proto_vft_t sctp_proto = {
/* *INDENT-ON* */
clib_error_t *
-sctp_init (vlib_main_t * vm)
+sctp_enable_disable (vlib_main_t * vm, u8 is_en)
{
- sctp_main_t *tm = vnet_get_sctp_main ();
+ sctp_main_t *sm = vnet_get_sctp_main ();
ip_main_t *im = &ip_main;
ip_protocol_info_t *pi;
- vlib_node_t *node = vlib_get_node_by_name (vm, (u8 *) "sctp4-established");
- tm->sctp4_established_phase_node_index = node->index;
+ vlib_node_t *node;
- node = vlib_get_node_by_name (vm, (u8 *) "sctp6-established");
- tm->sctp6_established_phase_node_index = node->index;
+ if (!sm->is_init && is_en)
+ {
+ node = vlib_get_node_by_name (vm, (u8 *) "sctp4-established");
+ sm->sctp4_established_phase_node_index = node->index;
+
+ node = vlib_get_node_by_name (vm, (u8 *) "sctp6-established");
+ sm->sctp6_established_phase_node_index = node->index;
+
+ sm->is_init = 1;
+
+ /* Register with IP for header parsing */
+ pi = ip_get_protocol_info (im, IP_PROTOCOL_SCTP);
+ if (pi == 0)
+ return clib_error_return (0, "SCTP protocol info AWOL");
+ pi->format_header = format_sctp_header;
+ pi->unformat_pg_edit = unformat_pg_sctp_header;
+
+ /* Register as transport with session layer */
+ transport_register_protocol (TRANSPORT_PROTO_SCTP, &sctp_proto,
+ FIB_PROTOCOL_IP4, sctp4_output_node.index);
+ transport_register_protocol (TRANSPORT_PROTO_SCTP, &sctp_proto,
+ FIB_PROTOCOL_IP6, sctp6_output_node.index);
+ }
- /* Session layer, and by implication SCTP, are disabled by default */
- tm->is_enabled = 0;
+ sctp_transport_enable_disable (vm, is_en);
+ return 0;
+}
- /* Register with IP for header parsing */
- pi = ip_get_protocol_info (im, IP_PROTOCOL_SCTP);
- if (pi == 0)
- return clib_error_return (0, "SCTP protocol info AWOL");
- pi->format_header = format_sctp_header;
- pi->unformat_pg_edit = unformat_pg_sctp_header;
+clib_error_t *
+sctp_init (vlib_main_t * vm)
+{
+ sctp_main_t *sm = vnet_get_sctp_main ();
- /* Register as transport with session layer */
- transport_register_protocol (TRANSPORT_PROTO_SCTP, &sctp_proto,
- FIB_PROTOCOL_IP4, sctp4_output_node.index);
- transport_register_protocol (TRANSPORT_PROTO_SCTP, &sctp_proto,
- FIB_PROTOCOL_IP6, sctp6_output_node.index);
+ /* Session layer, and by implication SCTP, are disabled by default */
+ sm->is_enabled = 0;
+ sm->is_init = 0;
sctp_api_reference ();
@@ -1023,6 +1040,46 @@ VLIB_CLI_COMMAND (show_tcp_punt_command, static) =
};
/* *INDENT-ON* */
+static clib_error_t *
+sctp_fn (vlib_main_t * vm, unformat_input_t * input,
+ vlib_cli_command_t * cmd_arg)
+{
+ unformat_input_t _line_input, *line_input = &_line_input;
+ clib_error_t *error;
+ u8 is_en;
+
+ if (!unformat_user (input, unformat_line_input, line_input))
+ return clib_error_return (0, "expected enable | disable");
+
+ while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT)
+ {
+ if (unformat (line_input, "enable"))
+ is_en = 1;
+ else if (unformat (line_input, "disable"))
+ is_en = 0;
+ else
+ {
+ error = clib_error_return (0, "unknown input `%U'",
+ format_unformat_error, line_input);
+ unformat_free (line_input);
+ return error;
+ }
+ }
+
+ unformat_free (line_input);
+
+ return sctp_enable_disable (vm, is_en);
+}
+
+/* *INDENT-OFF* */
+VLIB_CLI_COMMAND (show_sctp_command, static) =
+{
+ .path = "sctp",
+ .short_help = "sctp [enable | disable]",
+ .function = sctp_fn,
+};
+/* *INDENT-ON* */
+
/*
* fd.io coding-style-patch-verification: ON
*
diff --git a/src/vnet/sctp/sctp.h b/src/vnet/sctp/sctp.h
index 26e69eb797b..5cbe8d63fc9 100644
--- a/src/vnet/sctp/sctp.h
+++ b/src/vnet/sctp/sctp.h
@@ -510,6 +510,7 @@ typedef struct _sctp_main
/* Flag that indicates if stack is on or off */
u8 is_enabled;
+ u8 is_init;
/** Number of preallocated connections */
u32 preallocated_connections;
diff --git a/test/test_sctp.py b/test/test_sctp.py
index e1faa9a0c1d..59dcfd35ded 100644
--- a/test/test_sctp.py
+++ b/test/test_sctp.py
@@ -20,6 +20,7 @@ class TestSCTP(VppTestCase):
def setUp(self):
super(TestSCTP, self).setUp()
self.vapi.session_enable_disable(is_enabled=1)
+ self.vapi.cli("sctp enable")
self.create_loopback_interfaces(2)
table_id = 0