diff options
Diffstat (limited to 'src/vnet/ip/ip46_cli.c')
-rw-r--r-- | src/vnet/ip/ip46_cli.c | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/src/vnet/ip/ip46_cli.c b/src/vnet/ip/ip46_cli.c index 668c650682f..2508f0e8ee6 100644 --- a/src/vnet/ip/ip46_cli.c +++ b/src/vnet/ip/ip46_cli.c @@ -38,6 +38,8 @@ */ #include <vnet/ip/ip.h> +#include <vnet/ip/ip4_reassembly.h> +#include <vnet/ip/ip6_reassembly.h> /** * @file @@ -218,6 +220,87 @@ VLIB_CLI_COMMAND (set_interface_ip_address_command, static) = { }; /* *INDENT-ON* */ +static clib_error_t * +set_reassembly_command_fn (vlib_main_t * vm, + unformat_input_t * input, vlib_cli_command_t * cmd) +{ + vnet_main_t *vnm = vnet_get_main (); + unformat_input_t _line_input, *line_input = &_line_input; + u32 sw_if_index = ~0; + u8 ip4_on = 0; + u8 ip6_on = 0; + + /* Get a line of input. */ + if (!unformat_user (input, unformat_line_input, line_input)) + { + return NULL; + } + + if (!unformat (input, "%U", unformat_vnet_sw_interface, vnm, &sw_if_index)) + { + return clib_error_return (0, "Invalid interface name"); + } + + if (unformat (input, "on")) + { + ip4_on = 1; + ip6_on = 1; + } + else if (unformat (input, "off")) + { + ip4_on = 0; + ip6_on = 0; + } + else if (unformat (input, "ip4")) + { + ip4_on = 1; + ip6_on = 0; + } + else if (unformat (input, "ip6")) + { + ip4_on = 0; + ip6_on = 1; + } + else + { + return clib_error_return (0, "Unknown input `%U'", + format_unformat_error, line_input); + } + + + vnet_api_error_t rv4 = ip4_reass_enable_disable (sw_if_index, ip4_on); + vnet_api_error_t rv6 = ip6_reass_enable_disable (sw_if_index, ip6_on); + if (rv4 && rv6) + { + return clib_error_return (0, + "`ip4_reass_enable_disable' API call failed, rv=%d:%U, " + "`ip6_reass_enable_disable' API call failed, rv=%d:%U", + (int) rv4, format_vnet_api_errno, rv4, + (int) rv6, format_vnet_api_errno, rv6); + } + else if (rv4) + { + return clib_error_return (0, + "`ip4_reass_enable_disable' API call failed, rv=%d:%U", + (int) rv4, format_vnet_api_errno, rv4); + } + else if (rv6) + { + return clib_error_return (0, + "`ip6_reass_enable_disable' API call failed, rv=%d:%U", + (int) rv6, format_vnet_api_errno, rv6); + } + return NULL; +} + +/* *INDENT-OFF* */ +VLIB_CLI_COMMAND (set_reassembly_command, static) = { + .path = "set interface reassembly", + .short_help = "set interface reassembly <interface-name> [on|off|ip4|ip6]", + .function = set_reassembly_command_fn, +}; +/* *INDENT-ON* */ + /* Dummy init function to get us linked in. */ static clib_error_t * ip4_cli_init (vlib_main_t * vm) |