29 #define UNSUPPORTED_IN_ED_MODE_STR \ 30 "This command is unsupported in endpoint dependent mode" 31 #define SUPPORTED_ONLY_IN_ED_MODE_STR \ 32 "This command is supported only in endpoint dependent mode" 60 if (!mode_set &&
unformat (line_input,
"static-mapping-only"))
64 if (
unformat (line_input,
"connection-tracking"))
69 else if (!mode_set &&
unformat (line_input,
"out2in-dpo"))
74 else if (!mode_set &&
unformat (line_input,
"endpoint-dependent"))
136 if (
unformat (line_input,
"%U", unformat_bitmap_list, &bitmap))
158 case VNET_API_ERROR_INVALID_WORKER:
161 case VNET_API_ERROR_FEATURE_DISABLED:
163 "Supported only if 2 or more workes available.");
212 if (!
unformat (line_input,
"%d", &log_level))
218 if (log_level > SNAT_LOG_DEBUG)
255 if (
unformat (line_input,
"domain %d", &domain_id))
257 else if (
unformat (line_input,
"src-port %d", &src_port))
259 else if (
unformat (line_input,
"disable"))
295 else if (
unformat (input,
"verbose"))
344 u32 psid, psid_offset, psid_length, port_start, port_end;
356 if (
unformat (line_input,
"default"))
360 (line_input,
"map-e psid %d psid-offset %d psid-len %d", &psid,
361 &psid_offset, &psid_length))
366 (line_input,
"port-range %d - %d", &port_start, &port_end))
368 if (port_end <= port_start)
372 "The end-port must be greater than start-port");
404 case NAT_ADDR_AND_PORT_ALLOC_ALG_MAPE:
408 case NAT_ADDR_AND_PORT_ALLOC_ALG_RANGE:
434 if (
unformat (line_input,
"disable"))
436 else if (
unformat (line_input,
"%d", &mss))
472 u32 port, session_refresh_interval = 10;
486 (line_input,
"refresh-interval %u", &session_refresh_interval))
524 else if (
unformat (line_input,
"path-mtu %u", &path_mtu))
550 u32 path_mtu, session_refresh_interval, resync_ack_missed;
569 session_refresh_interval);
578 vlib_cli_output (vm,
" completed (%d ACK missed)\n", resync_ack_missed);
610 u32 start_host_order, end_host_order;
624 if (
unformat (line_input,
"%U - %U",
628 else if (
unformat (line_input,
"tenant-vrf %u", &vrf_id))
632 else if (
unformat (line_input,
"twice-nat"))
634 else if (
unformat (line_input,
"del"))
650 start_host_order = clib_host_to_net_u32 (start_addr.
as_u32);
651 end_host_order = clib_host_to_net_u32 (end_addr.
as_u32);
653 if (end_host_order < start_host_order)
659 count = (end_host_order - start_host_order) + 1;
668 for (i = 0; i <
count; i++)
677 case VNET_API_ERROR_VALUE_EXIST:
680 case VNET_API_ERROR_NO_SUCH_ENTRY:
683 case VNET_API_ERROR_UNSPECIFIED:
687 case VNET_API_ERROR_FEATURE_DISABLED:
690 "twice NAT available only for endpoint-dependent mode.");
710 u64 now,
u64 sess_timeout_time)
719 clib_dlist_remove_head (tsm->lru_pool, tsm->n##_lru_head_index); \ 720 if (~0 != oldest_index) \ 722 oldest_elt = pool_elt_at_index (tsm->lru_pool, oldest_index); \ 723 s = pool_elt_at_index (tsm->sessions, oldest_elt->value); \ 724 sess_timeout_time = \ 725 s->last_heard + (f64)nat44_session_get_timeout (sm, s); \ 726 vlib_cli_output (vm, d " LRU min session timeout %llu (now %llu)", \ 727 sess_timeout_time, now); \ 728 clib_dlist_addhead (tsm->lru_pool, tsm->n##_lru_head_index, \ 731 _(tcp_estab,
"established tcp");
732 _(tcp_trans,
"transitory tcp");
734 _(unk_proto,
"unknown protocol");
753 u64 sess_timeout_time = 0;
755 u32 udp_sessions = 0;
756 u32 tcp_sessions = 0;
757 u32 icmp_sessions = 0;
761 u32 transitory_wait_closed = 0;
762 u32 transitory_closed = 0;
778 sess_timeout_time = s->last_heard +
780 if (now >= sess_timeout_time)
783 switch (s->nat_proto)
785 case NAT_PROTOCOL_ICMP:
788 case NAT_PROTOCOL_TCP:
792 if (s->tcp_closed_timestamp)
794 if (now >= s->tcp_closed_timestamp)
800 ++transitory_wait_closed;
808 case NAT_PROTOCOL_UDP:
825 sess_timeout_time = s->last_heard +
827 if (now >= sess_timeout_time)
830 switch (s->nat_proto)
832 case NAT_PROTOCOL_ICMP:
835 case NAT_PROTOCOL_TCP:
839 if (s->tcp_closed_timestamp)
841 if (now >= s->tcp_closed_timestamp)
847 ++transitory_wait_closed;
855 case NAT_PROTOCOL_UDP:
869 vlib_cli_output (vm,
"total tcp established sessions: %u", established);
871 vlib_cli_output (vm,
"total tcp transitory (WAIT-CLOSED) sessions: %u",
872 transitory_wait_closed);
897 #define _(N, i, n, s) \ 898 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s); 911 #define _(N, i, n, s) \ 912 vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s); 928 u32 *inside_sw_if_indices = 0;
929 u32 *outside_sw_if_indices = 0;
930 u8 is_output_feature = 0;
944 vec_add1 (inside_sw_if_indices, sw_if_index);
947 vec_add1 (outside_sw_if_indices, sw_if_index);
948 else if (
unformat (line_input,
"output-feature"))
949 is_output_feature = 1;
950 else if (
unformat (line_input,
"del"))
960 if (
vec_len (inside_sw_if_indices))
962 for (i = 0; i <
vec_len (inside_sw_if_indices); i++)
964 sw_if_index = inside_sw_if_indices[
i];
965 if (is_output_feature)
968 (sw_if_index, 1, is_del))
971 is_del ?
"del" :
"add",
982 is_del ?
"del" :
"add",
991 if (
vec_len (outside_sw_if_indices))
993 for (i = 0; i <
vec_len (outside_sw_if_indices); i++)
995 sw_if_index = outside_sw_if_indices[
i];
996 if (is_output_feature)
999 (sw_if_index, 0, is_del))
1002 is_del ?
"del" :
"add",
1013 is_del ?
"del" :
"add",
1071 u32 l_port = 0, e_port = 0,
vrf_id = ~0;
1072 int is_add = 1, addr_only = 1, rv, exact = 0;
1098 else if (
unformat (line_input,
"external %U %u",
1102 else if (
unformat (line_input,
"external %U",
1112 else if (
unformat (line_input,
"twice-nat"))
1114 else if (
unformat (line_input,
"self-twice-nat"))
1116 else if (
unformat (line_input,
"out2in-only"))
1118 else if (
unformat (line_input,
"del"))
1128 if (twice_nat && addr_only)
1140 "address only mapping doesn't support protocol");
1144 else if (!proto_set)
1151 clib_host_to_net_u16 (e_port),
1152 vrf_id, addr_only, sw_if_index, proto, is_add,
1153 twice_nat, out2in_only, 0, 0, exact_addr,
1158 case VNET_API_ERROR_INVALID_VALUE:
1161 case VNET_API_ERROR_NO_SUCH_ENTRY:
1167 case VNET_API_ERROR_NO_SUCH_FIB:
1170 case VNET_API_ERROR_VALUE_EXIST:
1173 case VNET_API_ERROR_FEATURE_DISABLED:
1176 "twice-nat/out2in-only available only for endpoint-dependent mode.");
1214 else if (
unformat (line_input,
"external %U",
1222 else if (
unformat (line_input,
"del"))
1234 clib_host_to_net_u16 (port),
vrf_id, addr_only,
1235 sw_if_index, proto, is_add, 0, 0, 0, 1,
1240 case VNET_API_ERROR_INVALID_VALUE:
1243 case VNET_API_ERROR_NO_SUCH_ENTRY:
1249 case VNET_API_ERROR_NO_SUCH_FIB:
1252 case VNET_API_ERROR_VALUE_EXIST:
1288 if (
unformat (line_input,
"local %U:%u probability %u",
1292 local.addr = l_addr;
1293 local.port = (
u16) l_port;
1297 else if (
unformat (line_input,
"local %U:%u vrf %u probability %u",
1302 local.addr = l_addr;
1303 local.port = (
u16) l_port;
1314 else if (
unformat (line_input,
"twice-nat"))
1316 else if (
unformat (line_input,
"self-twice-nat"))
1318 else if (
unformat (line_input,
"out2in-only"))
1320 else if (
unformat (line_input,
"del"))
1322 else if (
unformat (line_input,
"affinity %u", &affinity))
1345 is_add, twice_nat, out2in_only, 0,
1350 case VNET_API_ERROR_INVALID_VALUE:
1353 case VNET_API_ERROR_NO_SUCH_ENTRY:
1359 case VNET_API_ERROR_VALUE_EXIST:
1362 case VNET_API_ERROR_FEATURE_DISABLED:
1396 if (
unformat (line_input,
"local %U:%u probability %u",
1399 else if (
unformat (line_input,
"local %U:%u vrf %u probability %u",
1409 else if (
unformat (line_input,
"del"))
1419 if (!l_port || !e_port)
1438 case VNET_API_ERROR_INVALID_VALUE:
1442 case VNET_API_ERROR_NO_SUCH_ENTRY:
1445 case VNET_API_ERROR_VALUE_EXIST:
1448 case VNET_API_ERROR_FEATURE_DISABLED:
1452 case VNET_API_ERROR_UNSPECIFIED:
1509 else if (
unformat (line_input,
"twice-nat"))
1511 else if (
unformat (line_input,
"del"))
1585 if (
unformat (line_input,
"detail"))
1648 if (
unformat (line_input,
"%u", &session_limit))
1693 else if (
unformat (line_input,
"fib %u", &fib_index))
1733 int is_in = 0, is_ed = 0;
1750 else if (
unformat (line_input,
"in"))
1755 else if (
unformat (line_input,
"out"))
1765 &eh_addr, &eh_port))
1778 clib_host_to_net_u16 (eh_port),
1808 u8 forwarding_enable;
1809 u8 forwarding_enable_set = 0;
1818 if (!forwarding_enable_set &&
unformat (line_input,
"enable"))
1820 forwarding_enable = 1;
1821 forwarding_enable_set = 1;
1823 else if (!forwarding_enable_set &&
unformat (line_input,
"disable"))
1825 forwarding_enable = 0;
1826 forwarding_enable_set = 1;
1836 if (!forwarding_enable_set)
1865 else if (
unformat (line_input,
"tcp-established %u",
1867 else if (
unformat (line_input,
"tcp-transitory %u",
1870 else if (
unformat (line_input,
"reset"))
1916 if (
unformat (line_input,
"%u", &fib))
1938 per_vrf_sessions_t *per_vrf_sessions;
1947 per_vrf_sessions->rx_fib_index,
1948 per_vrf_sessions->tx_fib_index,
1949 per_vrf_sessions->ses_count,
1950 per_vrf_sessions->expired ?
"expired" :
"");
1961 .path =
"debug nat44 fib expire",
1962 .short_help =
"debug nat44 fib expire <fib-index>",
1969 .path =
"debug nat44 fib registration",
1970 .short_help =
"debug nat44 fib registration",
1993 .path =
"nat44 enable",
1994 .short_help =
"nat44 enable sessions <max-number> [users <max-number>] [static-mappig-only [connection-tracking]|out2in-dpo|endpoint-dependent] [inside-vrf <vrf-id>] [outside-vrf <vrf-id>] [user-sessions <max-number>]",
2007 .path =
"nat44 disable",
2008 .short_help =
"nat44 disable",
2020 .path =
"set nat workers",
2022 .short_help =
"set nat workers <workers-list>",
2036 .path =
"show nat workers",
2037 .short_help =
"show nat workers",
2051 .path =
"set nat timeout",
2054 "set nat timeout [udp <sec> | tcp-established <sec> " 2055 "tcp-transitory <sec> | icmp <sec> | reset]",
2070 .path =
"show nat timeouts",
2071 .short_help =
"show nat timeouts",
2083 .path =
"nat set logging level",
2085 .short_help =
"nat set logging level <level>",
2098 .path =
"nat ipfix logging",
2100 .short_help =
"nat ipfix logging [domain <domain-id>] [src-port <port>] [disable]",
2116 .path =
"nat addr-port-assignment-alg",
2117 .short_help =
"nat addr-port-assignment-alg <alg-name> [<alg-params>]",
2128 .path =
"show nat addr-port-assignment-alg",
2129 .short_help =
"show nat addr-port-assignment-alg",
2144 .path =
"nat mss-clamping",
2145 .short_help =
"nat mss-clamping <mss-value>|disable",
2156 .path =
"show nat mss-clamping",
2157 .short_help =
"show nat mss-clamping",
2168 .path =
"nat ha failover",
2169 .short_help =
"nat ha failover <ip4-address>:<port> [refresh-interval <sec>]",
2180 .path =
"nat ha listener",
2181 .short_help =
"nat ha listener <ip4-address>:<port> [path-mtu <path-mtu>]",
2192 .path =
"show nat ha",
2193 .short_help =
"show nat ha",
2204 .path =
"nat ha flush",
2205 .short_help =
"nat ha flush",
2216 .path =
"nat ha resync",
2217 .short_help =
"nat ha resync",
2228 .path =
"show nat44 hash tables",
2229 .short_help =
"show nat44 hash tables [detail|verbose]",
2245 .path =
"nat44 add address",
2246 .short_help =
"nat44 add address <ip4-range-start> [- <ip4-range-end>] " 2247 "[tenant-vrf <vrf-id>] [twice-nat] [del]",
2259 .path =
"show nat44 summary",
2260 .short_help =
"show nat44 summary",
2289 .path =
"show nat44 addresses",
2290 .short_help =
"show nat44 addresses",
2305 .path =
"set interface nat44",
2307 .short_help =
"set interface nat44 in <intfc> out <intfc> [output-feature] " 2322 .path =
"show nat44 interfaces",
2323 .short_help =
"show nat44 interfaces",
2347 .path =
"nat44 add static mapping",
2350 "nat44 add static mapping tcp|udp|icmp local <addr> [<port|icmp-echo-id>] " 2351 "external <addr> [<port|icmp-echo-id>] [vrf <table-id>] [twice-nat|self-twice-nat] " 2352 "[out2in-only] [exact <pool-addr>] [del]",
2369 .path =
"nat44 add identity mapping",
2371 .short_help =
"nat44 add identity mapping <ip4-addr>|external <interface> " 2372 "[<protocol> <port>] [vrf <table-id>] [del]",
2386 .path =
"nat44 add load-balancing static mapping",
2389 "nat44 add load-balancing static mapping protocol tcp|udp " 2390 "external <addr>:<port> local <addr>:<port> [vrf <table-id>] " 2391 "probability <n> [twice-nat|self-twice-nat] [out2in-only] " 2392 "[affinity <timeout-seconds>] [del]",
2405 .path =
"nat44 add load-balancing back-end",
2408 "nat44 add load-balancing back-end protocol tcp|udp " 2409 "external <addr>:<port> local <addr>:<port> [vrf <table-id>] " 2410 "probability <n> [del]",
2429 .path =
"show nat44 static mappings",
2430 .short_help =
"show nat44 static mappings",
2443 .path =
"nat44 add interface address",
2444 .short_help =
"nat44 add interface address <interface> [twice-nat] [del]",
2460 .path =
"show nat44 interface address",
2461 .short_help =
"show nat44 interface address",
2472 .path =
"show nat44 sessions",
2473 .short_help =
"show nat44 sessions [detail|metrics]",
2484 .path =
"set nat44 session limit",
2485 .short_help =
"set nat44 session limit <limit> [vrf <table-id>]",
2497 .path =
"nat44 del user",
2498 .short_help =
"nat44 del user <addr> [fib <index>]",
2510 .path =
"clear nat44 sessions",
2511 .short_help =
"clear nat44 sessions",
2525 .path =
"nat44 del session",
2526 .short_help =
"nat44 del session in|out <addr>:<port> tcp|udp|icmp [vrf <id>] [external-host <addr>:<port>]",
2543 .path =
"nat44 forwarding",
2544 .short_help =
"nat44 forwarding enable|disable",
static clib_error_t * add_address_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
#define UNSUPPORTED_IN_ED_MODE_STR
vl_api_address_t end_addr
u32 * max_translations_per_fib
#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)
clib_bihash_16_8_t out2in_ed
int snat_del_address(snat_main_t *sm, ip4_address_t addr, u8 delete_sm, u8 twice_nat)
Delete external address from NAT44 pool.
static clib_error_t * nat44_enable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
nat_affinity_main_t nat_affinity_main
struct nat_timeouts_t::@86 tcp
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)
static u32 nat44_session_get_timeout(snat_main_t *sm, snat_session_t *s)
#define pool_foreach(VAR, POOL)
Iterate through pool.
static void nat44_show_lru_summary(vlib_main_t *vm, snat_main_per_thread_data_t *tsm, u64 now, u64 sess_timeout_time)
static clib_error_t * nat44_set_session_limit_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vl_api_address_t start_addr
clib_memset(h->entries, 0, sizeof(h->entries[0]) *entries)
static f64 vlib_time_now(vlib_main_t *vm)
per_vrf_sessions_t * per_vrf_sessions_vec
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).
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
format_function_t format_snat_static_mapping
static clib_error_t * add_identity_mapping_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int nat_ipfix_logging_enable_disable(int enable, u32 domain_id, u16 src_port)
Enable/disable NAT plugin IPFIX logging.
void nat_ha_get_resync_status(u8 *in_resync, u32 *resync_ack_missed)
Get resync status.
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
static_always_inline void nat_reset_timeouts(nat_timeouts_t *timeouts)
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_debug_fib_expire_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
int nat44_plugin_enable(nat44_config_t c)
Enable NAT44 plugin.
#define nat_interface_is_outside(i)
Check if NAT interface is outside.
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.
#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...)
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)
u32 * auto_add_sw_if_indices_twice_nat
vlib_worker_thread_t * vlib_worker_threads
static clib_error_t * nat44_show_hash_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
nat_addr_and_port_alloc_alg_t addr_and_port_alloc_alg
int nat44_plugin_disable()
Disable NAT44 plugin.
static clib_error_t * nat44_show_addresses_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat44_disable_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * snat_forwarding_set_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
#define nat_interface_is_inside(i)
Check if NAT interface is inside.
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)
void expire_per_vrf_sessions(u32 fib_index)
vl_api_ip_port_and_mask_t src_port
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).
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)
int nat44_update_session_limit(u32 session_limit, u32 vrf_id)
Update NAT44 session limit flushing all data (session limit, vrf id)
static void increment_v4_address(ip4_address_t *a)
int nat_ha_set_listener(ip4_address_t *addr, u16 port, u32 path_mtu)
Set HA listener (local settings)
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)
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.
#define SUPPORTED_ONLY_IN_ED_MODE_STR
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)
format_function_t format_snat_session
static clib_error_t * nat_show_timeouts_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
void nat44_sessions_clear()
Free all NAT44 sessions.
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)
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)
static clib_error_t * add_lb_backend_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
format_function_t format_snat_user
snat_static_map_resolve_t * to_resolve
static clib_error_t * nat44_debug_fib_registration_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
static clib_error_t * nat44_clear_sessions_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
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 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.
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, ip4_address_t pool_addr, int exact)
Add/delete NAT44 static mapping.
clib_bihash_16_8_t in2out_ed
int nat44_ei_user_del(ip4_address_t *addr, u32 fib_index)
Delete specific NAT44 EI user and his sessions.
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.
snat_session_t * sessions
static unsigned char * print(const cJSON *const item, cJSON_bool format, const internal_hooks *const hooks)
clib_bihash_8_8_t static_mapping_by_local
static clib_error_t * set_workers_command_fn(vlib_main_t *vm, unformat_input_t *input, vlib_cli_command_t *cmd)
vl_api_interface_index_t sw_if_index
snat_interface_t * interfaces
static uword pool_elts(void *v)
Number of active elements in a pool.