aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/nat44_classify.c
diff options
context:
space:
mode:
authorMatus Fabian <matfabia@cisco.com>2018-12-14 01:55:16 -0800
committerOle Trøan <otroan@employees.org>2018-12-14 19:47:37 +0000
commita5e73762d585e9fa405b56ebd9f5c78d12c4d1f9 (patch)
treecba204cb7851c1cf2935d92f3f102eaae1703d95 /src/plugins/nat/nat44_classify.c
parent2eca70db953c21d2cb797ad7a172e9b1c0ccd299 (diff)
NAT: counters (VPP-1484)
Change-Id: I5d1852a09712adfe7547c200d161539736aca6f5 Signed-off-by: Matus Fabian <matfabia@cisco.com>
Diffstat (limited to 'src/plugins/nat/nat44_classify.c')
-rw-r--r--src/plugins/nat/nat44_classify.c27
1 files changed, 22 insertions, 5 deletions
diff --git a/src/plugins/nat/nat44_classify.c b/src/plugins/nat/nat44_classify.c
index 8608fc532e2..8a417dcf5d9 100644
--- a/src/plugins/nat/nat44_classify.c
+++ b/src/plugins/nat/nat44_classify.c
@@ -31,7 +31,10 @@ vlib_node_registration_t nat44_handoff_classify_node;
#define foreach_nat44_classify_error \
_(MAX_REASS, "Maximum reassemblies exceeded") \
-_(MAX_FRAG, "Maximum fragments per reassembly exceeded")
+_(MAX_FRAG, "Maximum fragments per reassembly exceeded") \
+_(NEXT_IN2OUT, "next in2out") \
+_(NEXT_OUT2IN, "next out2in") \
+_(FRAG_CACHED, "fragment cached")
typedef enum
{
@@ -93,6 +96,7 @@ nat44_classify_node_fn_inline (vlib_main_t * vm,
snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
u32 *fragments_to_drop = 0;
u32 *fragments_to_loopback = 0;
+ u32 next_in2out = 0, next_out2in = 0, frag_cached = 0;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -361,12 +365,18 @@ nat44_classify_node_fn_inline (vlib_main_t * vm,
{
n_left_to_next++;
to_next--;
+ frag_cached++;
}
else
- /* verify speculative enqueue, maybe switch current next frame */
- vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
- to_next, n_left_to_next,
- bi0, next0);
+ {
+ next_in2out += next0 == NAT44_CLASSIFY_NEXT_IN2OUT;
+ next_out2in += next0 == NAT44_CLASSIFY_NEXT_OUT2IN;
+
+ /* verify speculative enqueue, maybe switch current next frame */
+ vlib_validate_buffer_enqueue_x1 (vm, node, next_index,
+ to_next, n_left_to_next,
+ bi0, next0);
+ }
if (n_left_from == 0 && vec_len (fragments_to_loopback))
{
@@ -398,6 +408,13 @@ nat44_classify_node_fn_inline (vlib_main_t * vm,
vec_free (fragments_to_drop);
+ vlib_node_increment_counter (vm, node->node_index,
+ NAT44_CLASSIFY_ERROR_NEXT_IN2OUT, next_in2out);
+ vlib_node_increment_counter (vm, node->node_index,
+ NAT44_CLASSIFY_ERROR_NEXT_OUT2IN, next_out2in);
+ vlib_node_increment_counter (vm, node->node_index,
+ NAT44_CLASSIFY_ERROR_FRAG_CACHED, frag_cached);
+
return frame->n_vectors;
}