#include <vnet/fib/ip4_fib.h>
#include <vnet/udp/udp_local.h>
#include <vppinfra/error.h>
-#include <nat/nat.h>
-#include <nat/lib/ipfix_logging.h>
-#include <nat/nat_inlines.h>
-#include <nat/nat44/inlines.h>
+
#include <nat/lib/nat_syslog.h>
-#include <nat/nat44/ed_inlines.h>
+#include <nat/lib/ipfix_logging.h>
+
+#include <nat/nat44-ed/nat44_ed.h>
+#include <nat/nat44-ed/nat44_ed_inlines.h>
static char *nat_out2in_ed_error_strings[] = {
#define _(sym,string) string,
u16 * port,
u16 port_per_thread, u32 snat_thread_index)
{
+ snat_main_t *sm = &snat_main;
u32 portnum;
switch (proto)
break;
foreach_nat_protocol
#undef _
- default:
- nat_elog_info ("unknown protocol");
+ default : nat_elog_info (sm, "unknown protocol");
return 1;
}
u16 port_per_thread,
u32 snat_thread_index)
{
- int i;
+ snat_main_t *sm = &snat_main;
snat_address_t *a, *ga = 0;
u32 portnum;
+ int i;
for (i = 0; i < vec_len (addresses); i++)
{
break;
foreach_nat_protocol
#undef _
- default : nat_elog_info ("unknown protocol");
+ default : nat_elog_info (sm, "unknown protocol");
return 1;
}
}
break;
foreach_nat_protocol
#undef _
- default : nat_elog_info ("unknown protocol");
+ default : nat_elog_info (sm, "unknown protocol");
return 1;
}
}
(nat44_ed_maximum_sessions_exceeded (sm, rx_fib_index, thread_index)))
{
b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
- nat_elog_notice ("maximum sessions exceeded");
+ nat_elog_notice (sm, "maximum sessions exceeded");
return 0;
}
s = nat_ed_session_alloc (sm, thread_index, now, nat_proto);
if (!s)
{
- b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_USER_SESS_EXCEEDED];
- nat_elog_warn ("create NAT session failed");
+ b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
+ nat_elog_warn (sm, "create NAT session failed");
return 0;
}
{
b->error = node->errors[NAT_OUT2IN_ED_ERROR_HASH_ADD_FAILED];
nat_ed_session_delete (sm, s, thread_index, 1);
- nat_elog_warn ("out2in flow hash add failed");
+ nat_elog_warn (sm, "out2in flow hash add failed");
return 0;
}
b->error = node->errors[NAT_OUT2IN_ED_ERROR_OUT_OF_PORTS];
if (nat_ed_ses_o2i_flow_hash_add_del (sm, thread_index, s, 0))
{
- nat_elog_warn ("out2in flow hash del failed");
+ nat_elog_warn (sm, "out2in flow hash del failed");
}
snat_free_outside_address_and_port (
sm->twice_nat_addresses, thread_index, &s->ext_host_nat_addr,
if (nat_ed_ses_i2o_flow_hash_add_del (sm, thread_index, s, 1))
{
- nat_elog_notice ("in2out flow hash add failed");
+ nat_elog_notice (sm, "in2out flow hash add failed");
if (nat_ed_ses_o2i_flow_hash_add_del (sm, thread_index, s, 0))
{
- nat_elog_warn ("out2in flow hash del failed");
+ nat_elog_warn (sm, "out2in flow hash del failed");
}
nat_ed_session_delete (sm, s, thread_index, 1);
return 0;
s->in2out.port,
s->out2in.port, s->in2out.fib_index);
- nat_syslog_nat44_sadd (s->user_index, s->in2out.fib_index,
- &s->in2out.addr, s->in2out.port,
- &s->ext_host_nat_addr, s->ext_host_nat_port,
- &s->out2in.addr, s->out2in.port,
- &s->ext_host_addr, s->ext_host_port,
- s->nat_proto, is_twice_nat_session (s));
+ nat_syslog_nat44_sadd (0, s->in2out.fib_index, &s->in2out.addr,
+ s->in2out.port, &s->ext_host_nat_addr,
+ s->ext_host_nat_port, &s->out2in.addr, s->out2in.port,
+ &s->ext_host_addr, s->ext_host_port, s->nat_proto,
+ is_twice_nat_session (s));
per_vrf_sessions_register_session (s, thread_index);
s = nat_ed_session_alloc (sm, thread_index, now, ip->protocol);
if (!s)
{
- nat_elog_warn ("create NAT session failed");
+ nat_elog_warn (sm, "create NAT session failed");
return;
}
nat_6t_flow_txfib_rewrite_set (&s->i2o, rx_fib_index);
if (nat_ed_ses_i2o_flow_hash_add_del (sm, thread_index, s, 1))
{
- nat_elog_notice ("in2out flow add failed");
+ nat_elog_notice (sm, "in2out flow add failed");
nat_ed_session_delete (sm, s, thread_index, 1);
return;
}
nat44_ed_maximum_sessions_exceeded (sm, rx_fib_index, thread_index)))
{
b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
- nat_elog_notice ("maximum sessions exceeded");
+ nat_elog_notice (sm, "maximum sessions exceeded");
return 0;
}
s = nat_ed_session_alloc (sm, thread_index, now, ip->protocol);
if (!s)
{
- b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_USER_SESS_EXCEEDED];
- nat_elog_warn ("create NAT session failed");
+ b->error = node->errors[NAT_OUT2IN_ED_ERROR_MAX_SESSIONS_EXCEEDED];
+ nat_elog_warn (sm, "create NAT session failed");
return 0;
}
nat_6t_flow_saddr_rewrite_set (&s->i2o, ip->dst_address.as_u32);
if (nat_ed_ses_i2o_flow_hash_add_del (sm, thread_index, s, 1))
{
- nat_elog_notice ("in2out key add failed");
+ nat_elog_notice (sm, "in2out key add failed");
nat_ed_session_delete (sm, s, thread_index, 1);
return NULL;
}
nat_6t_flow_txfib_rewrite_set (&s->o2i, m->fib_index);
if (nat_ed_ses_o2i_flow_hash_add_del (sm, thread_index, s, 1))
{
- nat_elog_notice ("out2in flow hash add failed");
+ nat_elog_notice (sm, "out2in flow hash add failed");
nat_ed_session_delete (sm, s, thread_index, 1);
return NULL;
}
switch (proto0)
{
case NAT_PROTOCOL_TCP:
- vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.tcp,
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in.tcp,
thread_index, sw_if_index0, 1);
nat44_set_tcp_session_state_o2i (sm, now, s0,
vnet_buffer (b0)->ip.
thread_index);
break;
case NAT_PROTOCOL_UDP:
- vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.udp,
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in.udp,
thread_index, sw_if_index0, 1);
break;
case NAT_PROTOCOL_ICMP:
- vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.icmp,
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in.icmp,
thread_index, sw_if_index0, 1);
break;
case NAT_PROTOCOL_OTHER:
- vlib_increment_simple_counter (
- &sm->counters.fastpath.out2in_ed.other, thread_index, sw_if_index0,
- 1);
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in.other,
+ thread_index, sw_if_index0, 1);
break;
}
if (next[0] == NAT_NEXT_DROP)
{
- vlib_increment_simple_counter (&sm->counters.fastpath.
- out2in_ed.drops, thread_index,
- sw_if_index0, 1);
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in.drops,
+ thread_index, sw_if_index0, 1);
}
n_left_from--;
goto trace0;
}
- vlib_increment_simple_counter (&sm->counters.slowpath.
- out2in_ed.other, thread_index,
- sw_if_index0, 1);
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in.other,
+ thread_index, sw_if_index0, 1);
goto trace0;
}
goto trace0;
}
- vlib_increment_simple_counter (&sm->counters.slowpath.
- out2in_ed.icmp, thread_index,
- sw_if_index0, 1);
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in.icmp,
+ thread_index, sw_if_index0, 1);
goto trace0;
}
if (PREDICT_TRUE (proto0 == NAT_PROTOCOL_TCP))
{
- vlib_increment_simple_counter (&sm->counters.slowpath.out2in_ed.tcp,
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in.tcp,
thread_index, sw_if_index0, 1);
nat44_set_tcp_session_state_o2i (sm, now, s0,
vnet_buffer (b0)->ip.
}
else
{
- vlib_increment_simple_counter (&sm->counters.slowpath.out2in_ed.udp,
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in.udp,
thread_index, sw_if_index0, 1);
}
if (next[0] == NAT_NEXT_DROP)
{
- vlib_increment_simple_counter (&sm->counters.slowpath.
- out2in_ed.drops, thread_index,
- sw_if_index0, 1);
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in.drops,
+ thread_index, sw_if_index0, 1);
}
n_left_from--;