summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2017-11-03 14:02:26 +0100
committerNeale Ranns <nranns@cisco.com>2017-11-03 16:11:35 +0000
commit37d39672de5d3e0d0f928d61eec8f66cd73c7fe8 (patch)
tree6abf305c4d722f07d51ba45891c8103ae7af522c /src/plugins/nat
parent0b0421d710829f8afe48ebb0a23f8860288d71c6 (diff)
NAT64: Input feature arc on virtual interface via interface RX DPO.
Change-Id: If2048c7d72048679bc5d0412f3fae109926f759e Signed-off-by: Ole Troan <ot@cisco.com>
Diffstat (limited to 'src/plugins/nat')
-rw-r--r--src/plugins/nat/nat64_cli.c46
1 files changed, 44 insertions, 2 deletions
diff --git a/src/plugins/nat/nat64_cli.c b/src/plugins/nat/nat64_cli.c
index 4128eda5a38..7fea6bbb983 100644
--- a/src/plugins/nat/nat64_cli.c
+++ b/src/plugins/nat/nat64_cli.c
@@ -680,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;
@@ -705,6 +706,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'",
format_unformat_error, line_input);
@@ -732,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);
@@ -954,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 <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
- "[del]",
+ "[del] [interface <interface]",
.function = nat64_add_del_prefix_command_fn,
};