dm->is_ce = 0;
+ /* Init counters */
+ dm->total_b4s.name = "total-b4s";
+ dm->total_b4s.stat_segment_name = "/dslite/total-b4s";
+ vlib_validate_simple_counter (&dm->total_b4s, 0);
+ vlib_zero_simple_counter (&dm->total_b4s, 0);
+ dm->total_sessions.name = "total-sessions";
+ dm->total_sessions.stat_segment_name = "/dslite/total-sessions";
+ vlib_validate_simple_counter (&dm->total_sessions, 0);
+ vlib_zero_simple_counter (&dm->total_sessions, 0);
+
dslite_dpo_module_init ();
}
u32 first_worker_index;
u16 port_per_thread;
+ /* counters/gauges */
+ vlib_simple_counter_main_t total_b4s;
+ vlib_simple_counter_main_t total_sessions;
+
/* If set then the DSLite component behaves as CPE/B4
* otherwise it behaves as AFTR */
u8 is_ce;
b4_index = b4_kv.value = b4 - dm->per_thread_data[thread_index].b4s;
clib_bihash_add_del_16_8 (&dm->per_thread_data[thread_index].b4_hash,
&b4_kv, 1);
+
+ vlib_set_simple_counter (&dm->total_b4s, thread_index, 0,
+ pool_elts (dm->
+ per_thread_data[thread_index].b4s));
}
else
{
clib_dlist_addtail (dm->per_thread_data[thread_index].list_pool,
s->per_b4_list_head_index,
elt - dm->per_thread_data[thread_index].list_pool);
+
+ vlib_set_simple_counter (&dm->total_sessions, thread_index, 0,
+ pool_elts (dm->per_thread_data
+ [thread_index].sessions));
}
s->in2out = *in2out_key;
/* add user */
if (clib_bihash_add_del_8_8 (&tsm->user_hash, &kv, 1))
nat_log_warn ("user_hash keay add failed");
+
+ vlib_set_simple_counter (&sm->total_users, thread_index, 0,
+ pool_elts (tsm->users));
}
else
{
per_user_translation_list_elt - tsm->list_pool);
s->user_index = u - tsm->users;
+ vlib_set_simple_counter (&sm->total_sessions, thread_index, 0,
+ pool_elts (tsm->sessions));
}
return s;
s->per_user_list_head_index,
per_user_translation_list_elt - tsm->list_pool);
}
+
+ vlib_set_simple_counter (&sm->total_sessions, thread_index, 0,
+ pool_elts (tsm->sessions));
}
return s;
nat_dpo_module_init ();
+ /* Init counters */
+ sm->total_users.name = "total-users";
+ sm->total_users.stat_segment_name = "/nat44/total-users";
+ vlib_validate_simple_counter (&sm->total_users, 0);
+ vlib_zero_simple_counter (&sm->total_users, 0);
+ sm->total_sessions.name = "total-sessions";
+ sm->total_sessions.stat_segment_name = "/nat44/total-sessions";
+ vlib_validate_simple_counter (&sm->total_sessions, 0);
+ vlib_zero_simple_counter (&sm->total_sessions, 0);
+
/* Init IPFIX logging */
snat_ipfix_logging_init (vm);
u16 mss_clamping;
u16 mss_value_net;
+ /* counters/gauges */
+ vlib_simple_counter_main_t total_users;
+ vlib_simple_counter_main_t total_sessions;
+
/* API message ID base */
u16 msg_id_base;
vec_add1 (im->add_del_interface_address_callbacks, cb4);
nm->ip4_main = im;
+ /* Init counters */
+ nm->total_bibs.name = "total-bibs";
+ nm->total_bibs.stat_segment_name = "/nat64/total-bibs";
+ vlib_validate_simple_counter (&nm->total_bibs, 0);
+ vlib_zero_simple_counter (&nm->total_bibs, 0);
+ nm->total_sessions.name = "total-sessions";
+ nm->total_sessions.stat_segment_name = "/nat64/total-sessions";
+ vlib_validate_simple_counter (&nm->total_sessions, 0);
+ vlib_zero_simple_counter (&nm->total_sessions, 0);
+
return 0;
}
/* Delete sessions using address */
/* *INDENT-OFF* */
vec_foreach (db, nm->db)
- nat64_db_free_out_addr (db, &a->addr);
+ {
+ nat64_db_free_out_addr (db, &a->addr);
+ vlib_set_simple_counter (&nm->total_bibs, db - nm->db, 0,
+ db->bib.bib_entries_num);
+ vlib_set_simple_counter (&nm->total_sessions, db - nm->db, 0,
+ db->st.st_entries_num);
+ }
#define _(N, id, n, s) \
clib_bitmap_free (a->busy_##n##_port_bitmap);
foreach_snat_protocol
continue;
if (static_bib->is_add)
- (void) nat64_db_bib_entry_create (db, &static_bib->in_addr,
- &static_bib->out_addr,
- static_bib->in_port,
- static_bib->out_port,
- static_bib->fib_index,
- static_bib->proto, 1);
+ {
+ (void) nat64_db_bib_entry_create (db, &static_bib->in_addr,
+ &static_bib->out_addr,
+ static_bib->in_port,
+ static_bib->out_port,
+ static_bib->fib_index,
+ static_bib->proto, 1);
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
+ }
else
{
addr.as_u64[0] = static_bib->in_addr.as_u64[0];
static_bib->proto,
static_bib->fib_index, 1);
if (bibe)
- nat64_db_bib_entry_free (db, bibe);
+ {
+ nat64_db_bib_entry_free (db, bibe);
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
+ vlib_set_simple_counter (&nm->total_sessions, thread_index, 0,
+ db->st.st_entries_num);
+ }
}
static_bib->done = 1;
fib_index, proto, 1);
if (!bibe)
return VNET_API_ERROR_UNSPECIFIED;
+
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
}
}
else
return VNET_API_ERROR_NO_SUCH_ENTRY;
if (!nm->sm->num_workers)
- nat64_db_bib_entry_free (db, bibe);
+ {
+ nat64_db_bib_entry_free (db, bibe);
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
+ }
}
if (nm->sm->num_workers)
u32 now = (u32) vlib_time_now (vm);
nad64_db_st_free_expired (db, now);
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
+ vlib_set_simple_counter (&nm->total_sessions, thread_index, 0,
+ db->st.st_entries_num);
return 0;
}
/* The process node which orcherstrates the cleanup */
u32 nat64_expire_walk_node_index;
+ /* counters/gauges */
+ vlib_simple_counter_main_t total_bibs;
+ vlib_simple_counter_main_t total_sessions;
+
ip4_main_t *ip4_main;
snat_main_t *sm;
} nat64_main_t;
sport, out_port, fib_index, proto, 0);
if (!bibe)
return -1;
+
+ vlib_set_simple_counter (&nm->total_bibs, ctx->thread_index, 0,
+ db->bib.bib_entries_num);
}
nat64_extract_ip4 (&ip6->dst_address, &daddr.ip4, fib_index);
&daddr.ip4, dport);
if (!ste)
return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, ctx->thread_index, 0,
+ db->st.st_entries_num);
}
ip4->src_address.as_u32 = bibe->out_addr.as_u32;
fib_index, IP_PROTOCOL_ICMP, 0);
if (!bibe)
return -1;
+
+ vlib_set_simple_counter (&nm->total_bibs, ctx->thread_index, 0,
+ db->bib.bib_entries_num);
}
nat64_extract_ip4 (&ip6->dst_address, &daddr.ip4, fib_index);
&daddr.ip4, 0);
if (!ste)
return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, ctx->thread_index, 0,
+ db->st.st_entries_num);
}
nat64_session_reset_timeout (ste, ctx->vm);
0);
if (!bibe)
return -1;
+
+ vlib_set_simple_counter (&nm->total_bibs, s_ctx->thread_index, 0,
+ db->bib.bib_entries_num);
}
nat64_extract_ip4 (&ip6->dst_address, &daddr.ip4, fib_index);
nat64_db_st_entry_create (db, bibe, &ip6->dst_address, &daddr.ip4, 0);
if (!ste)
return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, s_ctx->thread_index, 0,
+ db->st.st_entries_num);
}
nat64_session_reset_timeout (ste, s_ctx->vm);
sport, out_port, fib_index, proto, 0);
if (!bibe)
return -1;
+
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
}
nat64_extract_ip4 (&ip6->dst_address, &daddr.ip4, fib_index);
&daddr.ip4, dport);
if (!ste)
return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, thread_index, 0,
+ db->st.st_entries_num);
}
if (proto == IP_PROTOCOL_TCP)
0);
if (!bibe)
return -1;
+
+ vlib_set_simple_counter (&nm->total_bibs, thread_index, 0,
+ db->bib.bib_entries_num);
}
nat64_extract_ip4 (&ip6->dst_address, &daddr.ip4, fib_index);
nat64_db_st_entry_create (db, bibe, &ip6->dst_address, &daddr.ip4, 0);
if (!ste)
return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, thread_index, 0,
+ db->st.st_entries_num);
}
nat64_session_reset_timeout (ste, vm);
node->errors[NAT64_IN2OUT_ERROR_NO_TRANSLATION];
goto trace0;
}
+ vlib_set_simple_counter (&nm->total_bibs, thread_index,
+ 0, db->bib.bib_entries_num);
}
nat64_extract_ip4 (&ip60->dst_address, &daddr0.ip4,
fib_index0);
node->errors[NAT64_IN2OUT_ERROR_NO_TRANSLATION];
goto trace0;
}
+
+ vlib_set_simple_counter (&nm->total_sessions, thread_index,
+ 0, db->st.st_entries_num);
}
reass0->sess_index = nat64_db_st_entry_get_index (db, ste0);
nat64_compose_ip6 (&ip6_saddr, &ip4->src_address, bibe->fib_index);
ste =
nat64_db_st_entry_create (db, bibe, &ip6_saddr, &saddr.ip4, sport);
+
+ if (!ste)
+ return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, ctx->thread_index, 0,
+ db->st.st_entries_num);
}
ip6->src_address.as_u64[0] = ste->in_r_addr.as_u64[0];
nat64_compose_ip6 (&ip6_saddr, &ip4->src_address, bibe->fib_index);
ste =
nat64_db_st_entry_create (db, bibe, &ip6_saddr, &saddr.ip4, 0);
+
+ if (!ste)
+ return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, ctx->thread_index, 0,
+ db->st.st_entries_num);
}
nat64_session_reset_timeout (ste, ctx->vm);
nat64_compose_ip6 (&ip6_saddr, &ip4->src_address, bibe->fib_index);
ste = nat64_db_st_entry_create (db, bibe, &ip6_saddr, &saddr.ip4, 0);
+
+ if (!ste)
+ return -1;
+
+ vlib_set_simple_counter (&nm->total_sessions, ctx->thread_index, 0,
+ db->st.st_entries_num);
}
nat64_session_reset_timeout (ste, ctx->vm);
node->errors[NAT64_OUT2IN_ERROR_NO_TRANSLATION];
goto trace0;
}
+
+ vlib_set_simple_counter (&nm->total_sessions, thread_index,
+ 0, db->st.st_entries_num);
}
reass0->sess_index = nat64_db_st_entry_get_index (db, ste0);
reass0->thread_index = thread_index;
pool_put_index (tsm->list_pool, u->sessions_per_user_list_head_index);
pool_put (tsm->users, u);
clib_bihash_add_del_8_8 (&tsm->user_hash, &kv, 0);
+ vlib_set_simple_counter (&sm->total_users, thread_index, 0,
+ pool_elts (tsm->users));
}
}
clib_dlist_remove (tsm->list_pool, ses->per_user_index);
pool_put_index (tsm->list_pool, ses->per_user_index);
pool_put (tsm->sessions, ses);
+ vlib_set_simple_counter (&sm->total_sessions, thread_index, 0,
+ pool_elts (tsm->sessions));
u_key.addr = ses->in2out.addr;
u_key.fib_index = ses->in2out.fib_index;
""" Verify that there is no NAT44 user """
users = self.vapi.nat44_user_dump()
self.assertEqual(len(users), 0)
+ users = self.statistics.get_counter('/nat44/total-users')
+ self.assertEqual(users[0][0], 0)
+ sessions = self.statistics.get_counter('/nat44/total-sessions')
+ self.assertEqual(sessions[0][0], 0)
def verify_ipfix_max_entries_per_user(self, data, limit, src_addr):
"""
'/err/nat44-out2in/good out2in packets processed')
self.assertEqual(err - totaln, 3)
+ users = self.statistics.get_counter('/nat44/total-users')
+ self.assertEqual(users[0][0], 1)
+ sessions = self.statistics.get_counter('/nat44/total-sessions')
+ self.assertEqual(sessions[0][0], 3)
+
def test_dynamic_icmp_errors_in2out_ttl_1(self):
""" NAT44 handling of client packets with TTL=1 """
'/err/nat44-ed-out2in/good out2in packets processed')
self.assertEqual(err - totaln, 2)
+ users = self.statistics.get_counter('/nat44/total-users')
+ self.assertEqual(users[0][0], 1)
+ sessions = self.statistics.get_counter('/nat44/total-sessions')
+ self.assertEqual(sessions[0][0], 3)
+
def test_forwarding(self):
""" NAT44 forwarding test """
self.assertEqual(bibe.i_port, in_port)
self.assertEqual(bibe.o_port, out_port)
self.assertEqual(static_bib_num, 1)
+ bibs = self.statistics.get_counter('/nat64/total-bibs')
+ self.assertEqual(bibs[0][0], 1)
self.vapi.nat64_add_del_static_bib(in_addr,
out_addr,
if bibe.is_static:
static_bib_num += 1
self.assertEqual(static_bib_num, 0)
+ bibs = self.statistics.get_counter('/nat64/total-bibs')
+ self.assertEqual(bibs[0][0], 0)
def test_set_timeouts(self):
""" Set NAT64 timeouts """
'/err/nat64-out2in/good out2in packets processed')
self.assertEqual(err - totaln, 3)
+ bibs = self.statistics.get_counter('/nat64/total-bibs')
+ self.assertEqual(bibs[0][0], 3)
+ sessions = self.statistics.get_counter('/nat64/total-sessions')
+ self.assertEqual(sessions[0][0], 3)
+
# in2out
pkts = self.create_stream_in_ip6(self.pg0, self.pg1)
self.pg0.add_stream(pkts)
vrf_id=prefix.vrf_id,
is_add=0)
+ bibs = self.statistics.get_counter('/nat64/total-bibs')
+ self.assertEqual(bibs[0][0], 0)
+ sessions = self.statistics.get_counter('/nat64/total-sessions')
+ self.assertEqual(sessions[0][0], 0)
+
def tearDown(self):
super(TestNAT64, self).tearDown()
if not self.vpp_dead:
self.assertEqual(capture[IPv6].dst, self.pg1.remote_hosts[1].ip6)
self.assertTrue(capture.haslayer(ICMPv6EchoReply))
+ b4s = self.statistics.get_counter('/dslite/total-b4s')
+ self.assertEqual(b4s[0][0], 2)
+ sessions = self.statistics.get_counter('/dslite/total-sessions')
+ self.assertEqual(sessions[0][0], 3)
+
def tearDown(self):
super(TestDSlite, self).tearDown()
if not self.vpp_dead: