vlib_cli_output (vm, "%U",
format_bihash_8_8, &sm->static_mapping_by_external,
verbose);
+ vlib_cli_output (vm, "%U", format_bihash_16_8, &sm->out2in_ed, verbose);
vec_foreach_index (i, sm->per_thread_data)
{
tsm = vec_elt_at_index (sm->per_thread_data, i);
{
vlib_cli_output (vm, "%U", format_bihash_16_8, &tsm->in2out_ed,
verbose);
- vlib_cli_output (vm, "%U", format_bihash_16_8, &tsm->out2in_ed,
- verbose);
}
else
{
if (unformat (line_input, "disable"))
sm->mss_clamping = 0;
else if (unformat (line_input, "%d", &mss))
- {
- sm->mss_clamping = (u16) mss;
- sm->mss_value_net = clib_host_to_net_u16 (sm->mss_clamping);
- }
+ sm->mss_clamping = (u16) mss;
else
{
error = clib_error_return (0, "unknown input '%U'",
if (sm->deterministic || !sm->endpoint_dependent)
return clib_error_return (0, UNSUPPORTED_IN_DET_OR_NON_ED_MODE_STR);
- // print session configuration values
vlib_cli_output (vm, "max translations: %u", sm->max_translations);
vlib_cli_output (vm, "max translations per user: %u",
sm->max_translations_per_user);
u32 count = 0;
- u64 now = vlib_time_now (sm->vlib_main);
+ u64 now = vlib_time_now (vm);
u64 sess_timeout_time;
u32 udp_sessions = 0;
switch (s->in2out.protocol)
{
- case SNAT_PROTOCOL_ICMP:
+ case NAT_PROTOCOL_ICMP:
icmp_sessions++;
break;
- case SNAT_PROTOCOL_TCP:
+ case NAT_PROTOCOL_TCP:
tcp_sessions++;
if (s->state)
{
- if (s->tcp_close_timestamp)
+ if (s->tcp_closed_timestamp)
{
- if (now >= s->tcp_close_timestamp)
+ if (now >= s->tcp_closed_timestamp)
{
++transitory_closed;
}
else
established++;
break;
- case SNAT_PROTOCOL_UDP:
+ case NAT_PROTOCOL_UDP:
default:
udp_sessions++;
break;
switch (s->in2out.protocol)
{
- case SNAT_PROTOCOL_ICMP:
+ case NAT_PROTOCOL_ICMP:
icmp_sessions++;
break;
- case SNAT_PROTOCOL_TCP:
+ case NAT_PROTOCOL_TCP:
tcp_sessions++;
if (s->state)
{
- if (s->tcp_close_timestamp)
+ if (s->tcp_closed_timestamp)
{
- if (now >= s->tcp_close_timestamp)
+ if (now >= s->tcp_closed_timestamp)
{
++transitory_closed;
}
else
established++;
break;
- case SNAT_PROTOCOL_UDP:
+ case NAT_PROTOCOL_UDP:
default:
udp_sessions++;
break;
}));
/* *INDENT-ON* */
count = pool_elts (tsm->sessions);
+ if (sm->endpoint_dependent)
+ {
+ dlist_elt_t *oldest_elt;
+ u32 oldest_index;
+#define _(n, d) \
+ oldest_index = \
+ clib_dlist_remove_head (tsm->lru_pool, tsm->n##_lru_head_index); \
+ if (~0 != oldest_index) \
+ { \
+ oldest_elt = pool_elt_at_index (tsm->lru_pool, oldest_index); \
+ s = pool_elt_at_index (tsm->sessions, oldest_elt->value); \
+ sess_timeout_time = \
+ s->last_heard + (f64)nat44_session_get_timeout (sm, s); \
+ vlib_cli_output (vm, d " LRU min session timeout %llu (now %llu)", \
+ sess_timeout_time, now); \
+ clib_dlist_addhead (tsm->lru_pool, tsm->n##_lru_head_index, \
+ oldest_index); \
+ }
+ _(tcp_estab, "established tcp");
+ _(tcp_trans, "transitory tcp");
+ _(udp, "udp");
+ _(unk_proto, "unknown protocol");
+ _(icmp, "icmp");
+#undef _
+ }
}
vlib_cli_output (vm, "total timed out sessions: %u", timed_out);
vlib_cli_output (vm, " tenant VRF independent");
#define _(N, i, n, s) \
vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
- foreach_snat_protocol
+ foreach_nat_protocol
#undef _
}
vlib_cli_output (vm, "NAT44 twice-nat pool addresses:");
vlib_cli_output (vm, " tenant VRF independent");
#define _(N, i, n, s) \
vlib_cli_output (vm, " %d busy %s ports", ap->busy_##n##_ports, s);
- foreach_snat_protocol
+ foreach_nat_protocol
#undef _
}
/* *INDENT-ON* */
u32 sw_if_index = ~0;
vnet_main_t *vnm = vnet_get_main ();
int rv;
- snat_protocol_t proto = ~0;
+ nat_protocol_t proto = NAT_PROTOCOL_OTHER;
u8 proto_set = 0;
twice_nat_type_t twice_nat = TWICE_NAT_DISABLED;
u8 out2in_only = 0;
;
else if (unformat (line_input, "vrf %u", &vrf_id))
;
- else if (unformat (line_input, "%U", unformat_snat_protocol, &proto))
+ else if (unformat (line_input, "%U", unformat_nat_protocol, &proto))
proto_set = 1;
else if (unformat (line_input, "twice-nat"))
twice_nat = TWICE_NAT;
goto done;
}
- if (!addr_only && !proto_set)
+ if (addr_only)
{
- error = clib_error_return (0, "missing protocol");
+ if (proto_set)
+ {
+ error =
+ clib_error_return (0,
+ "address only mapping doesn't support protocol");
+ goto done;
+ }
+ }
+ else if (!proto_set)
+ {
+ error = clib_error_return (0, "protocol is required");
goto done;
}
u32 sw_if_index = ~0;
vnet_main_t *vnm = vnet_get_main ();
int rv;
- snat_protocol_t proto;
+ nat_protocol_t proto;
if (sm->deterministic)
return clib_error_return (0, UNSUPPORTED_IN_DET_MODE_STR);
;
else if (unformat (line_input, "vrf %u", &vrf_id))
;
- else if (unformat (line_input, "%U %u", unformat_snat_protocol, &proto,
+ else if (unformat (line_input, "%U %u", unformat_nat_protocol, &proto,
&port))
addr_only = 0;
else if (unformat (line_input, "del"))
u32 l_port = 0, e_port = 0, vrf_id = 0, probability = 0, affinity = 0;
int is_add = 1;
int rv;
- snat_protocol_t proto;
+ nat_protocol_t proto;
u8 proto_set = 0;
nat44_lb_addr_port_t *locals = 0, local;
twice_nat_type_t twice_nat = TWICE_NAT_DISABLED;
else if (unformat (line_input, "external %U:%u", unformat_ip4_address,
&e_addr, &e_port))
;
- else if (unformat (line_input, "protocol %U", unformat_snat_protocol,
+ else if (unformat (line_input, "protocol %U", unformat_nat_protocol,
&proto))
proto_set = 1;
else if (unformat (line_input, "twice-nat"))
u32 l_port = 0, e_port = 0, vrf_id = 0, probability = 0;
int is_add = 1;
int rv;
- snat_protocol_t proto;
+ nat_protocol_t proto;
u8 proto_set = 0;
if (sm->deterministic)
else if (unformat (line_input, "external %U:%u", unformat_ip4_address,
&e_addr, &e_port))
;
- else if (unformat (line_input, "protocol %U", unformat_snat_protocol,
+ else if (unformat (line_input, "protocol %U", unformat_nat_protocol,
&proto))
proto_set = 1;
else if (unformat (line_input, "del"))
clib_error_t *error = 0;
ip4_address_t addr, eh_addr;
u32 port = 0, eh_port = 0, vrf_id = sm->outside_vrf_id;
- snat_protocol_t proto;
+ nat_protocol_t proto;
int rv;
if (sm->deterministic)
{
if (unformat
(line_input, "%U:%u %U", unformat_ip4_address, &addr, &port,
- unformat_snat_protocol, &proto))
+ unformat_nat_protocol, &proto))
;
else if (unformat (line_input, "in"))
{
if (is_ed)
rv =
nat44_del_ed_session (sm, &addr, port, &eh_addr, eh_port,
- snat_proto_to_ip_proto (proto), vrf_id, is_in);
+ nat_proto_to_ip_proto (proto), vrf_id, is_in);
else
rv = nat44_del_session (sm, &addr, port, proto, vrf_id, is_in);
* vpp# nat44 add static mapping tcp local 10.0.0.3 6303 external 4.4.4.4 3606
* If not runnig "static mapping only" NAT plugin mode use before:
* vpp# nat44 add address 4.4.4.4
- * To create static mapping between local and external address use:
+ * To create address only static mapping between local and external address use:
* vpp# nat44 add static mapping local 10.0.0.3 external 4.4.4.4
+ * To create ICMP static mapping between local and external with ICMP echo
+ * identifier 10 use:
+ * vpp# nat44 add static mapping icmp local 10.0.0.3 10 external 4.4.4.4 10
* @cliexend
?*/
VLIB_CLI_COMMAND (add_static_mapping_command, static) = {
.path = "nat44 add static mapping",
.function = add_static_mapping_command_fn,
.short_help =
- "nat44 add static mapping tcp|udp|icmp local <addr> [<port>] "
- "external <addr> [<port>] [vrf <table-id>] [twice-nat|self-twice-nat] "
+ "nat44 add static mapping tcp|udp|icmp local <addr> [<port|icmp-echo-id>] "
+ "external <addr> [<port|icmp-echo-id>] [vrf <table-id>] [twice-nat|self-twice-nat] "
"[out2in-only] [del]",
};