32 u32 start_host_order, end_host_order;
48 else if (
unformat (line_input,
"tenant-vrf %u", &vrf_id))
51 end_addr = start_addr;
52 else if (
unformat (line_input,
"del"))
62 start_host_order = clib_host_to_net_u32 (start_addr.
as_u32);
63 end_host_order = clib_host_to_net_u32 (end_addr.
as_u32);
65 if (end_host_order < start_host_order)
71 count = (end_host_order - start_host_order) + 1;
72 this_addr = start_addr;
74 for (i = 0; i <
count; i++)
80 case VNET_API_ERROR_NO_SUCH_ENTRY:
85 case VNET_API_ERROR_VALUE_EXIST:
120 #define _(N, i, n, s) \ 121 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s); 147 u32 *inside_sw_if_indices = 0;
148 u32 *outside_sw_if_indices = 0;
160 vec_add1 (inside_sw_if_indices, sw_if_index);
163 vec_add1 (outside_sw_if_indices, sw_if_index);
164 else if (
unformat (line_input,
"del"))
174 if (
vec_len (inside_sw_if_indices))
176 for (i = 0; i <
vec_len (inside_sw_if_indices); i++)
178 sw_if_index = inside_sw_if_indices[
i];
182 case VNET_API_ERROR_NO_SUCH_ENTRY:
188 case VNET_API_ERROR_VALUE_EXIST:
194 case VNET_API_ERROR_INVALID_VALUE:
195 case VNET_API_ERROR_INVALID_VALUE_2:
198 "%U NAT64 feature enable/disable failed.",
209 if (
vec_len (outside_sw_if_indices))
211 for (i = 0; i <
vec_len (outside_sw_if_indices); i++)
213 sw_if_index = outside_sw_if_indices[
i];
217 case VNET_API_ERROR_NO_SUCH_ENTRY:
223 case VNET_API_ERROR_VALUE_EXIST:
229 case VNET_API_ERROR_INVALID_VALUE:
230 case VNET_API_ERROR_INVALID_VALUE_2:
233 "%U NAT64 feature enable/disable failed.",
290 u32 vrf_id = 0, protocol;
304 &out_addr, &out_port))
306 else if (
unformat (line_input,
"vrf %u", &vrf_id))
315 else if (
unformat (line_input,
"del"))
346 (
u16) out_port, p, vrf_id, is_add);
350 case VNET_API_ERROR_NO_SUCH_ENTRY:
353 case VNET_API_ERROR_VALUE_EXIST:
356 case VNET_API_ERROR_UNSPECIFIED:
359 case VNET_API_ERROR_INVALID_VALUE:
364 case VNET_API_ERROR_INVALID_VALUE_2:
388 case IP_PROTOCOL_ICMP:
389 case IP_PROTOCOL_TCP:
390 case IP_PROTOCOL_UDP:
393 clib_net_to_host_u16 (bibe->in_port),
395 clib_net_to_host_u16 (bibe->out_port),
398 bibe->is_static ?
"static" :
"dynamic", bibe->ses_num);
405 bibe->is_static ?
"static" :
"dynamic", bibe->ses_num);
426 else if (
unformat (line_input,
"unknown"))
428 else if (
unformat (line_input,
"all"))
460 u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
471 if (
unformat (line_input,
"udp %u", &timeout))
479 else if (
unformat (line_input,
"icmp %u", &timeout))
487 else if (
unformat (line_input,
"tcp-trans %u", &tcp_trans))
493 "Invalid TCP transitory timeouts value");
497 else if (
unformat (line_input,
"tcp-est %u", &tcp_est))
503 "Invalid TCP established timeouts value");
508 if (
unformat (line_input,
"tcp-incoming-syn %u", &tcp_incoming_syn))
514 "Invalid TCP incoming SYN timeouts value");
518 else if (
unformat (line_input,
"reset"))
566 nat64_db_bib_entry_t *bibe;
579 if (ste->proto == IP_PROTOCOL_ICMP)
583 clib_net_to_host_u16 (bibe->in_port),
586 clib_net_to_host_u16 (bibe->out_port),
589 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
592 clib_net_to_host_u16 (bibe->in_port),
594 clib_net_to_host_u16 (ste->r_port),
596 clib_net_to_host_u16 (bibe->out_port),
598 clib_net_to_host_u16 (ste->r_port),
607 bibe->proto, vrf_id);
631 else if (
unformat (line_input,
"unknown"))
633 else if (
unformat (line_input,
"all"))
668 u32 vrf_id = 0, sw_if_index = ~0;
681 else if (
unformat (line_input,
"tenant-vrf %u", &vrf_id))
683 else if (
unformat (line_input,
"del"))
708 case VNET_API_ERROR_NO_SUCH_ENTRY:
711 case VNET_API_ERROR_INVALID_VALUE:
722 if (sw_if_index != ~0)
805 else if (
unformat (line_input,
"del"))
819 case VNET_API_ERROR_NO_SUCH_ENTRY:
822 case VNET_API_ERROR_VALUE_EXIST:
850 .path =
"nat64 add pool address",
851 .short_help =
"nat64 add pool address <ip4-range-start> [- <ip4-range-end>] " 852 "[tenant-vrf <vrf-id>] [del]",
867 .path =
"show nat64 pool",
868 .short_help =
"show nat64 pool",
883 .path =
"set interface nat64",
884 .short_help =
"set interface nat64 in|out <intfc> [del]",
900 .path =
"show nat64 interfaces",
901 .short_help =
"show nat64 interfaces",
915 .path =
"nat64 add static bib",
916 .short_help =
"nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> " 917 "tcp|udp|icmp [vfr <table-id>] [del]",
942 .path =
"show nat64 bib",
943 .short_help =
"show nat64 bib all|tcp|udp|icmp|unknown",
958 .path =
"set nat64 timeouts",
959 .short_help =
"set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> " 960 "tcp-est <sec> tcp-incoming-syn <sec> | reset",
978 .path =
"show nat64 timeouts",
979 .short_help =
"show nat64 timeouts",
1006 .path =
"show nat64 session table",
1007 .short_help =
"show nat64 session table all|tcp|udp|icmp|unknown",
1022 .path =
"nat64 add prefix",
1023 .short_help =
"nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] " 1024 "[del] [interface <interface]",
1040 .path =
"show nat64 prefix",
1041 .short_help =
"show nat64 prefix",
1054 .path =
"nat64 add interface address",
1055 .short_help =
"nat64 add interface address <interface> [del]",
u32 nat64_get_icmp_timeout(void)
Get ICMP session timeout.
static clib_error_t * nat64_show_bib_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
nat64_db_t * db
BIB and session DB per thread.
int nat64_set_udp_timeout(u32 timeout)
Set UDP session timeout.
static clib_error_t * nat64_show_timeouts_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int nat64_cli_pool_walk(snat_address_t *ap, void *ctx)
u8 * format_snat_protocol(u8 *s, va_list *args)
vnet_main_t * vnet_get_main(void)
static int nat64_cli_interface_walk(snat_interface_t *i, void *ctx)
int nat64_add_del_interface(u32 sw_if_index, u8 is_inside, u8 is_add)
Enable/disable NAT64 feature on the interface.
int nat64_add_del_pool_addr(ip4_address_t *addr, u32 vrf_id, u8 is_add)
Add/delete address to NAT64 pool.
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
unformat_function_t unformat_vnet_sw_interface
A path that result in received traffic being recieved/recirculated so that it appears to have arrived...
int nat64_add_interface_address(u32 sw_if_index, int is_add)
NAT64 pool address from specific (DHCP addressed) interface.
int nat64_set_tcp_timeouts(u32 trans, u32 est, u32 incoming_syn)
Set TCP session timeouts.
format_function_t format_vnet_sw_if_index_name
#define nat_interface_is_outside(i)
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.
static clib_error_t * nat64_add_del_pool_addr_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int nat64_set_icmp_timeout(u32 timeout)
Set ICMP session timeout.
A high priority source a plugin can use.
Aggregrate type for a prefix.
#define clib_error_return(e, args...)
static int nat64_cli_bib_walk(nat64_db_bib_entry_t *bibe, void *ctx)
static clib_error_t * nat64_add_interface_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 fib_table_find(fib_protocol_t proto, u32 table_id)
Get the index of the FIB for a Table-ID.
u16 fp_len
The mask length.
static clib_error_t * nat64_show_pool_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 nat64_get_udp_timeout(void)
Get UDP session timeout.
#define nat_interface_is_inside(i)
void fib_table_unlock(u32 fib_index, fib_protocol_t proto, fib_source_t source)
Take a reference counting lock on the table.
u32 nat64_get_tcp_est_timeout(void)
Get TCP established timeout.
struct nat64_cli_st_walk_ctx_t_ nat64_cli_st_walk_ctx_t
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)
void nat64_pool_addr_walk(nat64_pool_addr_walk_fn_t fn, void *ctx)
Walk NAT64 pool.
u32 ft_table_id
Table ID (hash key) for this FIB.
#define vec_free(V)
Free vector's memory (no header).
int nat64_add_del_prefix(ip6_address_t *prefix, u8 plen, u32 vrf_id, u8 is_add)
Add/delete NAT64 prefix.
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 VLIB_CLI_COMMAND(x,...)
void nat64_db_st_walk(nat64_db_t *db, u8 proto, nat64_db_st_walk_fn_t fn, void *ctx)
Walk NAT64 session table.
u32 nat64_get_tcp_incoming_syn_timeout(void)
Get TCP incoming SYN timeout.
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.
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.
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.
void nat64_prefix_walk(nat64_prefix_walk_fn_t fn, void *ctx)
Walk NAT64 prefixes.
void nat64_interfaces_walk(nat64_interface_walk_fn_t fn, void *ctx)
Walk NAT64 interfaces.
static clib_error_t * nat64_interface_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
NAT64 global declarations.
void increment_v4_address(ip4_address_t *a)
static u32 ip_proto_to_snat_proto(u8 ip_proto)
The NAT inline functions.
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
static int nat64_cli_st_walk(nat64_db_st_entry_t *ste, void *arg)
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
uword unformat_snat_protocol(unformat_input_t *input, va_list *args)
static clib_error_t * nat64_show_st_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_foreach(var, vec)
Vector iterator.
static clib_error_t * nat64_add_del_prefix_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat64_set_timeouts_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static int nat64_cli_prefix_walk(nat64_prefix_t *p, void *ctx)
static clib_error_t * nat64_show_prefix_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat64_db_bib_walk(nat64_db_t *db, u8 proto, nat64_db_bib_walk_fn_t fn, void *ctx)
Walk NAT64 BIB.
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.
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
u32 nat64_get_tcp_trans_timeout(void)
Get TCP transitory timeout.
static clib_error_t * nat64_show_interfaces_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
A protocol Independent FIB table.