X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat44_cli.c;h=efde4be284c73a89b9581197303b669e6e29b263;hb=70a26ac05f2ab9d4cc0669599b09f654de580f36;hp=2f1e9a019ac30541863b99dd6f529d34b2437d8e;hpb=1e5c07d379a092f4829e7081aa962d013b31fdfc;p=vpp.git diff --git a/src/plugins/nat/nat44_cli.c b/src/plugins/nat/nat44_cli.c index 2f1e9a019ac..efde4be284c 100644 --- a/src/plugins/nat/nat44_cli.c +++ b/src/plugins/nat/nat44_cli.c @@ -157,6 +157,38 @@ done: return error; } +static clib_error_t * +nat44_show_hash_commnad_fn (vlib_main_t * vm, unformat_input_t * input, + vlib_cli_command_t * cmd) +{ + snat_main_t *sm = &snat_main; + snat_main_per_thread_data_t *tsm; + int i; + int verbose = 0; + + if (unformat (input, "detail")) + verbose = 1; + else if (unformat (input, "verbose")) + verbose = 2; + + vlib_cli_output (vm, "%U", format_bihash_16_8, &sm->in2out_ed, verbose); + vlib_cli_output (vm, "%U", format_bihash_16_8, &sm->out2in_ed, verbose); + vlib_cli_output (vm, "%U", format_bihash_8_8, &sm->static_mapping_by_local, + verbose); + vlib_cli_output (vm, "%U", + format_bihash_8_8, &sm->static_mapping_by_external, + verbose); + vec_foreach_index (i, sm->per_thread_data) + { + tsm = vec_elt_at_index (sm->per_thread_data, i); + vlib_cli_output (vm, "%U", format_bihash_8_8, &tsm->in2out, verbose); + vlib_cli_output (vm, "%U", format_bihash_8_8, &tsm->out2in, verbose); + vlib_cli_output (vm, "%U", format_bihash_8_8, &tsm->user_hash, verbose); + } + + return 0; +} + static clib_error_t * nat44_set_alloc_addr_and_port_alg_command_fn (vlib_main_t * vm, unformat_input_t * input, @@ -927,10 +959,10 @@ nat44_del_session_command_fn (vlib_main_t * vm, { snat_main_t *sm = &snat_main; unformat_input_t _line_input, *line_input = &_line_input; - int is_in = 0; + int is_in = 0, is_ed = 0; clib_error_t *error = 0; - ip4_address_t addr; - u32 port = 0, vrf_id = sm->outside_vrf_id; + ip4_address_t addr, eh_addr; + u32 port = 0, eh_port = 0, vrf_id = sm->outside_vrf_id; snat_protocol_t proto; int rv; @@ -952,8 +984,18 @@ nat44_del_session_command_fn (vlib_main_t * vm, is_in = 1; vrf_id = sm->inside_vrf_id; } + else if (unformat (line_input, "out")) + { + is_in = 0; + vrf_id = sm->outside_vrf_id; + } else if (unformat (line_input, "vrf %u", &vrf_id)) ; + else + if (unformat + (line_input, "external-host %U:%u", unformat_ip4_address, + &eh_addr, &eh_port)) + is_ed = 1; else { error = clib_error_return (0, "unknown input '%U'", @@ -962,7 +1004,12 @@ nat44_del_session_command_fn (vlib_main_t * vm, } } - rv = nat44_del_session (sm, &addr, port, proto, vrf_id, is_in); + if (is_ed) + rv = + nat44_del_ed_session (sm, &addr, port, &eh_addr, eh_port, + snat_proto_to_ip_proto (proto), vrf_id, is_in); + else + rv = nat44_del_session (sm, &addr, port, proto, vrf_id, is_in); switch (rv) { @@ -1488,6 +1535,18 @@ VLIB_CLI_COMMAND (nat44_set_alloc_addr_and_port_alg_command, static) = { .function = nat44_set_alloc_addr_and_port_alg_command_fn, }; +/*? + * @cliexpar + * @cliexstart{show nat44 hash tables} + * Show NAT44 hash tables + * @cliexend +?*/ +VLIB_CLI_COMMAND (nat44_show_hash, static) = { + .path = "show nat44 hash tables", + .short_help = "show nat44 hash tables [detail|verbose]", + .function = nat44_show_hash_commnad_fn, +}; + /*? * @cliexpar * @cliexstart{nat44 add address} @@ -1706,7 +1765,7 @@ VLIB_CLI_COMMAND (nat44_show_sessions_command, static) = { ?*/ VLIB_CLI_COMMAND (nat44_del_session_command, static) = { .path = "nat44 del session", - .short_help = "nat44 del session in|out : tcp|udp|icmp [vrf ]", + .short_help = "nat44 del session in|out : tcp|udp|icmp [vrf ] [external-host :]", .function = nat44_del_session_command_fn, };