diff options
Diffstat (limited to 'src/plugins/nat/nat66')
-rw-r--r-- | src/plugins/nat/nat66/nat66.c | 14 | ||||
-rw-r--r-- | src/plugins/nat/nat66/nat66.h | 3 | ||||
-rw-r--r-- | src/plugins/nat/nat66/nat66_in2out.c | 11 | ||||
-rw-r--r-- | src/plugins/nat/nat66/nat66_out2in.c | 11 |
4 files changed, 27 insertions, 12 deletions
diff --git a/src/plugins/nat/nat66/nat66.c b/src/plugins/nat/nat66/nat66.c index 36d5d733a6d..0a90f732b95 100644 --- a/src/plugins/nat/nat66/nat66.c +++ b/src/plugins/nat/nat66/nat66.c @@ -70,9 +70,22 @@ nat66_init (vlib_main_t * vm) FIB_SOURCE_PRIORITY_HI, FIB_SOURCE_BH_SIMPLE); + nm->in2out_packets.name = "in2out"; + nm->in2out_packets.stat_segment_name = "/nat64/in2out"; + nm->out2in_packets.name = "out2in"; + nm->out2in_packets.stat_segment_name = "/nat64/out2in"; return nat66_plugin_api_hookup (vm); } +static void +nat66_validate_counters (nat66_main_t * nm, u32 sw_if_index) +{ + vlib_validate_simple_counter (&nm->in2out_packets, sw_if_index); + vlib_zero_simple_counter (&nm->in2out_packets, sw_if_index); + vlib_validate_simple_counter (&nm->out2in_packets, sw_if_index); + vlib_zero_simple_counter (&nm->out2in_packets, sw_if_index); +} + int nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add) { @@ -101,6 +114,7 @@ nat66_interface_add_del (u32 sw_if_index, u8 is_inside, u8 is_add) interface->flags = is_inside ? NAT66_INTERFACE_FLAG_IS_INSIDE : NAT66_INTERFACE_FLAG_IS_OUTSIDE; + nat66_validate_counters (nm, sw_if_index); } else { diff --git a/src/plugins/nat/nat66/nat66.h b/src/plugins/nat/nat66/nat66.h index 9757f030032..42dd7ca0eb2 100644 --- a/src/plugins/nat/nat66/nat66.h +++ b/src/plugins/nat/nat66/nat66.h @@ -74,6 +74,9 @@ typedef struct u16 msg_id_base; u8 log_level; + + vlib_simple_counter_main_t in2out_packets; + vlib_simple_counter_main_t out2in_packets;; } nat66_main_t; #define nat66_elog(_level, _str) \ diff --git a/src/plugins/nat/nat66/nat66_in2out.c b/src/plugins/nat/nat66/nat66_in2out.c index 5a027e2cd50..4c4d3ab0299 100644 --- a/src/plugins/nat/nat66/nat66_in2out.c +++ b/src/plugins/nat/nat66/nat66_in2out.c @@ -42,7 +42,6 @@ format_nat66_in2out_trace (u8 * s, va_list * args) } #define foreach_nat66_in2out_error \ -_(IN2OUT_PACKETS, "good in2out packets processed") \ _(NO_TRANSLATION, "no translation") \ _(UNKNOWN, "unknown") @@ -113,7 +112,6 @@ VLIB_NODE_FN (nat66_in2out_node) (vlib_main_t * vm, { u32 n_left_from, *from, *to_next; nat66_in2out_next_t next_index; - u32 pkts_processed = 0; u32 thread_index = vm->thread_index; nat66_main_t *nm = &nat66_main; @@ -221,7 +219,11 @@ VLIB_NODE_FN (nat66_in2out_node) (vlib_main_t * vm, t->next_index = next0; } - pkts_processed += next0 != NAT66_IN2OUT_NEXT_DROP; + if (next0 != NAT66_IN2OUT_NEXT_DROP) + { + vlib_increment_simple_counter (&nm->in2out_packets, + thread_index, sw_if_index0, 1); + } /* verify speculative enqueue, maybe switch current next frame */ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, @@ -230,9 +232,6 @@ VLIB_NODE_FN (nat66_in2out_node) (vlib_main_t * vm, vlib_put_next_frame (vm, node, next_index, n_left_to_next); } - vlib_node_increment_counter (vm, nm->in2out_node_index, - NAT66_IN2OUT_ERROR_IN2OUT_PACKETS, - pkts_processed); return frame->n_vectors; } diff --git a/src/plugins/nat/nat66/nat66_out2in.c b/src/plugins/nat/nat66/nat66_out2in.c index 563ad6f5178..9d44b4880eb 100644 --- a/src/plugins/nat/nat66/nat66_out2in.c +++ b/src/plugins/nat/nat66/nat66_out2in.c @@ -42,7 +42,6 @@ format_nat66_out2in_trace (u8 * s, va_list * args) } #define foreach_nat66_out2in_error \ -_(OUT2IN_PACKETS, "good out2in packets processed") \ _(NO_TRANSLATION, "no translation") \ _(UNKNOWN, "unknown") @@ -73,7 +72,6 @@ VLIB_NODE_FN (nat66_out2in_node) (vlib_main_t * vm, { u32 n_left_from, *from, *to_next; nat66_out2in_next_t next_index; - u32 pkts_processed = 0; u32 thread_index = vm->thread_index; nat66_main_t *nm = &nat66_main; @@ -179,7 +177,11 @@ VLIB_NODE_FN (nat66_out2in_node) (vlib_main_t * vm, t->next_index = next0; } - pkts_processed += next0 != NAT66_OUT2IN_NEXT_DROP; + if (next0 != NAT66_OUT2IN_NEXT_DROP) + { + vlib_increment_simple_counter (&nm->out2in_packets, + thread_index, sw_if_index0, 1); + } /* verify speculative enqueue, maybe switch current next frame */ vlib_validate_buffer_enqueue_x1 (vm, node, next_index, to_next, @@ -188,9 +190,6 @@ VLIB_NODE_FN (nat66_out2in_node) (vlib_main_t * vm, vlib_put_next_frame (vm, node, next_index, n_left_to_next); } - vlib_node_increment_counter (vm, nm->out2in_node_index, - NAT66_OUT2IN_ERROR_OUT2IN_PACKETS, - pkts_processed); return frame->n_vectors; } |