From 6e4a56e65697999d2f9e2fd539b9e53a0d420266 Mon Sep 17 00:00:00 2001 From: Neale Ranns Date: Sat, 13 Aug 2022 10:58:11 +0000 Subject: ip-neighbor: Declarative .api counters. Type: improvement plus the addition of the 'thorttle' counter of IP6. Signed-off-by: Neale Ranns Change-Id: Ic845247a9f3288caa755c33e79ae2eb6d2029d09 --- src/vnet/ip-neighbor/ip4_neighbor.c | 38 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 23 deletions(-) (limited to 'src/vnet/ip-neighbor/ip4_neighbor.c') diff --git a/src/vnet/ip-neighbor/ip4_neighbor.c b/src/vnet/ip-neighbor/ip4_neighbor.c index 368703d595b..5a6e8dd154c 100644 --- a/src/vnet/ip-neighbor/ip4_neighbor.c +++ b/src/vnet/ip-neighbor/ip4_neighbor.c @@ -38,6 +38,7 @@ */ #include +#include #include #include #include @@ -197,7 +198,8 @@ ip4_arp_inline (vlib_main_t * vm, !ip4_sas_by_sw_if_index (sw_if_index0, &resolve0, &src0)) { /* No source address available */ - p0->error = node->errors[IP4_ARP_ERROR_NO_SOURCE_ADDRESS]; + p0->error = + node->errors[IP4_NEIGHBOR_ERROR_NO_SOURCE_ADDRESS]; continue; } } @@ -208,7 +210,7 @@ ip4_arp_inline (vlib_main_t * vm, if (throttle_check (&arp_throttle, thread_index, r0, seed)) { - p0->error = node->errors[IP4_ARP_ERROR_THROTTLED]; + p0->error = node->errors[IP4_NEIGHBOR_ERROR_THROTTLED]; continue; } @@ -218,7 +220,7 @@ ip4_arp_inline (vlib_main_t * vm, */ if (IP_LOOKUP_NEXT_REWRITE == adj0->lookup_next_index) { - p0->error = node->errors[IP4_ARP_ERROR_RESOLVED]; + p0->error = node->errors[IP4_NEIGHBOR_ERROR_RESOLVED]; continue; } @@ -229,7 +231,7 @@ ip4_arp_inline (vlib_main_t * vm, if ((is_glean && adj0->lookup_next_index != IP_LOOKUP_NEXT_GLEAN) || (!is_glean && adj0->lookup_next_index != IP_LOOKUP_NEXT_ARP)) { - p0->error = node->errors[IP4_ARP_ERROR_NON_ARP_ADJ]; + p0->error = node->errors[IP4_NEIGHBOR_ERROR_NON_ARP_ADJ]; continue; } @@ -241,11 +243,11 @@ ip4_arp_inline (vlib_main_t * vm, /* copy the persistent fields from the original */ clib_memcpy_fast (b0->opaque2, p0->opaque2, sizeof (p0->opaque2)); - p0->error = node->errors[IP4_ARP_ERROR_REQUEST_SENT]; + p0->error = node->errors[IP4_NEIGHBOR_ERROR_REQUEST_SENT]; } else { - p0->error = node->errors[IP4_ARP_ERROR_NO_BUFFERS]; + p0->error = node->errors[IP4_NEIGHBOR_ERROR_NO_BUFFERS]; continue; } } @@ -268,23 +270,14 @@ VLIB_NODE_FN (ip4_glean_node) (vlib_main_t * vm, vlib_node_runtime_t * node, return (ip4_arp_inline (vm, node, frame, 1)); } -static char *ip4_arp_error_strings[] = { - [IP4_ARP_ERROR_THROTTLED] = "ARP requests throttled", - [IP4_ARP_ERROR_RESOLVED] = "ARP requests resolved", - [IP4_ARP_ERROR_NO_BUFFERS] = "ARP requests out of buffer", - [IP4_ARP_ERROR_REQUEST_SENT] = "ARP requests sent", - [IP4_ARP_ERROR_NON_ARP_ADJ] = "ARPs to non-ARP adjacencies", - [IP4_ARP_ERROR_NO_SOURCE_ADDRESS] = "no source address for ARP request", -}; - /* *INDENT-OFF* */ VLIB_REGISTER_NODE (ip4_arp_node) = { .name = "ip4-arp", .vector_size = sizeof (u32), .format_trace = format_ip4_forward_next_trace, - .n_errors = ARRAY_LEN (ip4_arp_error_strings), - .error_strings = ip4_arp_error_strings, + .n_errors = IP4_NEIGHBOR_N_ERROR, + .error_counters = ip4_neighbor_error_counters, .n_next_nodes = IP4_ARP_N_NEXT, .next_nodes = { [IP4_ARP_NEXT_DROP] = "ip4-drop", @@ -296,8 +289,8 @@ VLIB_REGISTER_NODE (ip4_glean_node) = .name = "ip4-glean", .vector_size = sizeof (u32), .format_trace = format_ip4_forward_next_trace, - .n_errors = ARRAY_LEN (ip4_arp_error_strings), - .error_strings = ip4_arp_error_strings, + .n_errors = IP4_NEIGHBOR_N_ERROR, + .error_counters = ip4_neighbor_error_counters, .n_next_nodes = IP4_ARP_N_NEXT, .next_nodes = { [IP4_ARP_NEXT_DROP] = "ip4-drop", @@ -319,10 +312,9 @@ arp_notrace_init (vlib_main_t * vm) vlib_node_runtime_t *rt = vlib_node_get_runtime (vm, ip4_arp_node.index); /* don't trace ARP request packets */ -#define _(a) \ - vnet_pcap_drop_trace_filter_add_del \ - (rt->errors[IP4_ARP_ERROR_##a], \ - 1 /* is_add */); +#define _(a) \ + vnet_pcap_drop_trace_filter_add_del (rt->errors[IP4_NEIGHBOR_ERROR_##a], \ + 1 /* is_add */); foreach_notrace_ip4_arp_error; #undef _ return 0; -- cgit 1.2.3-korg