aboutsummaryrefslogtreecommitdiffstats
path: root/src/vnet
diff options
context:
space:
mode:
authorNeale Ranns <neale@graphiant.com>2022-08-13 10:58:11 +0000
committerBeno�t Ganne <bganne@cisco.com>2022-08-18 08:30:36 +0000
commit6e4a56e65697999d2f9e2fd539b9e53a0d420266 (patch)
tree1f609b9616a2af9f902fef09f823e70a78246253 /src/vnet
parentb29c60660a69ae892495de65e8c5147052c84ef5 (diff)
ip-neighbor: Declarative .api counters.
Type: improvement plus the addition of the 'thorttle' counter of IP6. Signed-off-by: Neale Ranns <neale@graphiant.com> Change-Id: Ic845247a9f3288caa755c33e79ae2eb6d2029d09
Diffstat (limited to 'src/vnet')
-rw-r--r--src/vnet/ethernet/arp_packet.h10
-rw-r--r--src/vnet/ip-neighbor/ip4_neighbor.c38
-rw-r--r--src/vnet/ip-neighbor/ip6_neighbor.c38
-rw-r--r--src/vnet/ip-neighbor/ip_neighbor.api79
4 files changed, 109 insertions, 56 deletions
diff --git a/src/vnet/ethernet/arp_packet.h b/src/vnet/ethernet/arp_packet.h
index 6b4dfa6ab3d..c406dade6e2 100644
--- a/src/vnet/ethernet/arp_packet.h
+++ b/src/vnet/ethernet/arp_packet.h
@@ -110,16 +110,6 @@ typedef enum
IP4_ARP_N_NEXT,
} ip4_arp_next_t;
-typedef enum
-{
- IP4_ARP_ERROR_THROTTLED,
- IP4_ARP_ERROR_RESOLVED,
- IP4_ARP_ERROR_NO_BUFFERS,
- IP4_ARP_ERROR_REQUEST_SENT,
- IP4_ARP_ERROR_NON_ARP_ADJ,
- IP4_ARP_ERROR_NO_SOURCE_ADDRESS,
-} ip4_arp_error_t;
-
/* *INDENT-OFF* */
typedef CLIB_PACKED (struct {
mac_address_t mac;
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 <vnet/ip-neighbor/ip4_neighbor.h>
+#include <vnet/ip-neighbor/ip_neighbor.api_enum.h>
#include <vnet/ethernet/ethernet.h>
#include <vnet/util/throttle.h>
#include <vnet/fib/fib_sas.h>
@@ -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;
diff --git a/src/vnet/ip-neighbor/ip6_neighbor.c b/src/vnet/ip-neighbor/ip6_neighbor.c
index a59495edbc8..576ae570c0f 100644
--- a/src/vnet/ip-neighbor/ip6_neighbor.c
+++ b/src/vnet/ip-neighbor/ip6_neighbor.c
@@ -16,6 +16,7 @@
*/
#include <vnet/ip-neighbor/ip6_neighbor.h>
+#include <vnet/ip-neighbor/ip_neighbor.api_enum.h>
#include <vnet/util/throttle.h>
#include <vnet/fib/fib_sas.h>
#include <vnet/ip/ip_sas.h>
@@ -119,14 +120,6 @@ typedef enum
IP6_NBR_N_NEXT,
} ip6_discover_neighbor_next_t;
-typedef enum
-{
- IP6_NBR_ERROR_DROP,
- IP6_NBR_ERROR_REQUEST_SENT,
- IP6_NBR_ERROR_NO_SOURCE_ADDRESS,
- IP6_NBR_ERROR_NO_BUFFERS,
-} ip6_discover_neighbor_error_t;
-
static uword
ip6_discover_neighbor_inline (vlib_main_t * vm,
vlib_node_runtime_t * node,
@@ -192,6 +185,12 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
to_next_drop += 1;
n_left_to_next_drop -= 1;
+ if (drop0)
+ {
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_THROTTLED];
+ continue;
+ }
+
hw_if0 = vnet_get_sup_hw_interface (vnm, sw_if_index0);
/* If the interface is link-down, drop the pkt */
@@ -210,7 +209,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
if (drop0)
{
- p0->error = node->errors[IP6_NBR_ERROR_DROP];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_DROP];
continue;
}
@@ -222,7 +221,7 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
!ip6_sas_by_sw_if_index (sw_if_index0, &ip0->dst_address, &src))
{
/* There is no address on the interface */
- p0->error = node->errors[IP6_NBR_ERROR_NO_SOURCE_ADDRESS];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_NO_SOURCE_ADDRESS];
continue;
}
@@ -235,12 +234,12 @@ ip6_discover_neighbor_inline (vlib_main_t * vm,
sizeof (p0->opaque2));
b0->flags |= p0->flags & VLIB_BUFFER_IS_TRACED;
b0->trace_handle = p0->trace_handle;
- p0->error = node->errors[IP6_NBR_ERROR_REQUEST_SENT];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_REQUEST_SENT];
}
else
{
/* There is no address on the interface */
- p0->error = node->errors[IP6_NBR_ERROR_NO_BUFFERS];
+ p0->error = node->errors[IP6_NEIGHBOR_ERROR_NO_BUFFERS];
continue;
}
}
@@ -264,13 +263,6 @@ ip6_glean (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
return (ip6_discover_neighbor_inline (vm, node, frame, 1));
}
-static char *ip6_discover_neighbor_error_strings[] = {
- [IP6_NBR_ERROR_DROP] = "address overflow drops",
- [IP6_NBR_ERROR_REQUEST_SENT] = "neighbor solicitations sent",
- [IP6_NBR_ERROR_NO_SOURCE_ADDRESS] = "no source address for ND solicitation",
- [IP6_NBR_ERROR_NO_BUFFERS] = "no buffers",
-};
-
/* *INDENT-OFF* */
VLIB_REGISTER_NODE (ip6_glean_node) =
{
@@ -278,8 +270,8 @@ VLIB_REGISTER_NODE (ip6_glean_node) =
.name = "ip6-glean",
.vector_size = sizeof (u32),
.format_trace = format_ip6_forward_next_trace,
- .n_errors = ARRAY_LEN (ip6_discover_neighbor_error_strings),
- .error_strings = ip6_discover_neighbor_error_strings,
+ .n_errors = IP6_NEIGHBOR_N_ERROR,
+ .error_counters = ip6_neighbor_error_counters,
.n_next_nodes = IP6_NBR_N_NEXT,
.next_nodes =
{
@@ -293,8 +285,8 @@ VLIB_REGISTER_NODE (ip6_discover_neighbor_node) =
.name = "ip6-discover-neighbor",
.vector_size = sizeof (u32),
.format_trace = format_ip6_forward_next_trace,
- .n_errors = ARRAY_LEN (ip6_discover_neighbor_error_strings),
- .error_strings = ip6_discover_neighbor_error_strings,
+ .n_errors = IP6_NEIGHBOR_N_ERROR,
+ .error_counters = ip6_neighbor_error_counters,
.n_next_nodes = IP6_NBR_N_NEXT,
.next_nodes =
{
diff --git a/src/vnet/ip-neighbor/ip_neighbor.api b/src/vnet/ip-neighbor/ip_neighbor.api
index 62730e7c1e3..a04fcbc569e 100644
--- a/src/vnet/ip-neighbor/ip_neighbor.api
+++ b/src/vnet/ip-neighbor/ip_neighbor.api
@@ -264,6 +264,85 @@ service {
events ip_neighbor_event_v2;
};
+counters ip4_neighbor {
+ throttled {
+ severity info;
+ type counter64;
+ units "packets";
+ description "ARP requests throttled";
+ };
+ resolved {
+ severity info;
+ type counter64;
+ units "packets";
+ description "ARP requests resolved";
+ };
+ no_buffers {
+ severity error;
+ type counter64;
+ units "packets";
+ description "ARP requests out of buffer";
+ };
+ request_sent {
+ severity info;
+ type counter64;
+ units "packets";
+ description "ARP requests sent";
+ };
+ non_arp_adj {
+ severity error;
+ type counter64;
+ units "packets";
+ description "ARPs to non-ARP adjacencies";
+ };
+ no_source_address {
+ severity error;
+ type counter64;
+ units "packets";
+ description "no source address for ARP request";
+ };
+};
+
+counters ip6_neighbor {
+ throttled {
+ severity info;
+ type counter64;
+ units "packets";
+ description "throttled";
+ };
+ drop {
+ severity error;
+ type counter64;
+ units "packets";
+ description "address overflow drops";
+ };
+ request_sent {
+ severity info;
+ type counter64;
+ units "packets";
+ description "neighbor solicitations sent";
+ };
+ no_source_address {
+ severity error;
+ type counter64;
+ units "packets";
+ description "no source address for ND solicitation";
+ };
+ no_buffers {
+ severity error;
+ type counter64;
+ units "packets";
+ description "no buffers";
+ };
+};
+
+paths {
+ "/err/ip4-arp" "ip4_neighbor";
+ "/err/ip4-glean" "ip4_neighbor";
+ "/err/ip6-arp" "ip6_neighbor";
+ "/err/ip6-glean" "ip6_neighbor";
+};
+
/*
* Local Variables:
* eval: (c-set-style "gnu")