|
FD.io VPP
v21.06-3-gbb25fbf28
Vector Packet Processing
|
Go to the documentation of this file.
19 #define NAT64_EXPECTED_ARGUMENT "expected required argument(s)"
27 u8 enable = 0, is_set = 0;
36 if (!is_set &&
unformat (line_input,
"enable"))
38 unformat (line_input,
"bib-buckets %u", &
c.bib_buckets);
39 unformat (line_input,
"bib-memory %u", &
c.bib_memory_size);
40 unformat (line_input,
"st-buckets %u", &
c.st_buckets);
41 unformat (line_input,
"st-memory %u", &
c.st_memory_size);
44 else if (!is_set &&
unformat (line_input,
"disable"));
76 u32 start_host_order, end_host_order;
96 else if (
unformat (line_input,
"del"))
106 start_host_order = clib_host_to_net_u32 (
start_addr.as_u32);
107 end_host_order = clib_host_to_net_u32 (
end_addr.as_u32);
109 if (end_host_order < start_host_order)
115 count = (end_host_order - start_host_order) + 1;
124 case VNET_API_ERROR_NO_SUCH_ENTRY:
129 case VNET_API_ERROR_VALUE_EXIST:
164 #define _(N, i, n, s) \
165 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
191 u32 *inside_sw_if_indices = 0;
192 u32 *outside_sw_if_indices = 0;
208 else if (
unformat (line_input,
"del"))
218 if (
vec_len (inside_sw_if_indices))
220 for (
i = 0;
i <
vec_len (inside_sw_if_indices);
i++)
226 case VNET_API_ERROR_NO_SUCH_ENTRY:
232 case VNET_API_ERROR_VALUE_EXIST:
238 case VNET_API_ERROR_INVALID_VALUE:
239 case VNET_API_ERROR_INVALID_VALUE_2:
242 "%U NAT64 feature enable/disable failed.",
253 if (
vec_len (outside_sw_if_indices))
255 for (
i = 0;
i <
vec_len (outside_sw_if_indices);
i++)
261 case VNET_API_ERROR_NO_SUCH_ENTRY:
267 case VNET_API_ERROR_VALUE_EXIST:
273 case VNET_API_ERROR_INVALID_VALUE:
274 case VNET_API_ERROR_INVALID_VALUE_2:
277 "%U NAT64 feature enable/disable failed.",
330 ip6_address_t in_addr;
348 &out_addr, &out_port))
359 else if (
unformat (line_input,
"del"))
394 case VNET_API_ERROR_NO_SUCH_ENTRY:
397 case VNET_API_ERROR_VALUE_EXIST:
400 case VNET_API_ERROR_UNSPECIFIED:
403 case VNET_API_ERROR_INVALID_VALUE:
406 "Outside address %U and port %u already in use.",
409 case VNET_API_ERROR_INVALID_VALUE_2:
433 case IP_PROTOCOL_ICMP:
434 case IP_PROTOCOL_TCP:
435 case IP_PROTOCOL_UDP:
438 clib_net_to_host_u16 (bibe->in_port),
440 clib_net_to_host_u16 (bibe->out_port),
443 bibe->is_static ?
"static" :
"dynamic", bibe->ses_num);
450 bibe->is_static ?
"static" :
"dynamic", bibe->ses_num);
471 else if (
unformat (line_input,
"unknown"))
473 else if (
unformat (line_input,
"all"))
509 nat64_db_bib_entry_t *bibe;
522 if (ste->proto == IP_PROTOCOL_ICMP)
526 clib_net_to_host_u16 (bibe->in_port),
529 clib_net_to_host_u16 (bibe->out_port),
532 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
535 clib_net_to_host_u16 (bibe->in_port),
537 clib_net_to_host_u16 (ste->r_port),
539 clib_net_to_host_u16 (bibe->out_port),
541 clib_net_to_host_u16 (ste->r_port),
574 else if (
unformat (line_input,
"unknown"))
576 else if (
unformat (line_input,
"all"))
627 else if (
unformat (line_input,
"del"))
652 case VNET_API_ERROR_NO_SUCH_ENTRY:
655 case VNET_API_ERROR_INVALID_VALUE:
748 else if (
unformat (line_input,
"del"))
762 case VNET_API_ERROR_NO_SUCH_ENTRY:
765 case VNET_API_ERROR_VALUE_EXIST:
794 .path =
"nat64 plugin",
795 .short_help =
"nat64 plugin <enable "
796 "[bib-buckets <count>] [bib-memory <size>] "
797 "[st-buckets <count>] [st-memory <size>] | disable>",
814 .path =
"nat64 add pool address",
815 .short_help =
"nat64 add pool address <ip4-range-start> [- <ip4-range-end>] "
816 "[tenant-vrf <vrf-id>] [del]",
831 .path =
"show nat64 pool",
832 .short_help =
"show nat64 pool",
847 .path =
"set interface nat64",
848 .short_help =
"set interface nat64 in|out <intfc> [del]",
864 .path =
"show nat64 interfaces",
865 .short_help =
"show nat64 interfaces",
879 .path =
"nat64 add static bib",
880 .short_help =
"nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> "
881 "tcp|udp|icmp [vfr <table-id>] [del]",
906 .path =
"show nat64 bib",
907 .short_help =
"show nat64 bib all|tcp|udp|icmp|unknown",
934 .path =
"show nat64 session table",
935 .short_help =
"show nat64 session table all|tcp|udp|icmp|unknown",
950 .path =
"nat64 add prefix",
951 .short_help =
"nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] "
952 "[del] [interface <interface]",
968 .path =
"show nat64 prefix",
969 .short_help =
"show nat64 prefix",
982 .path =
"nat64 add interface address",
983 .short_help =
"nat64 add interface address <interface> [del]",
int nat64_add_del_prefix(ip6_address_t *prefix, u8 plen, u32 vrf_id, u8 is_add)
Add/delete NAT64 prefix.
int nat64_add_del_static_bib_entry(ip6_address_t *in_addr, ip4_address_t *out_addr, u16 in_port, u16 out_port, u8 proto, u32 vrf_id, u8 is_add)
Add/delete static NAT64 BIB entry.
static vlib_cli_command_t nat64_add_del_static_bib_command
(constructor) VLIB_CLI_COMMAND (nat64_add_del_static_bib_command)
vl_api_address_t end_addr
fib_node_index_t fib_table_entry_update_one_path(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, fib_entry_flag_t flags, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_mpls_label_t *next_hop_labels, fib_route_path_flags_t path_flags)
Update the entry to have just one path.
void nat64_prefix_walk(nat64_prefix_walk_fn_t fn, void *ctx)
Walk NAT64 prefixes.
unformat_function_t unformat_nat_protocol
static clib_error_t * nat64_add_del_prefix_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static nat_protocol_t ip_proto_to_nat_proto(u8 ip_proto)
Common NAT inline functions.
static int nat64_cli_prefix_walk(nat64_prefix_t *p, void *ctx)
#define clib_error_return(e, args...)
static clib_error_t * nat64_add_del_pool_addr_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_cli_command_t nat64_add_interface_address_command
(constructor) VLIB_CLI_COMMAND (nat64_add_interface_address_command)
static vlib_cli_command_t show_nat64_bib_command
(constructor) VLIB_CLI_COMMAND (show_nat64_bib_command)
static vlib_cli_command_t nat64_add_pool_address_command
(constructor) VLIB_CLI_COMMAND (nat64_add_pool_address_command)
u16 fp_len
The mask length.
vlib_main_t * vm
X-connect all packets from the HOST to the PHY.
static int nat64_cli_interface_walk(nat64_interface_t *i, void *ctx)
void nat64_db_st_walk(nat64_db_t *db, u8 proto, nat64_db_st_walk_fn_t fn, void *ctx)
Walk NAT64 session table.
static int nat64_cli_st_walk(nat64_db_st_entry_t *ste, void *arg)
vl_api_address_t start_addr
static clib_error_t * nat64_add_interface_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat64_show_interfaces_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static vlib_cli_command_t nat64_plugin_enable_disable_command
(constructor) VLIB_CLI_COMMAND (nat64_plugin_enable_disable_command)
void nat64_db_bib_walk(nat64_db_t *db, u8 proto, nat64_db_bib_walk_fn_t fn, void *ctx)
Walk NAT64 BIB.
static vlib_cli_command_t show_nat64_st_command
(constructor) VLIB_CLI_COMMAND (show_nat64_st_command)
A protocol Independent FIB table.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
@ FIB_ROUTE_PATH_INTF_RX
A path that result in received traffic being recieved/recirculated so that it appears to have arrived...
static vlib_cli_command_t nat64_add_del_prefix_command
(constructor) VLIB_CLI_COMMAND (nat64_add_del_prefix_command)
int nat64_plugin_enable(nat64_config_t c)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
#define NAT64_EXPECTED_ARGUMENT
void fib_table_entry_path_remove(u32 fib_index, const fib_prefix_t *prefix, fib_source_t source, dpo_proto_t next_hop_proto, const ip46_address_t *next_hop, u32 next_hop_sw_if_index, u32 next_hop_fib_index, u32 next_hop_weight, fib_route_path_flags_t path_flags)
remove one path to an entry (aka route) in the FIB.
vnet_main_t * vnet_get_main(void)
u32 ft_table_id
Table ID (hash key) for this FIB.
u32 fib_table_find_or_create_and_lock(fib_protocol_t proto, u32 table_id, fib_source_t src)
Get the index of the FIB for a Table-ID.
static_always_inline u8 nat_proto_to_ip_proto(nat_protocol_t nat_proto)
struct nat64_cli_st_walk_ctx_t_ nat64_cli_st_walk_ctx_t
void nat64_pool_addr_walk(nat64_pool_addr_walk_fn_t fn, void *ctx)
Walk NAT64 pool.
void nat64_interfaces_walk(nat64_interface_walk_fn_t fn, void *ctx)
Walk NAT64 interfaces.
static vlib_cli_command_t show_nat64_interfaces_command
(constructor) VLIB_CLI_COMMAND (show_nat64_interfaces_command)
sll srl srl sll sra u16x4 i
#define VLIB_CLI_COMMAND(x,...)
#define nat64_interface_is_inside(i)
Check if NAT64 interface is inside.
static int nat64_cli_bib_walk(nat64_db_bib_entry_t *bibe, void *ctx)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
#define nat64_interface_is_outside(i)
Check if NAT64 interface is outside.
static clib_error_t * nat64_show_bib_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat64_show_st_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void increment_v4_address(ip4_address_t *a)
static clib_error_t * nat64_add_del_static_bib_command_fn(vlib_main_t *vm, unformat_input_t() *input, vlib_cli_command_t *cmd)
#define vec_free(V)
Free vector's memory (no header).
static vlib_cli_command_t show_nat64_prefix_command
(constructor) VLIB_CLI_COMMAND (show_nat64_prefix_command)
int nat64_add_del_pool_addr(u32 thread_index, ip4_address_t *addr, u32 vrf_id, u8 is_add)
Add/delete address to NAT64 pool.
format_function_t format_nat_protocol
format_function_t format_vnet_sw_if_index_name
unformat_function_t unformat_vnet_sw_interface
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
static clib_error_t * nat64_show_pool_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vl_api_ip_proto_t protocol
static clib_error_t * nat64_show_prefix_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_foreach(var, vec)
Vector iterator.
static vlib_cli_command_t set_interface_nat64_command
(constructor) VLIB_CLI_COMMAND (set_interface_nat64_command)
static int nat64_cli_pool_walk(nat64_address_t *ap, void *ctx)
static clib_error_t * nat64_interface_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
static clib_error_t * nat64_plugin_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
nat64_db_bib_entry_t * nat64_db_bib_entry_by_index(nat64_db_t *db, u8 proto, u32 bibe_index)
Get BIB entry by index and protocol.
int nat64_add_interface_address(u32 sw_if_index, int is_add)
NAT64 pool address from specific (DHCP addressed) interface.
int nat64_plugin_disable()
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
vl_api_interface_index_t sw_if_index
int nat64_interface_add_del(u32 sw_if_index, u8 is_inside, u8 is_add)
Enable/disable NAT64 feature on the interface.
static vlib_cli_command_t show_nat64_pool_command
(constructor) VLIB_CLI_COMMAND (show_nat64_pool_command)
Aggregate type for a prefix.