X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fplugins%2Fnat%2Fnat64_cli.c;h=53152f119961f84220ed449cd93270441a01140b;hb=8feeaff56;hp=d1acca963a1378b365c829003af4d19208d3f5b4;hpb=a3a6ec63d34c98e19b18530c165d09ac61389225;p=vpp.git diff --git a/src/plugins/nat/nat64_cli.c b/src/plugins/nat/nat64_cli.c index d1acca963a1..53152f11996 100644 --- a/src/plugins/nat/nat64_cli.c +++ b/src/plugins/nat/nat64_cli.c @@ -19,6 +19,7 @@ #include #include +#include #include static clib_error_t * @@ -72,7 +73,7 @@ nat64_add_del_pool_addr_command_fn (vlib_main_t * vm, for (i = 0; i < count; i++) { - rv = nat64_add_del_pool_addr (&this_addr, vrf_id, is_add); + rv = nat64_add_del_pool_addr (0, &this_addr, vrf_id, is_add); switch (rv) { @@ -181,22 +182,22 @@ nat64_interface_feature_command_fn (vlib_main_t * vm, case VNET_API_ERROR_NO_SUCH_ENTRY: error = clib_error_return (0, "%U NAT64 feature not enabled.", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + format_vnet_sw_if_index_name, vnm, + sw_if_index); goto done; case VNET_API_ERROR_VALUE_EXIST: error = clib_error_return (0, "%U NAT64 feature already enabled.", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + format_vnet_sw_if_index_name, vnm, + vnm, sw_if_index); goto done; case VNET_API_ERROR_INVALID_VALUE: case VNET_API_ERROR_INVALID_VALUE_2: error = clib_error_return (0, "%U NAT64 feature enable/disable failed.", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + format_vnet_sw_if_index_name, vnm, + sw_if_index); goto done; default: break; @@ -216,22 +217,22 @@ nat64_interface_feature_command_fn (vlib_main_t * vm, case VNET_API_ERROR_NO_SUCH_ENTRY: error = clib_error_return (0, "%U NAT64 feature not enabled.", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + format_vnet_sw_if_index_name, vnm, + sw_if_index); goto done; case VNET_API_ERROR_VALUE_EXIST: error = clib_error_return (0, "%U NAT64 feature already enabled.", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + format_vnet_sw_if_index_name, vnm, + sw_if_index); goto done; case VNET_API_ERROR_INVALID_VALUE: case VNET_API_ERROR_INVALID_VALUE_2: error = clib_error_return (0, "%U NAT64 feature enable/disable failed.", - format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, sw_if_index)); + format_vnet_sw_if_index_name, vnm, + sw_if_index); goto done; default: break; @@ -254,8 +255,8 @@ nat64_cli_interface_walk (snat_interface_t * i, void *ctx) vlib_main_t *vm = ctx; vnet_main_t *vnm = vnet_get_main (); - vlib_cli_output (vm, " %U %s", format_vnet_sw_interface_name, vnm, - vnet_get_sw_interface (vnm, i->sw_if_index), + vlib_cli_output (vm, " %U %s", format_vnet_sw_if_index_name, vnm, + i->sw_if_index, (nat_interface_is_inside (i) && nat_interface_is_outside (i)) ? "in out" : nat_interface_is_inside (i) ? "in" : "out"); @@ -357,7 +358,8 @@ nat64_add_del_static_bib_command_fn (vlib_main_t * goto done; case VNET_API_ERROR_INVALID_VALUE: error = - clib_error_return (0, "Outside addres %U and port %u already in use.", + clib_error_return (0, + "Outside address %U and port %u already in use.", format_ip4_address, &out_addr, out_port); goto done; case VNET_API_ERROR_INVALID_VALUE_2: @@ -450,107 +452,6 @@ done: return error; } -static clib_error_t * -nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - unformat_input_t _line_input, *line_input = &_line_input; - clib_error_t *error = 0; - u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn; - - tcp_trans = nat64_get_tcp_trans_timeout (); - tcp_est = nat64_get_tcp_est_timeout (); - tcp_incoming_syn = nat64_get_tcp_incoming_syn_timeout (); - - if (!unformat_user (input, unformat_line_input, line_input)) - return 0; - - while (unformat_check_input (line_input) != UNFORMAT_END_OF_INPUT) - { - if (unformat (line_input, "udp %u", &timeout)) - { - if (nat64_set_udp_timeout (timeout)) - { - error = clib_error_return (0, "Invalid UDP timeout value"); - goto done; - } - } - else if (unformat (line_input, "icmp %u", &timeout)) - { - if (nat64_set_icmp_timeout (timeout)) - { - error = clib_error_return (0, "Invalid ICMP timeout value"); - goto done; - } - } - else if (unformat (line_input, "tcp-trans %u", &tcp_trans)) - { - if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn)) - { - error = - clib_error_return (0, - "Invalid TCP transitory timeouts value"); - goto done; - } - } - else if (unformat (line_input, "tcp-est %u", &tcp_est)) - { - if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn)) - { - error = - clib_error_return (0, - "Invalid TCP established timeouts value"); - goto done; - } - } - else - if (unformat (line_input, "tcp-incoming-syn %u", &tcp_incoming_syn)) - { - if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn)) - { - error = - clib_error_return (0, - "Invalid TCP incoming SYN timeouts value"); - goto done; - } - } - else if (unformat (line_input, "reset")) - { - nat64_set_udp_timeout (0); - nat64_set_icmp_timeout (0); - nat64_set_tcp_timeouts (0, 0, 0); - } - else - { - error = clib_error_return (0, "unknown input '%U'", - format_unformat_error, line_input); - goto done; - } - } - -done: - unformat_free (line_input); - - return error; -} - -static clib_error_t * -nat64_show_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input, - vlib_cli_command_t * cmd) -{ - vlib_cli_output (vm, "NAT64 session timeouts:"); - vlib_cli_output (vm, " UDP %usec", nat64_get_udp_timeout ()); - vlib_cli_output (vm, " ICMP %usec", nat64_get_icmp_timeout ()); - vlib_cli_output (vm, " TCP transitory %usec", - nat64_get_tcp_trans_timeout ()); - vlib_cli_output (vm, " TCP established %usec", - nat64_get_tcp_est_timeout ()); - vlib_cli_output (vm, " TCP incoming SYN %usec", - nat64_get_tcp_incoming_syn_timeout ()); - - return 0; -} - typedef struct nat64_cli_st_walk_ctx_t_ { vlib_main_t *vm; @@ -943,42 +844,6 @@ VLIB_CLI_COMMAND (show_nat64_bib_command, static) = { .function = nat64_show_bib_command_fn, }; -/*? - * @cliexpar - * @cliexstart{set nat64 timeouts} - * Set NAT64 session timeouts (in seconds). - * To set NAT64 session timeoutes use use: - * vpp# set nat64 timeouts udp 200 icmp 30 tcp-trans 250 tcp-est 7450 - * To reset NAT64 session timeoutes to default values use: - * vpp# set nat64 timeouts reset - * @cliexend -?*/ -VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = { - .path = "set nat64 timeouts", - .short_help = "set nat64 timeouts udp icmp tcp-trans " - "tcp-est tcp-incoming-syn | reset", - .function = nat64_set_timeouts_command_fn, -}; - -/*? - * @cliexpar - * @cliexstart{show nat64 timeoutss} - * Show NAT64 session timeouts: - * vpp# show nat64 timeouts - * NAT64 session timeouts: - * UDP 300sec - * ICMP 60sec - * TCP transitory 240sec - * TCP established 7440sec - * TCP incoming SYN 6sec - * @cliexend -?*/ -VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = { - .path = "show nat64 timeouts", - .short_help = "show nat64 timeouts", - .function = nat64_show_timeouts_command_fn, -}; - /*? * @cliexpar * @cliexstart{show nat64 session table}