summaryrefslogtreecommitdiffstats
path: root/src/plugins/nat/out2in_ed.c
diff options
context:
space:
mode:
authorKlement Sekera <ksekera@cisco.com>2020-07-16 07:54:10 +0000
committerOle Trøan <otroan@employees.org>2020-08-13 08:34:33 +0000
commitde118da58e80aec43f4b816a1ea957634a8bc07c (patch)
tree16de15d96990fdc6dd9eaf17be405daa2980d790 /src/plugins/nat/out2in_ed.c
parentfbecd936bd40e590031ec6d7ff81c3f8827f9f18 (diff)
nat: remove non-error error counters
Some statistics counters were implemented as error counters. Move them to stat segment, where they belong. Type: improvement Change-Id: I5600bec1b4e0496282297374ec1e79d909cdaf8a Signed-off-by: Klement Sekera <ksekera@cisco.com>
Diffstat (limited to 'src/plugins/nat/out2in_ed.c')
-rw-r--r--src/plugins/nat/out2in_ed.c89
1 files changed, 34 insertions, 55 deletions
diff --git a/src/plugins/nat/out2in_ed.c b/src/plugins/nat/out2in_ed.c
index 05fc75fac71..56906369ca6 100644
--- a/src/plugins/nat/out2in_ed.c
+++ b/src/plugins/nat/out2in_ed.c
@@ -675,15 +675,11 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
vlib_frame_t * frame,
int is_multi_worker)
{
- u32 n_left_from, *from, pkts_processed = 0, stats_node_index;
+ u32 n_left_from, *from;
snat_main_t *sm = &snat_main;
f64 now = vlib_time_now (vm);
u32 thread_index = vm->thread_index;
snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
- u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
- 0, fragments = 0;
-
- stats_node_index = sm->ed_out2in_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -867,10 +863,10 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
}
tcp0->checksum = ip_csum_fold (sum0);
}
- tcp_packets++;
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.tcp,
+ thread_index, sw_if_index0, 1);
if (nat44_set_tcp_session_state_o2i
- (sm, now, s0,
- vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags,
+ (sm, now, s0, vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags,
vnet_buffer (b0)->ip.reass.tcp_ack_number,
vnet_buffer (b0)->ip.reass.tcp_seq_number, thread_index))
goto trace0;
@@ -898,7 +894,8 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
ip0->src_address.as_u32 = s0->ext_host_nat_addr.as_u32;
}
udp0->checksum = ip_csum_fold (sum0);
- udp_packets++;
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.udp,
+ thread_index, sw_if_index0, 1);
}
else
{
@@ -911,7 +908,8 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
ip0->src_address.as_u32 = s0->ext_host_nat_addr.as_u32;
}
}
- udp_packets++;
+ vlib_increment_simple_counter (&sm->counters.fastpath.out2in_ed.udp,
+ thread_index, sw_if_index0, 1);
}
/* Accounting */
@@ -937,7 +935,12 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
t->session_index = ~0;
}
- pkts_processed += next[0] == vnet_buffer2 (b0)->nat.arc_next;
+ if (next[0] == NAT_NEXT_DROP)
+ {
+ vlib_increment_simple_counter (&sm->counters.fastpath.
+ out2in_ed.drops, thread_index,
+ sw_if_index0, 1);
+ }
n_left_from--;
next++;
@@ -945,22 +948,6 @@ nat44_ed_out2in_fast_path_node_fn_inline (vlib_main_t * vm,
vlib_buffer_enqueue_to_next (vm, node, from, (u16 *) nexts,
frame->n_vectors);
-
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_OUT2IN_PACKETS,
- pkts_processed);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_TCP_PACKETS, tcp_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_UDP_PACKETS, udp_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_ICMP_PACKETS,
- icmp_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_OTHER_PACKETS,
- other_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_FRAGMENTS, fragments);
return frame->n_vectors;
}
@@ -969,15 +956,11 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
vlib_frame_t * frame)
{
- u32 n_left_from, *from, pkts_processed = 0, stats_node_index;
+ u32 n_left_from, *from;
snat_main_t *sm = &snat_main;
f64 now = vlib_time_now (vm);
u32 thread_index = vm->thread_index;
snat_main_per_thread_data_t *tsm = &sm->per_thread_data[thread_index];
- u32 tcp_packets = 0, udp_packets = 0, icmp_packets = 0, other_packets =
- 0, fragments = 0;
-
- stats_node_index = sm->ed_out2in_slowpath_node_index;
from = vlib_frame_vector_args (frame);
n_left_from = frame->n_vectors;
@@ -1040,7 +1023,9 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
if (!s0)
next[0] = NAT_NEXT_DROP;
}
- other_packets++;
+ vlib_increment_simple_counter (&sm->counters.slowpath.
+ out2in_ed.other, thread_index,
+ sw_if_index0, 1);
goto trace0;
}
@@ -1049,7 +1034,9 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
next[0] = icmp_out2in_ed_slow_path
(sm, b0, ip0, icmp0, sw_if_index0, rx_fib_index0, node,
next[0], now, thread_index, &s0);
- icmp_packets++;
+ vlib_increment_simple_counter (&sm->counters.slowpath.
+ out2in_ed.icmp, thread_index,
+ sw_if_index0, 1);
goto trace0;
}
@@ -1194,10 +1181,10 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
}
tcp0->checksum = ip_csum_fold (sum0);
}
- tcp_packets++;
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in_ed.tcp,
+ thread_index, sw_if_index0, 1);
if (nat44_set_tcp_session_state_o2i
- (sm, now, s0,
- vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags,
+ (sm, now, s0, vnet_buffer (b0)->ip.reass.icmp_type_or_tcp_flags,
vnet_buffer (b0)->ip.reass.tcp_ack_number,
vnet_buffer (b0)->ip.reass.tcp_seq_number, thread_index))
goto trace0;
@@ -1224,7 +1211,8 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
ip0->src_address.as_u32 = s0->ext_host_nat_addr.as_u32;
}
udp0->checksum = ip_csum_fold (sum0);
- udp_packets++;
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in_ed.udp,
+ thread_index, sw_if_index0, 1);
}
else
{
@@ -1237,7 +1225,8 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
ip0->src_address.as_u32 = s0->ext_host_nat_addr.as_u32;
}
}
- udp_packets++;
+ vlib_increment_simple_counter (&sm->counters.slowpath.out2in_ed.udp,
+ thread_index, sw_if_index0, 1);
}
/* Accounting */
@@ -1263,7 +1252,12 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
t->session_index = ~0;
}
- pkts_processed += next[0] == vnet_buffer2 (b0)->nat.arc_next;
+ if (next[0] == NAT_NEXT_DROP)
+ {
+ vlib_increment_simple_counter (&sm->counters.slowpath.
+ out2in_ed.drops, thread_index,
+ sw_if_index0, 1);
+ }
n_left_from--;
next++;
@@ -1273,21 +1267,6 @@ nat44_ed_out2in_slow_path_node_fn_inline (vlib_main_t * vm,
vlib_buffer_enqueue_to_next (vm, node, from, (u16 *) nexts,
frame->n_vectors);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_OUT2IN_PACKETS,
- pkts_processed);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_TCP_PACKETS, tcp_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_UDP_PACKETS, udp_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_ICMP_PACKETS,
- icmp_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_OTHER_PACKETS,
- other_packets);
- vlib_node_increment_counter (vm, stats_node_index,
- NAT_OUT2IN_ED_ERROR_FRAGMENTS, fragments);
return frame->n_vectors;
}