31 #define UNSUPPORTED_IN_DET_OR_ED_MODE_STR \ 32 "This command is unsupported in deterministic or endpoint dependent mode" 33 #define UNSUPPORTED_IN_DET_OR_NON_ED_MODE_STR \ 34 "This command is unsupported in deterministic or non endpoint dependent mode" 35 #define UNSUPPORTED_IN_DET_MODE_STR \ 36 "This command is unsupported in deterministic mode" 37 #define SUPPORTED_ONLY_IN_ED_MODE_STR \ 38 "This command is supported only in endpoint dependent mode" 39 #define SUPPORTED_ONLY_IN_DET_MODE_STR \ 40 "This command is supported only in deterministic mode" 61 if (
unformat (line_input,
"%U", unformat_bitmap_list, &bitmap))
83 case VNET_API_ERROR_INVALID_WORKER:
86 case VNET_API_ERROR_FEATURE_DISABLED:
88 "Supported only if 2 or more workes available.");
140 if (!
unformat (line_input,
"%d", &log_level))
146 if (log_level > SNAT_LOG_DEBUG)
183 if (
unformat (line_input,
"domain %d", &domain_id))
185 else if (
unformat (line_input,
"src-port %d", &src_port))
187 else if (
unformat (line_input,
"disable"))
223 else if (
unformat (input,
"verbose"))
267 u32 psid, psid_offset, psid_length, port_start, port_end;
278 if (
unformat (line_input,
"default"))
282 (line_input,
"map-e psid %d psid-offset %d psid-len %d", &psid,
283 &psid_offset, &psid_length))
288 (line_input,
"port-range %d - %d", &port_start, &port_end))
290 if (port_end <= port_start)
294 "The end-port must be greater than start-port");
329 case NAT_ADDR_AND_PORT_ALLOC_ALG_MAPE:
333 case NAT_ADDR_AND_PORT_ALLOC_ALG_RANGE:
359 if (
unformat (line_input,
"disable"))
361 else if (
unformat (line_input,
"%d", &mss))
400 u32 port, session_refresh_interval = 10;
414 (line_input,
"refresh-interval %u", &session_refresh_interval))
452 else if (
unformat (line_input,
"path-mtu %u", &path_mtu))
478 u32 path_mtu, session_refresh_interval, resync_ack_missed;
497 session_refresh_interval);
506 vlib_cli_output (vm,
" completed (%d ACK missed)\n", resync_ack_missed);
538 u32 start_host_order, end_host_order;
555 if (
unformat (line_input,
"%U - %U",
559 else if (
unformat (line_input,
"tenant-vrf %u", &vrf_id))
562 end_addr = start_addr;
563 else if (
unformat (line_input,
"twice-nat"))
565 else if (
unformat (line_input,
"del"))
581 start_host_order = clib_host_to_net_u32 (start_addr.
as_u32);
582 end_host_order = clib_host_to_net_u32 (end_addr.
as_u32);
584 if (end_host_order < start_host_order)
590 count = (end_host_order - start_host_order) + 1;
597 this_addr = start_addr;
599 for (i = 0; i <
count; i++)
608 case VNET_API_ERROR_VALUE_EXIST:
611 case VNET_API_ERROR_NO_SUCH_ENTRY:
614 case VNET_API_ERROR_UNSPECIFIED:
618 case VNET_API_ERROR_FEATURE_DISABLED:
621 "twice NAT available only for endpoint-dependent mode.");
658 u64 sess_timeout_time;
660 u32 udp_sessions = 0;
661 u32 tcp_sessions = 0;
662 u32 icmp_sessions = 0;
666 u32 transitory_wait_closed = 0;
667 u32 transitory_closed = 0;
677 sess_timeout_time = s->last_heard +
678 (f64) nat44_session_get_timeout (sm, s);
679 if (now >= sess_timeout_time)
682 switch (s->in2out.protocol)
684 case NAT_PROTOCOL_ICMP:
687 case NAT_PROTOCOL_TCP:
691 if (s->tcp_closed_timestamp)
693 if (now >= s->tcp_closed_timestamp)
699 ++transitory_wait_closed;
707 case NAT_PROTOCOL_UDP:
723 sess_timeout_time = s->last_heard +
724 (f64) nat44_session_get_timeout (sm, s);
725 if (now >= sess_timeout_time)
728 switch (s->in2out.protocol)
730 case NAT_PROTOCOL_ICMP:
733 case NAT_PROTOCOL_TCP:
737 if (s->tcp_closed_timestamp)
739 if (now >= s->tcp_closed_timestamp)
745 ++transitory_wait_closed;
753 case NAT_PROTOCOL_UDP:
761 if (sm->endpoint_dependent)
767 clib_dlist_remove_head (tsm->lru_pool, tsm->n##_lru_head_index); \ 768 if (~0 != oldest_index) \ 770 oldest_elt = pool_elt_at_index (tsm->lru_pool, oldest_index); \ 771 s = pool_elt_at_index (tsm->sessions, oldest_elt->value); \ 772 sess_timeout_time = \ 773 s->last_heard + (f64)nat44_session_get_timeout (sm, s); \ 774 vlib_cli_output (vm, d " LRU min session timeout %llu (now %llu)", \ 775 sess_timeout_time, now); \ 776 clib_dlist_addhead (tsm->lru_pool, tsm->n##_lru_head_index, \ 779 _(tcp_estab,
"established tcp");
780 _(tcp_trans,
"transitory tcp");
782 _(unk_proto,
"unknown protocol");
794 transitory_wait_closed);
822 #define _(N, i, n, s) \ 823 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s); 836 #define _(N, i, n, s) \ 837 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s); 853 u32 *inside_sw_if_indices = 0;
854 u32 *outside_sw_if_indices = 0;
855 u8 is_output_feature = 0;
869 vec_add1 (inside_sw_if_indices, sw_if_index);
872 vec_add1 (outside_sw_if_indices, sw_if_index);
873 else if (
unformat (line_input,
"output-feature"))
874 is_output_feature = 1;
875 else if (
unformat (line_input,
"del"))
885 if (
vec_len (inside_sw_if_indices))
887 for (i = 0; i <
vec_len (inside_sw_if_indices); i++)
889 sw_if_index = inside_sw_if_indices[
i];
890 if (is_output_feature)
893 (sw_if_index, 1, is_del))
896 is_del ?
"del" :
"add",
907 is_del ?
"del" :
"add",
916 if (
vec_len (outside_sw_if_indices))
918 for (i = 0; i <
vec_len (outside_sw_if_indices); i++)
920 sw_if_index = outside_sw_if_indices[
i];
921 if (is_output_feature)
924 (sw_if_index, 0, is_del))
927 is_del ?
"del" :
"add",
938 is_del ?
"del" :
"add",
967 vlib_cli_output (vm,
" %U %s", format_vnet_sw_if_index_name, vnm,
969 (nat_interface_is_inside(i) &&
970 nat_interface_is_outside(i)) ?
"in out" :
971 (nat_interface_is_inside(i) ?
"in" :
"out"));
976 vlib_cli_output (vm,
" %U output-feature %s",
977 format_vnet_sw_if_index_name, vnm,
979 (nat_interface_is_inside(i) &&
980 nat_interface_is_outside(i)) ?
"in out" :
981 (nat_interface_is_inside(i) ?
"in" :
"out"));
1029 else if (
unformat (line_input,
"external %U %u",
1034 else if (
unformat (line_input,
"external %U",
1041 else if (
unformat (line_input,
"twice-nat"))
1043 else if (
unformat (line_input,
"self-twice-nat"))
1045 else if (
unformat (line_input,
"out2in-only"))
1047 else if (
unformat (line_input,
"del"))
1057 if (twice_nat && addr_only)
1063 if (!addr_only && !proto_set)
1070 vrf_id, addr_only, sw_if_index, proto, is_add,
1071 twice_nat, out2in_only, 0, 0);
1075 case VNET_API_ERROR_INVALID_VALUE:
1078 case VNET_API_ERROR_NO_SUCH_ENTRY:
1084 case VNET_API_ERROR_NO_SUCH_FIB:
1087 case VNET_API_ERROR_VALUE_EXIST:
1090 case VNET_API_ERROR_FEATURE_DISABLED:
1093 "twice-nat/out2in-only available only for endpoint-dependent mode.");
1135 else if (
unformat (line_input,
"external %U",
1143 else if (
unformat (line_input,
"del"))
1154 vrf_id, addr_only, sw_if_index, proto, is_add,
1159 case VNET_API_ERROR_INVALID_VALUE:
1162 case VNET_API_ERROR_NO_SUCH_ENTRY:
1168 case VNET_API_ERROR_NO_SUCH_FIB:
1171 case VNET_API_ERROR_VALUE_EXIST:
1211 if (
unformat (line_input,
"local %U:%u probability %u",
1215 local.addr = l_addr;
1216 local.port = (
u16) l_port;
1220 else if (
unformat (line_input,
"local %U:%u vrf %u probability %u",
1225 local.addr = l_addr;
1226 local.port = (
u16) l_port;
1237 else if (
unformat (line_input,
"twice-nat"))
1239 else if (
unformat (line_input,
"self-twice-nat"))
1241 else if (
unformat (line_input,
"out2in-only"))
1243 else if (
unformat (line_input,
"del"))
1245 else if (
unformat (line_input,
"affinity %u", &affinity))
1268 is_add, twice_nat, out2in_only, 0,
1273 case VNET_API_ERROR_INVALID_VALUE:
1276 case VNET_API_ERROR_NO_SUCH_ENTRY:
1282 case VNET_API_ERROR_VALUE_EXIST:
1285 case VNET_API_ERROR_FEATURE_DISABLED:
1323 if (
unformat (line_input,
"local %U:%u probability %u",
1326 else if (
unformat (line_input,
"local %U:%u vrf %u probability %u",
1336 else if (
unformat (line_input,
"del"))
1346 if (!l_port || !e_port)
1365 case VNET_API_ERROR_INVALID_VALUE:
1369 case VNET_API_ERROR_NO_SUCH_ENTRY:
1372 case VNET_API_ERROR_VALUE_EXIST:
1375 case VNET_API_ERROR_FEATURE_DISABLED:
1379 case VNET_API_ERROR_UNSPECIFIED:
1408 vlib_cli_output (vm,
" %U", format_snat_static_mapping, m);
1442 else if (
unformat (line_input,
"twice-nat"))
1444 else if (
unformat (line_input,
"del"))
1524 if (
unformat (line_input,
"detail"))
1555 vlib_cli_output (vm,
" %U", format_snat_user, tsm, u, detail);
1563 vlib_cli_output (vm,
" %U\n", format_snat_session, tsm, s);
1591 if (
unformat (line_input,
"%u", &session_limit))
1636 else if (
unformat (line_input,
"fib %u", &fib_index))
1681 int is_in = 0, is_ed = 0;
1701 else if (
unformat (line_input,
"in"))
1706 else if (
unformat (line_input,
"out"))
1716 &eh_addr, &eh_port))
1756 u8 forwarding_enable;
1757 u8 forwarding_enable_set = 0;
1769 if (!forwarding_enable_set &&
unformat (line_input,
"enable"))
1771 forwarding_enable = 1;
1772 forwarding_enable_set = 1;
1774 else if (!forwarding_enable_set &&
unformat (line_input,
"disable"))
1776 forwarding_enable = 0;
1777 forwarding_enable_set = 1;
1787 if (!forwarding_enable_set)
1808 u32 in_plen, out_plen;
1829 else if (
unformat (line_input,
"del"))
1869 vlib_cli_output (vm,
" in %U/%d out %U/%d\n",
1870 format_ip4_address, &dm->in_addr, dm->in_plen,
1871 format_ip4_address, &dm->out_addr, dm->out_plen);
1872 vlib_cli_output (vm,
" outside address sharing ratio: %d\n",
1874 vlib_cli_output (vm,
" number of ports per inside host: %d\n",
1875 dm->ports_per_host);
1876 vlib_cli_output (vm,
" sessions number: %d\n", dm->ses_num);
1962 if (out_port < 1024 || out_port > 65535)
2005 else if (
unformat (line_input,
"tcp-established %u",
2013 "Invalid TCP established timeouts value");
2017 else if (
unformat (line_input,
"tcp-transitory %u",
2025 "Invalid TCP transitory timeouts value");
2037 else if (
unformat (line_input,
"reset"))
2093 vec_foreach_index (i, dm->sessions)
2095 ses = vec_elt_at_index (dm->sessions, i);
2097 vlib_cli_output (vm,
" %U", format_det_map_ses, dm, ses, &i);
2112 u32 out_port, ext_port;
2127 if (
unformat (line_input,
"%U:%d %U:%d",
2171 u32 in_port, ext_port;
2186 if (
unformat (line_input,
"%U:%d %U:%d",
2230 .path =
"set nat workers",
2232 .short_help =
"set nat workers <workers-list>",
2246 .path =
"show nat workers",
2247 .short_help =
"show nat workers",
2261 .path =
"set nat timeout",
2264 "set nat timeout [udp <sec> | tcp-established <sec> " 2265 "tcp-transitory <sec> | icmp <sec> | reset]",
2280 .path =
"show nat timeouts",
2281 .short_help =
"show nat timeouts",
2293 .path =
"nat set logging level",
2295 .short_help =
"nat set logging level <level>",
2308 .path =
"nat ipfix logging",
2310 .short_help =
"nat ipfix logging [domain <domain-id>] [src-port <port>] [disable]",
2326 .path =
"nat addr-port-assignment-alg",
2327 .short_help =
"nat addr-port-assignment-alg <alg-name> [<alg-params>]",
2338 .path =
"show nat addr-port-assignment-alg",
2339 .short_help =
"show nat addr-port-assignment-alg",
2354 .path =
"nat mss-clamping",
2355 .short_help =
"nat mss-clamping <mss-value>|disable",
2366 .path =
"show nat mss-clamping",
2367 .short_help =
"show nat mss-clamping",
2378 .path =
"nat ha failover",
2379 .short_help =
"nat ha failover <ip4-address>:<port> [refresh-interval <sec>]",
2390 .path =
"nat ha listener",
2391 .short_help =
"nat ha listener <ip4-address>:<port> [path-mtu <path-mtu>]",
2402 .path =
"show nat ha",
2403 .short_help =
"show nat ha",
2414 .path =
"nat ha flush",
2415 .short_help =
"nat ha flush",
2426 .path =
"nat ha resync",
2427 .short_help =
"nat ha resync",
2438 .path =
"show nat44 hash tables",
2439 .short_help =
"show nat44 hash tables [detail|verbose]",
2455 .path =
"nat44 add address",
2456 .short_help =
"nat44 add address <ip4-range-start> [- <ip4-range-end>] " 2457 "[tenant-vrf <vrf-id>] [twice-nat] [del]",
2469 .path =
"show nat44 summary",
2470 .short_help =
"show nat44 summary",
2499 .path =
"show nat44 addresses",
2500 .short_help =
"show nat44 addresses",
2515 .path =
"set interface nat44",
2517 .short_help =
"set interface nat44 in <intfc> out <intfc> [output-feature] " 2532 .path =
"show nat44 interfaces",
2533 .short_help =
"show nat44 interfaces",
2552 .path =
"nat44 add static mapping",
2555 "nat44 add static mapping tcp|udp|icmp local <addr> [<port>] " 2556 "external <addr> [<port>] [vrf <table-id>] [twice-nat|self-twice-nat] " 2557 "[out2in-only] [del]",
2574 .path =
"nat44 add identity mapping",
2576 .short_help =
"nat44 add identity mapping <ip4-addr>|external <interface> " 2577 "[<protocol> <port>] [vrf <table-id>] [del]",
2591 .path =
"nat44 add load-balancing static mapping",
2594 "nat44 add load-balancing static mapping protocol tcp|udp " 2595 "external <addr>:<port> local <addr>:<port> [vrf <table-id>] " 2596 "probability <n> [twice-nat|self-twice-nat] [out2in-only] " 2597 "[affinity <timeout-seconds>] [del]",
2610 .path =
"nat44 add load-balancing back-end",
2613 "nat44 add load-balancing back-end protocol tcp|udp " 2614 "external <addr>:<port> local <addr>:<port> [vrf <table-id>] " 2615 "probability <n> [del]",
2634 .path =
"show nat44 static mappings",
2635 .short_help =
"show nat44 static mappings",
2648 .path =
"nat44 add interface address",
2649 .short_help =
"nat44 add interface address <interface> [twice-nat] [del]",
2665 .path =
"show nat44 interface address",
2666 .short_help =
"show nat44 interface address",
2677 .path =
"show nat44 sessions",
2678 .short_help =
"show nat44 sessions [detail|metrics]",
2689 .path =
"set nat44 session limit",
2690 .short_help =
"set nat44 session limit <limit> [vrf <table-id>]",
2702 .path =
"nat44 del user",
2703 .short_help =
"nat44 del user <addr> [fib <index>]",
2715 .path =
"clear nat44 sessions",
2716 .short_help =
"clear nat44 sessions",
2730 .path =
"nat44 del session",
2731 .short_help =
"nat44 del session in|out <addr>:<port> tcp|udp|icmp [vrf <id>] [external-host <addr>:<port>]",
2748 .path =
"nat44 forwarding",
2749 .short_help =
"nat44 forwarding enable|disable",
2765 .path =
"nat44 deterministic add",
2766 .short_help =
"nat44 deterministic add in <addr>/<plen> out <addr>/<plen> [del]",
2783 .path =
"show nat44 deterministic mappings",
2784 .short_help =
"show nat44 deterministic mappings",
2799 .path =
"nat44 deterministic forward",
2800 .short_help =
"nat44 deterministic forward <addr>",
2814 .path =
"nat44 deterministic reverse",
2815 .short_help =
"nat44 deterministic reverse <addr>:<port>",
2831 .path =
"show nat44 deterministic sessions",
2832 .short_help =
"show nat44 deterministic sessions",
2845 .path =
"nat44 deterministic close session out",
2846 .short_help =
"nat44 deterministic close session out " 2847 "<out_addr>:<out_port> <ext_addr>:<ext_port>",
2860 .path =
"nat44 deterministic close session in",
2861 .short_help =
"nat44 deterministic close session in " 2862 "<in_addr>:<in_port> <ext_addr>:<ext_port>",
static clib_error_t * add_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * snat_det_reverse_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define nat_log_info(...)
#define vec_foreach_index(var, v)
Iterate over vector indices.
static clib_error_t * nat44_show_sessions_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Delete external address from NAT44 pool.
int nat64_set_udp_timeout(u32 timeout)
Set UDP session timeout.
nat_affinity_main_t nat_affinity_main
int nat44_del_session(snat_main_t *sm, ip4_address_t *addr, u16 port, nat_protocol_t proto, u32 vrf_id, int is_in)
Delete NAT44 session.
vnet_main_t * vnet_get_main(void)
#define SNAT_TCP_ESTABLISHED_TIMEOUT
static clib_error_t * nat44_set_session_limit_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
static clib_error_t * nat_ha_resync_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_add1(V, E)
Add 1 element to end of vector (unspecified alignment).
static void snat_det_ses_close(snat_det_map_t *dm, snat_det_session_t *ses)
static snat_det_session_t * snat_det_find_ses_by_in(snat_det_map_t *dm, ip4_address_t *in_addr, u16 in_port, snat_det_out_key_t out_key)
static void snat_det_forward(snat_det_map_t *dm, ip4_address_t *in_addr, ip4_address_t *out_addr, u16 *lo_port)
int nat44_del_ed_session(snat_main_t *sm, ip4_address_t *addr, u16 port, ip4_address_t *eh_addr, u16 eh_port, u8 proto, u32 vrf_id, int is_in)
Delete NAT44 endpoint-dependent session.
unformat_function_t unformat_vnet_sw_interface
snat_det_map_t * det_maps
static clib_error_t * add_identity_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat_ha_get_resync_status(u8 *in_resync, u32 *resync_ack_missed)
Get resync status.
static void snat_det_reverse(snat_det_map_t *dm, ip4_address_t *out_addr, u16 out_port, ip4_address_t *in_addr)
static clib_error_t * snat_det_close_session_out_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat44_show_summary_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_vnet_sw_if_index_name
int snat_interface_add_del(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 feature on the interface.
static clib_error_t * nat_show_ha_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_bihash_8_8_t user_hash
static clib_error_t * nat44_show_hash_commnad_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 max_translations_per_user
int nat_ha_resync(u32 client_index, u32 pid, nat_ha_resync_event_cb_t event_callback)
Resync HA (resend existing sessions to new failover)
#define pool_foreach(VAR, POOL, BODY)
Iterate through pool.
static clib_error_t * snat_det_map_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vl_api_interface_index_t sw_if_index
ip4_address_t ext_host_addr
clib_bihash_16_8_t affinity_hash
int snat_add_address(snat_main_t *sm, ip4_address_t *addr, u32 vrf_id, u8 twice_nat)
Add external address to NAT44 pool.
int nat64_set_icmp_timeout(u32 timeout)
Set ICMP session timeout.
static clib_error_t * snat_det_close_session_in_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * snat_det_forward_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define vec_elt_at_index(v, i)
Get vector value at index i checking that i is in bounds.
#define clib_error_return(e, args...)
int snat_ipfix_logging_enable_disable(int enable, u32 domain_id, u16 src_port)
Enable/disable NAT plugin IPFIX logging.
#define UNSUPPORTED_IN_DET_OR_ED_MODE_STR
static clib_error_t * nat44_set_alloc_addr_and_port_alg_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat_set_mss_clamping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int nat44_set_session_limit(u32 session_limit, u32 vrf_id)
Set NAT44 session limit (session limit, vrf id)
u32 * auto_add_sw_if_indices_twice_nat
vlib_worker_thread_t * vlib_worker_threads
static_always_inline int nat44_user_del(ip4_address_t *addr, u32 fib_index)
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
static clib_error_t * nat44_show_addresses_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
clib_bihash_16_8_t out2in_ed
static snat_det_map_t * snat_det_map_by_out(snat_main_t *sm, ip4_address_t *out_addr)
static clib_error_t * snat_forwarding_set_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat44_det_show_sessions_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
snat_static_mapping_t * static_mappings
static clib_error_t * nat44_del_user_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat_ha_get_listener(ip4_address_t *addr, u16 *port, u32 *path_mtu)
Get HA listener/local configuration.
void nat_ha_flush(u8 is_resync)
Flush the current HA data (for testing)
clib_bihash_8_8_t static_mapping_by_external
static clib_error_t * snat_feature_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat_set_alloc_addr_and_port_default(void)
Set address and port assignment algorithm to default/standard.
snat_interface_t * output_feature_interfaces
static clib_error_t * snat_set_log_level_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * add_lb_static_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * snat_ipfix_logging_enable_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 ft_table_id
Table ID (hash key) for this FIB.
static clib_error_t * nat_show_workers_commnad_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat44_show_interfaces_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat44_add_del_address_dpo(ip4_address_t addr, u8 is_add)
Add/delete external address to FIB DPO (out2in DPO mode)
sll srl srl sll sra u16x4 i
#define vec_free(V)
Free vector's memory (no header).
deterministic NAT definitions
format_function_t format_snat_static_map_to_resolve
int snat_interface_add_del_output_feature(u32 sw_if_index, u8 is_inside, int is_del)
Enable/disable NAT44 output feature on the interface (postrouting NAT)
format_function_t format_nat_addr_and_port_alloc_alg
static clib_error_t * set_timeout_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
u32 tcp_transitory_timeout
int nat_ha_set_listener(ip4_address_t *addr, u16 port, u32 path_mtu)
Set HA listener (local settings)
int snat_det_add_map(snat_main_t *sm, ip4_address_t *in_addr, u8 in_plen, ip4_address_t *out_addr, u8 out_plen, int is_add)
Add/delete deterministic NAT mapping.
static clib_error_t * nat_ha_failover_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define VLIB_CLI_COMMAND(x,...)
u32 * auto_add_sw_if_indices
static clib_error_t * nat_show_mss_clamping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static snat_det_map_t * snat_det_map_by_user(snat_main_t *sm, ip4_address_t *user_addr)
unformat_function_t unformat_nat_protocol
static clib_error_t * nat_ha_flush_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat_ha_listener_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void vlib_cli_output(vlib_main_t *vm, char *fmt,...)
int nat_ha_set_failover(ip4_address_t *addr, u16 port, u32 session_refresh_interval)
Set HA failover (remote settings)
void nat_set_alloc_addr_and_port_range(u16 start_port, u16 end_port)
Set address and port assignment algorithm for port range.
static clib_error_t * add_static_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define clib_bitmap_free(v)
Free a bitmap.
snat_address_t * twice_nat_addresses
static clib_error_t * nat44_del_session_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
NAT64 global declarations.
int nat64_set_tcp_timeouts(u32 trans, u32 est)
Set TCP session timeouts.
static clib_error_t * nat_show_timeouts_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static_always_inline void nat44_sessions_clear()
int nat44_lb_static_mapping_add_del_local(ip4_address_t e_addr, u16 e_port, ip4_address_t l_addr, u16 l_port, nat_protocol_t proto, u32 vrf_id, u8 probability, u8 is_add)
#define vec_len(v)
Number of elements in vector (rvalue-only, NULL tolerant)
#define UNSUPPORTED_IN_DET_MODE_STR
static_always_inline u8 nat_proto_to_ip_proto(nat_protocol_t nat_proto)
static clib_error_t * snat_add_interface_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
snat_main_per_thread_data_t * per_thread_data
fib_table_t * fib_table_get(fib_node_index_t index, fib_protocol_t proto)
Get a pointer to a FIB table.
snat_address_t * addresses
static clib_error_t * nat44_show_alloc_addr_and_port_alg_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int snat_add_interface_address(snat_main_t *sm, u32 sw_if_index, int is_del, u8 twice_nat)
Add/delete NAT44 pool address from specific interface.
static clib_error_t * nat44_show_interface_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat_ha_get_failover(ip4_address_t *addr, u16 *port, u32 *session_refresh_interval)
Get HA failover/remote settings.
static clib_error_t * nat44_show_static_mappings_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define UNSUPPORTED_IN_DET_OR_NON_ED_MODE_STR
static clib_error_t * add_lb_backend_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define SNAT_ICMP_TIMEOUT
static snat_det_session_t * snat_det_get_ses_by_out(snat_det_map_t *dm, ip4_address_t *in_addr, u64 out_key)
snat_static_map_resolve_t * to_resolve
static clib_error_t * nat44_clear_sessions_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static void increment_v4_address(ip4_address_t *a)
#define SUPPORTED_ONLY_IN_DET_MODE_STR
int snat_add_static_mapping(ip4_address_t l_addr, ip4_address_t e_addr, u16 l_port, u16 e_port, u32 vrf_id, int addr_only, u32 sw_if_index, nat_protocol_t proto, int is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u8 identity_nat)
Add/delete NAT44 static mapping.
#define vec_foreach(var, vec)
Vector iterator.
int nat44_add_del_lb_static_mapping(ip4_address_t e_addr, u16 e_port, nat_protocol_t proto, nat44_lb_addr_port_t *locals, u8 is_add, twice_nat_type_t twice_nat, u8 out2in_only, u8 *tag, u32 affinity)
Add/delete static mapping with load-balancing (multiple backends)
int snat_set_workers(uword *bitmap)
Set NAT plugin workers.
clib_bihash_16_8_t in2out_ed
void nat_set_alloc_addr_and_port_mape(u16 psid, u16 psid_offset, u16 psid_length)
Set address and port assignment algorithm for MAP-E CE.
NAT plugin client-IP based session affinity for load-balancing.
#define SNAT_TCP_TRANSITORY_TIMEOUT
snat_session_t * sessions
clib_bihash_8_8_t static_mapping_by_local
static clib_error_t * nat44_det_show_mappings_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * set_workers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
snat_interface_t * interfaces
u32 tcp_established_timeout
static uword pool_elts(void *v)
Number of active elements in a pool.