X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fnat%2Fnat64_cli.c;h=7fea6bbb9835f19910c9210ef99dff14466378e9;hb=37d39672de5d3e0d0f928d61eec8f66cd73c7fe8;hp=bb62ecf29673778ad236ce2144b316593c0e4ef6;hpb=2ba92e32e0197f676dd905e5edcb4ff3e1bec241;p=vpp.git diff --git a/src/plugins/nat/nat64_cli.c b/src/plugins/nat/nat64_cli.c index bb62ecf2967..7fea6bbb983 100644 --- a/src/plugins/nat/nat64_cli.c +++ b/src/plugins/nat/nat64_cli.c @@ -268,7 +268,9 @@ nat64_cli_interface_walk (snat_interface_t * i, void *ctx) vlib_cli_output (vm, " %U %s", format_vnet_sw_interface_name, vnm, vnet_get_sw_interface (vnm, i->sw_if_index), - i->is_inside ? "in" : "out"); + (nat_interface_is_inside (i) + && nat_interface_is_outside (i)) ? "in out" : + nat_interface_is_inside (i) ? "in" : "out"); return 0; } @@ -301,8 +303,8 @@ nat64_add_del_static_bib_command_fn (vlib_main_t * u8 is_add = 1; ip6_address_t in_addr; ip4_address_t out_addr; - u16 in_port = 0; - u16 out_port = 0; + u32 in_port = 0; + u32 out_port = 0; u32 vrf_id = 0, protocol; snat_protocol_t proto = 0; u8 p = 0; @@ -362,8 +364,8 @@ nat64_add_del_static_bib_command_fn (vlib_main_t * } rv = - nat64_add_del_static_bib_entry (&in_addr, &out_addr, in_port, out_port, p, - vrf_id, is_add); + nat64_add_del_static_bib_entry (&in_addr, &out_addr, (u16) in_port, + (u16) out_port, p, vrf_id, is_add); switch (rv) { @@ -511,7 +513,8 @@ nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input, if (nat64_set_tcp_timeouts (tcp_trans, tcp_est, tcp_incoming_syn)) { error = - clib_error_return (0, "Invalid TCP transitory tiemout value"); + clib_error_return (0, + "Invalid TCP transitory timeouts value"); goto done; } } @@ -521,7 +524,7 @@ nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input, { error = clib_error_return (0, - "Invalid TCP established tiemout value"); + "Invalid TCP established timeouts value"); goto done; } } @@ -532,7 +535,7 @@ nat64_set_timeouts_command_fn (vlib_main_t * vm, unformat_input_t * input, { error = clib_error_return (0, - "Invalid TCP incoming SYN tiemout value"); + "Invalid TCP incoming SYN timeouts value"); goto done; } } @@ -677,10 +680,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input, vlib_cli_command_t * cmd) { nat64_main_t *nm = &nat64_main; + vnet_main_t *vnm = vnet_get_main (); clib_error_t *error = 0; unformat_input_t _line_input, *line_input = &_line_input; u8 is_add = 1; - u32 vrf_id = 0; + u32 vrf_id = 0, sw_if_index = ~0; ip6_address_t prefix; u32 plen = 0; int rv; @@ -701,6 +705,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input, ; else if (unformat (line_input, "del")) is_add = 0; + else + if (unformat + (line_input, "interface %U", unformat_vnet_sw_interface, vnm, + &sw_if_index)) + ; else { error = clib_error_return (0, "unknown input: '%U'", @@ -729,6 +738,42 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input, break; } + /* + * Add RX interface route, whenNAT isn't running on the real input + * interface + */ + if (sw_if_index != ~0) + { + u32 fib_index; + fib_prefix_t fibpfx = { + .fp_len = plen, + .fp_proto = FIB_PROTOCOL_IP6, + .fp_addr = {.ip6 = prefix} + }; + + if (is_add) + { + fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6, + vrf_id, + FIB_SOURCE_PLUGIN_HI); + fib_table_entry_update_one_path (fib_index, &fibpfx, + FIB_SOURCE_PLUGIN_HI, + FIB_ENTRY_FLAG_NONE, DPO_PROTO_IP6, + NULL, sw_if_index, ~0, 0, NULL, + FIB_ROUTE_PATH_INTF_RX); + } + else + { + fib_index = fib_table_find (FIB_PROTOCOL_IP6, vrf_id); + fib_table_entry_path_remove (fib_index, &fibpfx, + FIB_SOURCE_PLUGIN_HI, DPO_PROTO_IP6, + NULL, sw_if_index, ~0, 1, + FIB_ROUTE_PATH_INTF_RX); + fib_table_unlock (fib_index, FIB_PROTOCOL_IP6, + FIB_SOURCE_PLUGIN_HI); + } + } + done: unformat_free (line_input); @@ -893,9 +938,9 @@ VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = { /*? * @cliexpar - * @cliexstart{show nat64 tiemouts} + * @cliexstart{show nat64 timeoutss} * Show NAT64 session timeouts: - * vpp# show nat64 tiemouts + * vpp# show nat64 timeouts * NAT64 session timeouts: * UDP 300sec * ICMP 60sec @@ -905,8 +950,8 @@ VLIB_CLI_COMMAND (set_nat64_timeouts_command, static) = { * @cliexend ?*/ VLIB_CLI_COMMAND (show_nat64_timeouts_command, static) = { - .path = "show nat64 tiemouts", - .short_help = "show nat64 tiemouts", + .path = "show nat64 timeouts", + .short_help = "show nat64 timeouts", .function = nat64_show_timeouts_command_fn, }; @@ -951,7 +996,7 @@ VLIB_CLI_COMMAND (show_nat64_st_command, static) = { VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = { .path = "nat64 add prefix", .short_help = "nat64 add prefix / [tenant-vrf ] " - "[del]", + "[del] [interface