Skip to content

Commit 37d3967

Browse files
Ole TroanNeale Ranns
Ole Troan
authored and
Neale Ranns
committed
NAT64: Input feature arc on virtual interface via interface RX DPO.
Change-Id: If2048c7d72048679bc5d0412f3fae109926f759e Signed-off-by: Ole Troan <[email protected]>
1 parent 0b0421d commit 37d3967

File tree

3 files changed

+46
-4
lines changed

3 files changed

+46
-4
lines changed

src/plugins/nat/nat64_cli.c

+44-2
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
680680
vlib_cli_command_t * cmd)
681681
{
682682
nat64_main_t *nm = &nat64_main;
683+
vnet_main_t *vnm = vnet_get_main ();
683684
clib_error_t *error = 0;
684685
unformat_input_t _line_input, *line_input = &_line_input;
685686
u8 is_add = 1;
686-
u32 vrf_id = 0;
687+
u32 vrf_id = 0, sw_if_index = ~0;
687688
ip6_address_t prefix;
688689
u32 plen = 0;
689690
int rv;
@@ -704,6 +705,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
704705
;
705706
else if (unformat (line_input, "del"))
706707
is_add = 0;
708+
else
709+
if (unformat
710+
(line_input, "interface %U", unformat_vnet_sw_interface, vnm,
711+
&sw_if_index))
712+
;
707713
else
708714
{
709715
error = clib_error_return (0, "unknown input: '%U'",
@@ -732,6 +738,42 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
732738
break;
733739
}
734740

741+
/*
742+
* Add RX interface route, whenNAT isn't running on the real input
743+
* interface
744+
*/
745+
if (sw_if_index != ~0)
746+
{
747+
u32 fib_index;
748+
fib_prefix_t fibpfx = {
749+
.fp_len = plen,
750+
.fp_proto = FIB_PROTOCOL_IP6,
751+
.fp_addr = {.ip6 = prefix}
752+
};
753+
754+
if (is_add)
755+
{
756+
fib_index = fib_table_find_or_create_and_lock (FIB_PROTOCOL_IP6,
757+
vrf_id,
758+
FIB_SOURCE_PLUGIN_HI);
759+
fib_table_entry_update_one_path (fib_index, &fibpfx,
760+
FIB_SOURCE_PLUGIN_HI,
761+
FIB_ENTRY_FLAG_NONE, DPO_PROTO_IP6,
762+
NULL, sw_if_index, ~0, 0, NULL,
763+
FIB_ROUTE_PATH_INTF_RX);
764+
}
765+
else
766+
{
767+
fib_index = fib_table_find (FIB_PROTOCOL_IP6, vrf_id);
768+
fib_table_entry_path_remove (fib_index, &fibpfx,
769+
FIB_SOURCE_PLUGIN_HI, DPO_PROTO_IP6,
770+
NULL, sw_if_index, ~0, 1,
771+
FIB_ROUTE_PATH_INTF_RX);
772+
fib_table_unlock (fib_index, FIB_PROTOCOL_IP6,
773+
FIB_SOURCE_PLUGIN_HI);
774+
}
775+
}
776+
735777
done:
736778
unformat_free (line_input);
737779

@@ -954,7 +996,7 @@ VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
954996
VLIB_CLI_COMMAND (nat64_add_del_prefix_command, static) = {
955997
.path = "nat64 add prefix",
956998
.short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
957-
"[del]",
999+
"[del] [interface <interface]",
9581000
.function = nat64_add_del_prefix_command_fn,
9591001
};
9601002

src/vnet/dpo/interface_rx_dpo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ format_interface_rx_dpo (u8* s, va_list *ap)
154154
vnet_main_t * vnm = vnet_get_main();
155155
interface_rx_dpo_t *ido = interface_rx_dpo_get(index);
156156

157-
return (format(s, "%U-dpo: %U",
157+
return (format(s, "%U-rx-dpo: %U",
158158
format_vnet_sw_interface_name,
159159
vnm,
160160
vnet_get_sw_interface(vnm, ido->ido_sw_if_index),

src/vnet/dpo/interface_tx_dpo.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ format_interface_tx_dpo (u8* s, va_list *ap)
5050
CLIB_UNUSED(u32 indent) = va_arg(*ap, u32);
5151
vnet_main_t * vnm = vnet_get_main();
5252

53-
return (format(s, "%U-dpo:",
53+
return (format(s, "%U-tx-dpo:",
5454
format_vnet_sw_interface_name,
5555
vnm,
5656
vnet_get_sw_interface(vnm, index)));

0 commit comments

Comments
 (0)