X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fvnet%2Fsctp%2Fsctp.c;h=e27ddb6e11bb257844277d2f9d44c688f4c144c1;hb=1cfcb78940580c8e3645fca0419d32f9286e942d;hp=08285e42ba5c941e0b59e51b8922e0dac8689340;hpb=a5a458f3807f549c2519781c7a08d30cbfce0bf0;p=vpp.git diff --git a/src/vnet/sctp/sctp.c b/src/vnet/sctp/sctp.c index 08285e42ba5..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) { @@ -940,9 +940,9 @@ sctp_update_time (f64 now, u8 thread_index) sctp_flush_frames_to_output (thread_index); } -/* *INDENT OFF* */ -const static transport_proto_vft_t sctp_proto = { - .enable = sctp_enable_disable, +/* *INDENT-OFF* */ +static const transport_proto_vft_t sctp_proto = { + .enable = sctp_transport_enable_disable, .start_listen = sctp_session_bind, .stop_listen = sctp_session_unbind, .connect = sctp_session_open, @@ -958,39 +958,57 @@ const static transport_proto_vft_t sctp_proto = { .format_connection = format_sctp_session, .format_listener = format_sctp_listener_session, .format_half_open = format_sctp_half_open, - .tx_type = TRANSPORT_TX_DEQUEUE, - .service_type = TRANSPORT_SERVICE_VC, + .transport_options = { + .tx_type = TRANSPORT_TX_DEQUEUE, + .service_type = TRANSPORT_SERVICE_VC, + }, }; - -/* *INDENT ON* */ +/* *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 (); @@ -1022,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 *