@@ -680,10 +680,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
680
680
vlib_cli_command_t * cmd )
681
681
{
682
682
nat64_main_t * nm = & nat64_main ;
683
+ vnet_main_t * vnm = vnet_get_main ();
683
684
clib_error_t * error = 0 ;
684
685
unformat_input_t _line_input , * line_input = & _line_input ;
685
686
u8 is_add = 1 ;
686
- u32 vrf_id = 0 ;
687
+ u32 vrf_id = 0 , sw_if_index = ~ 0 ;
687
688
ip6_address_t prefix ;
688
689
u32 plen = 0 ;
689
690
int rv ;
@@ -704,6 +705,11 @@ nat64_add_del_prefix_command_fn (vlib_main_t * vm, unformat_input_t * input,
704
705
;
705
706
else if (unformat (line_input , "del" ))
706
707
is_add = 0 ;
708
+ else
709
+ if (unformat
710
+ (line_input , "interface %U" , unformat_vnet_sw_interface , vnm ,
711
+ & sw_if_index ))
712
+ ;
707
713
else
708
714
{
709
715
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,
732
738
break ;
733
739
}
734
740
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
+
735
777
done :
736
778
unformat_free (line_input );
737
779
@@ -954,7 +996,7 @@ VLIB_CLI_COMMAND (show_nat64_st_command, static) = {
954
996
VLIB_CLI_COMMAND (nat64_add_del_prefix_command , static ) = {
955
997
.path = "nat64 add prefix" ,
956
998
.short_help = "nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
957
- "[del]" ,
999
+ "[del] [interface <interface] " ,
958
1000
.function = nat64_add_del_prefix_command_fn ,
959
1001
};
960
1002
0 commit comments