arp: Use the new style error count declaration

Type: improvement

Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: Ifda8ca8d26912c750a77d2ca889e1638ca83d85a
This commit is contained in:
Neale Ranns
2022-08-09 00:59:37 +00:00
committed by Beno�t Ganne
parent ee15f8682c
commit 13a74ae25d
5 changed files with 229 additions and 135 deletions

View File

@ -98,3 +98,121 @@ define proxy_arp_intfc_details
u32 context;
u32 sw_if_index;
};
counters arp {
replies_sent {
severity info;
type counter64;
units "packets";
description "ARP replies sent";
};
disabled {
severity error;
type counter64;
units "packets";
description "ARP Disabled";
};
l2_type_not_ethernet {
severity error;
type counter64;
units "packets";
description "L2 type not ethernet";
};
l3_type_not_ip4 {
severity error;
type counter64;
units "packets";
description "L3 type not IP4";
};
l3_src_address_not_local {
severity error;
type counter64;
units "packets";
description "IP4 source address not local to subnet";
};
l3_dst_address_not_local {
severity error;
type counter64;
units "packets";
description "IP4 destination address not local to subnet";
};
l3_dst_address_unset {
severity error;
type counter64;
units "packets";
description "IP4 destination address is unset";
};
l3_src_address_is_local {
severity error;
type counter64;
units "packets";
description "IP4 source address matches local interface";
};
l3_src_address_learned {
severity info;
type counter64;
units "packets";
description "ARP request IP4 source address learned";
};
replies_received {
severity info;
type counter64;
units "packets";
description "ARP replies received";
};
opcode_not_request {
severity error;
type counter64;
units "packets";
description "ARP opcode not request";
};
proxy_arp_replies_sent {
severity info;
type counter64;
units "packets";
description "Proxy ARP replies sent";
};
l2_address_mismatch {
severity error;
type counter64;
units "packets";
description "ARP hw addr does not match L2 frame src addr";
};
gratuitous_arp {
severity error;
type counter64;
units "packets";
description "ARP probe or announcement dropped";
};
interface_no_table {
severity error;
type counter64;
units "packets";
description "Interface is not mapped to an IP table";
};
interface_not_ip_enabled {
severity error;
type counter64;
units "packets";
description "Interface is not IP enabled";
};
unnumbered_mismatch {
severity error;
type counter64;
units "packets";
description "RX interface is unnumbered to different subnet";
};
};
paths {
"/err/arp-reply" "arp";
"/err/arp-disabled" "arp";
"/err/arp-input" "arp";
"/err/arp-proxy" "arp";
};
/*
* Local Variables:
* eval: (c-set-style "gnu")
* End:
*/

File diff suppressed because it is too large Load Diff

View File

@ -19,32 +19,7 @@
#include <vnet/ethernet/ethernet.h>
#include <vnet/ip/ip.h>
#include <vnet/ethernet/arp_packet.h>
#define foreach_ethernet_arp_error \
_ (replies_sent, "ARP replies sent") \
_ (l2_type_not_ethernet, "L2 type not ethernet") \
_ (l3_type_not_ip4, "L3 type not IP4") \
_ (l3_src_address_not_local, "IP4 source address not local to subnet") \
_ (l3_dst_address_not_local, "IP4 destination address not local to subnet") \
_ (l3_dst_address_unset, "IP4 destination address is unset") \
_ (l3_src_address_is_local, "IP4 source address matches local interface") \
_ (l3_src_address_learned, "ARP request IP4 source address learned") \
_ (replies_received, "ARP replies received") \
_ (opcode_not_request, "ARP opcode not request") \
_ (proxy_arp_replies_sent, "Proxy ARP replies sent") \
_ (l2_address_mismatch, "ARP hw addr does not match L2 frame src addr") \
_ (gratuitous_arp, "ARP probe or announcement dropped") \
_ (interface_no_table, "Interface is not mapped to an IP table") \
_ (interface_not_ip_enabled, "Interface is not IP enabled") \
_ (unnumbered_mismatch, "RX interface is unnumbered to different subnet") \
typedef enum
{
#define _(sym,string) ETHERNET_ARP_ERROR_##sym,
foreach_ethernet_arp_error
#undef _
ETHERNET_ARP_N_ERROR,
} ethernet_arp_reply_error_t;
#include <vnet/arp/arp.api_enum.h>
extern int arp_proxy_add (u32 fib_index,
const ip4_address_t * lo_addr,

View File

@ -326,14 +326,14 @@ arp_proxy (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
is_request0 = arp0->opcode
== clib_host_to_net_u16 (ETHERNET_ARP_OPCODE_request);
error0 = ETHERNET_ARP_ERROR_replies_sent;
error0 = ARP_ERROR_REPLIES_SENT;
sw_if_index0 = vnet_buffer (p0)->sw_if_index[VLIB_RX];
next0 = ARP_REPLY_NEXT_DROP;
fib_index0 = ip4_fib_table_get_index_for_sw_if_index (sw_if_index0);
if (~0 == fib_index0)
{
error0 = ETHERNET_ARP_ERROR_interface_no_table;
error0 = ARP_ERROR_INTERFACE_NO_TABLE;
}
if (0 == error0 && is_request0)
@ -376,28 +376,28 @@ arp_proxy (vlib_main_t * vm, vlib_node_runtime_t * node, vlib_frame_t * frame)
vlib_put_next_frame (vm, node, next_index, n_left_to_next);
}
vlib_error_count (vm, node->node_index,
ETHERNET_ARP_ERROR_replies_sent, n_arp_replies_sent);
vlib_error_count (vm, node->node_index, ARP_ERROR_REPLIES_SENT,
n_arp_replies_sent);
return frame->n_vectors;
}
static char *ethernet_arp_error_strings[] = {
#define _(sym,string) string,
foreach_ethernet_arp_error
#undef _
};
VLIB_REGISTER_NODE (arp_proxy_node, static) =
{
.function = arp_proxy,.name = "arp-proxy",.vector_size =
sizeof (u32),.n_errors = ETHERNET_ARP_N_ERROR,.error_strings =
ethernet_arp_error_strings,.n_next_nodes = ARP_REPLY_N_NEXT,.next_nodes =
.function = arp_proxy,
.name = "arp-proxy",
.vector_size = sizeof (u32),
.n_errors = ARP_N_ERROR,
.error_counters = arp_error_counters,
.n_next_nodes = ARP_REPLY_N_NEXT,
.next_nodes =
{
[ARP_REPLY_NEXT_DROP] = "error-drop",
[ARP_REPLY_NEXT_REPLY_TX] = "interface-output",}
,.format_buffer = format_ethernet_arp_header,.format_trace =
format_ethernet_arp_input_trace,};
[ARP_REPLY_NEXT_DROP] = "error-drop",
[ARP_REPLY_NEXT_REPLY_TX] = "interface-output",
},
.format_buffer = format_ethernet_arp_header,
.format_trace = format_ethernet_arp_input_trace,
};
static clib_error_t *
show_ip4_arp (vlib_main_t * vm,

View File

@ -1794,9 +1794,7 @@ class ARPTestCase(VppTestCase):
# they are all dropped because the subnet's don't match
self.assertEqual(
4,
self.statistics.get_err_counter(
"/err/arp-reply/IP4 destination address not local to subnet"
),
self.statistics.get_err_counter("/err/arp-reply/l3_dst_address_not_local"),
)
def test_arp_incomplete2(self):