32 u32 start_host_order, end_host_order;
40 "NAT64 disabled, multi thread not supported");
52 else if (
unformat (line_input,
"tenant-vrf %u", &vrf_id))
55 end_addr = start_addr;
56 else if (
unformat (line_input,
"del"))
66 start_host_order = clib_host_to_net_u32 (start_addr.
as_u32);
67 end_host_order = clib_host_to_net_u32 (end_addr.
as_u32);
69 if (end_host_order < start_host_order)
75 count = (end_host_order - start_host_order) + 1;
76 this_addr = start_addr;
78 for (i = 0; i <
count; i++)
84 case VNET_API_ERROR_NO_SUCH_ENTRY:
89 case VNET_API_ERROR_VALUE_EXIST:
136 "NAT64 disabled, multi thread not supported");
154 u32 *inside_sw_if_indices = 0;
155 u32 *outside_sw_if_indices = 0;
161 "NAT64 disabled, multi thread not supported");
171 vec_add1 (inside_sw_if_indices, sw_if_index);
174 vec_add1 (outside_sw_if_indices, sw_if_index);
175 else if (
unformat (line_input,
"del"))
185 if (
vec_len (inside_sw_if_indices))
187 for (i = 0; i <
vec_len (inside_sw_if_indices); i++)
189 sw_if_index = inside_sw_if_indices[
i];
193 case VNET_API_ERROR_NO_SUCH_ENTRY:
199 case VNET_API_ERROR_VALUE_EXIST:
205 case VNET_API_ERROR_INVALID_VALUE:
206 case VNET_API_ERROR_INVALID_VALUE_2:
209 "%U NAT64 feature enable/disable failed.",
220 if (
vec_len (outside_sw_if_indices))
222 for (i = 0; i <
vec_len (outside_sw_if_indices); i++)
224 sw_if_index = outside_sw_if_indices[
i];
228 case VNET_API_ERROR_NO_SUCH_ENTRY:
234 case VNET_API_ERROR_VALUE_EXIST:
240 case VNET_API_ERROR_INVALID_VALUE:
241 case VNET_API_ERROR_INVALID_VALUE_2:
244 "%U NAT64 feature enable/disable failed.",
284 "NAT64 disabled, multi thread not supported");
306 u32 vrf_id = 0, protocol;
313 "NAT64 disabled, multi thread not supported");
324 &out_addr, &out_port))
326 else if (
unformat (line_input,
"vrf %u", &vrf_id))
335 else if (
unformat (line_input,
"del"))
366 (
u16) out_port, p, vrf_id, is_add);
370 case VNET_API_ERROR_NO_SUCH_ENTRY:
373 case VNET_API_ERROR_VALUE_EXIST:
376 case VNET_API_ERROR_UNSPECIFIED:
379 case VNET_API_ERROR_INVALID_VALUE:
406 case IP_PROTOCOL_ICMP:
407 case IP_PROTOCOL_TCP:
408 case IP_PROTOCOL_UDP:
411 clib_net_to_host_u16 (bibe->in_port),
413 clib_net_to_host_u16 (bibe->out_port),
416 bibe->is_static ?
"static" :
"dynamic", bibe->ses_num);
423 bibe->is_static ?
"static" :
"dynamic", bibe->ses_num);
440 "NAT64 disabled, multi thread not supported");
447 else if (
unformat (line_input,
"unknown"))
449 else if (
unformat (line_input,
"all"))
478 u32 timeout, tcp_trans, tcp_est, tcp_incoming_syn;
486 "NAT64 disabled, multi thread not supported");
493 if (
unformat (line_input,
"udp %u", &timeout))
501 else if (
unformat (line_input,
"icmp %u", &timeout))
509 else if (
unformat (line_input,
"tcp-trans %u", &tcp_trans))
515 "Invalid TCP transitory timeouts value");
519 else if (
unformat (line_input,
"tcp-est %u", &tcp_est))
525 "Invalid TCP established timeouts value");
530 if (
unformat (line_input,
"tcp-incoming-syn %u", &tcp_incoming_syn))
536 "Invalid TCP incoming SYN timeouts value");
540 else if (
unformat (line_input,
"reset"))
568 "NAT64 disabled, multi thread not supported");
588 nat64_db_bib_entry_t *bibe;
601 if (ste->proto == IP_PROTOCOL_ICMP)
605 clib_net_to_host_u16 (bibe->in_port),
608 clib_net_to_host_u16 (bibe->out_port),
611 else if (ste->proto == IP_PROTOCOL_TCP || ste->proto == IP_PROTOCOL_UDP)
614 clib_net_to_host_u16 (bibe->in_port),
616 clib_net_to_host_u16 (ste->r_port),
618 clib_net_to_host_u16 (bibe->out_port),
620 clib_net_to_host_u16 (ste->r_port),
629 bibe->proto, vrf_id);
646 "NAT64 disabled, multi thread not supported");
653 else if (
unformat (line_input,
"unknown"))
655 else if (
unformat (line_input,
"all"))
691 "NAT64 disabled, multi thread not supported");
701 else if (
unformat (line_input,
"tenant-vrf %u", &vrf_id))
703 else if (
unformat (line_input,
"del"))
723 case VNET_API_ERROR_NO_SUCH_ENTRY:
726 case VNET_API_ERROR_INVALID_VALUE:
758 "NAT64 disabled, multi thread not supported");
781 .path =
"nat64 add pool address",
782 .short_help =
"nat64 add pool address <ip4-range-start> [- <ip4-range-end>] " 783 "[tenant-vrf <vrf-id>] [del]",
798 .path =
"show nat64 pool",
799 .short_help =
"show nat64 pool",
814 .path =
"set interface nat64",
815 .short_help =
"set interface nat64 in|out <intfc> [del]",
831 .path =
"show nat64 interfaces",
832 .short_help =
"show nat64 interfaces",
846 .path =
"nat64 add static bib",
847 .short_help =
"nat64 add static bib <ip6-addr> <port> <ip4-addr> <port> " 848 "tcp|udp|icmp [vfr <table-id>] [del]",
873 .path =
"show nat64 bib",
874 .short_help =
"show nat64 bib all|tcp|udp|icmp|unknown",
889 .path =
"set nat64 timeouts",
890 .short_help =
"set nat64 timeouts udp <sec> icmp <sec> tcp-trans <sec> " 891 "tcp-est <sec> tcp-incoming-syn <sec> | reset",
909 .path =
"show nat64 timeouts",
910 .short_help =
"show nat64 timeouts",
937 .path =
"show nat64 session table",
938 .short_help =
"show nat64 session table all|tcp|udp|icmp|unknown",
953 .path =
"nat64 add prefix",
954 .short_help =
"nat64 add prefix <ip6-prefix>/<plen> [tenant-vrf <vrf-id>] " 971 .path =
"show nat64 prefix",
972 .short_help =
"show nat64 prefix",
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)
sll srl srl sll sra u16x4 i
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)
static int nat64_cli_st_walk(nat64_db_st_entry_t *ste, void *ctx)
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).
static vnet_sw_interface_t * vnet_get_sw_interface(vnet_main_t *vnm, u32 sw_if_index)
unformat_function_t unformat_vnet_sw_interface
int nat64_set_tcp_timeouts(u32 trans, u32 est, u32 incoming_syn)
Set TCP session timeouts.
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.
#define clib_error_return(e, args...)
static int nat64_cli_bib_walk(nat64_db_bib_entry_t *bibe, void *ctx)
nat64_db_t db
BIB and session DB.
format_function_t format_vnet_sw_interface_name
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.
u32 nat64_get_tcp_est_timeout(void)
Get TCP established timeout.
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.
static u32 ip_proto_to_snat_proto(u8 ip_proto)
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 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)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
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)
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.
static u8 snat_proto_to_ip_proto(snat_protocol_t snat_proto)