diff options
author | Neale Ranns <neale@graphiant.com> | 2022-08-12 01:50:24 +0000 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2022-08-18 08:29:21 +0000 |
commit | b29c60660a69ae892495de65e8c5147052c84ef5 (patch) | |
tree | 1813e86c6bde802965c89a8e556819ba15aa8ea1 /src/vnet/ip | |
parent | c65921f7744a0da09ede876b6588628e3a188529 (diff) |
ip: Use .api declarative counters for ICMP.
Type: improvement
Signed-off-by: Neale Ranns <neale@graphiant.com>
Change-Id: I3d36faa60075658fd59eb5bbe16efcb48664691b
Diffstat (limited to 'src/vnet/ip')
-rw-r--r-- | src/vnet/ip/icmp4.c | 14 | ||||
-rw-r--r-- | src/vnet/ip/icmp4.h | 23 | ||||
-rw-r--r-- | src/vnet/ip/icmp6.c | 14 | ||||
-rw-r--r-- | src/vnet/ip/icmp6.h | 42 | ||||
-rw-r--r-- | src/vnet/ip/ip.api | 238 |
5 files changed, 246 insertions, 85 deletions
diff --git a/src/vnet/ip/icmp4.c b/src/vnet/ip/icmp4.c index 857c3b1d2a5..318081b9c9f 100644 --- a/src/vnet/ip/icmp4.c +++ b/src/vnet/ip/icmp4.c @@ -43,12 +43,6 @@ #include <vnet/ip/ip_sas.h> #include <vnet/util/throttle.h> -static char *icmp_error_strings[] = { -#define _(f,s) s, - foreach_icmp4_error -#undef _ -}; - /** ICMP throttling */ static throttle_t icmp_throttle; @@ -219,8 +213,8 @@ VLIB_REGISTER_NODE (ip4_icmp_input_node) = { .format_trace = format_icmp_input_trace, - .n_errors = ARRAY_LEN (icmp_error_strings), - .error_strings = icmp_error_strings, + .n_errors = ICMP4_N_ERROR, + .error_counters = icmp4_error_counters, .n_next_nodes = 1, .next_nodes = { @@ -399,8 +393,8 @@ VLIB_REGISTER_NODE (ip4_icmp_error_node) = { .name = "ip4-icmp-error", .vector_size = sizeof (u32), - .n_errors = ARRAY_LEN (icmp_error_strings), - .error_strings = icmp_error_strings, + .n_errors = ICMP4_N_ERROR, + .error_counters = icmp4_error_counters, .n_next_nodes = IP4_ICMP_ERROR_N_NEXT, .next_nodes = { diff --git a/src/vnet/ip/icmp4.h b/src/vnet/ip/icmp4.h index e2a95673fc7..22a4fc508e5 100644 --- a/src/vnet/ip/icmp4.h +++ b/src/vnet/ip/icmp4.h @@ -15,29 +15,6 @@ #ifndef included_vnet_icmp4_h #define included_vnet_icmp4_h -#define foreach_icmp4_error \ - _ (NONE, "valid packets") \ - _ (UNKNOWN_TYPE, "unknown type") \ - _ (INVALID_CODE_FOR_TYPE, "invalid code for type") \ - _ (INVALID_HOP_LIMIT_FOR_TYPE, "hop_limit != 255") \ - _ (LENGTH_TOO_SMALL_FOR_TYPE, "payload length too small for type") \ - _ (OPTIONS_WITH_ODD_LENGTH, \ - "total option length not multiple of 8 bytes") \ - _ (OPTION_WITH_ZERO_LENGTH, "option has zero length") \ - _ (ECHO_REPLIES_SENT, "echo replies sent") \ - _ (DST_LOOKUP_MISS, "icmp6 dst address lookup misses") \ - _ (DEST_UNREACH_SENT, "destination unreachable response sent") \ - _ (TTL_EXPIRE_SENT, "hop limit exceeded response sent") \ - _ (PARAM_PROBLEM_SENT, "parameter problem response sent") \ - _ (DROP, "error message dropped") - -typedef enum -{ -#define _(f,s) ICMP4_ERROR_##f, - foreach_icmp4_error -#undef _ -} icmp4_error_t; - typedef struct { u8 packet_data[64]; diff --git a/src/vnet/ip/icmp6.c b/src/vnet/ip/icmp6.c index f92f31c05cb..4cabc0e083f 100644 --- a/src/vnet/ip/icmp6.c +++ b/src/vnet/ip/icmp6.c @@ -127,12 +127,6 @@ format_icmp6_input_trace (u8 * s, va_list * va) return s; } -static char *icmp_error_strings[] = { -#define _(f,s) s, - foreach_icmp6_error -#undef _ -}; - typedef enum { ICMP_INPUT_NEXT_PUNT, @@ -250,8 +244,8 @@ VLIB_REGISTER_NODE (ip6_icmp_input_node) = { .format_trace = format_icmp6_input_trace, - .n_errors = ARRAY_LEN (icmp_error_strings), - .error_strings = icmp_error_strings, + .n_errors = ICMP6_N_ERROR, + .error_counters = icmp6_error_counters, .n_next_nodes = 1, .next_nodes = { @@ -439,8 +433,8 @@ VLIB_REGISTER_NODE (ip6_icmp_error_node) = { .name = "ip6-icmp-error", .vector_size = sizeof (u32), - .n_errors = ARRAY_LEN (icmp_error_strings), - .error_strings = icmp_error_strings, + .n_errors = ICMP6_N_ERROR, + .error_counters = icmp6_error_counters, .n_next_nodes = IP6_ICMP_ERROR_N_NEXT, .next_nodes = { diff --git a/src/vnet/ip/icmp6.h b/src/vnet/ip/icmp6.h index 7a5eef5df18..119aaf0bae9 100644 --- a/src/vnet/ip/icmp6.h +++ b/src/vnet/ip/icmp6.h @@ -17,48 +17,6 @@ #include <vnet/ip/icmp46_packet.h> -#define foreach_icmp6_error \ - _ (NONE, "valid packets") \ - _ (UNKNOWN_TYPE, "unknown type") \ - _ (INVALID_CODE_FOR_TYPE, "invalid code for type") \ - _ (INVALID_HOP_LIMIT_FOR_TYPE, "hop_limit != 255") \ - _ (LENGTH_TOO_SMALL_FOR_TYPE, "payload length too small for type") \ - _ (OPTIONS_WITH_ODD_LENGTH, \ - "total option length not multiple of 8 bytes") \ - _ (OPTION_WITH_ZERO_LENGTH, "option has zero length") \ - _ (ECHO_REPLIES_SENT, "echo replies sent") \ - _ (NEIGHBOR_SOLICITATION_SOURCE_NOT_ON_LINK, \ - "neighbor solicitations from source not on link") \ - _ (NEIGHBOR_SOLICITATION_SOURCE_UNKNOWN, \ - "neighbor solicitations for unknown targets") \ - _ (NEIGHBOR_ADVERTISEMENTS_TX, "neighbor advertisements sent") \ - _ (NEIGHBOR_ADVERTISEMENTS_RX, "neighbor advertisements received") \ - _ (ROUTER_SOLICITATION_SOURCE_NOT_ON_LINK, \ - "router solicitations from source not on link") \ - _ (ROUTER_SOLICITATION_UNSUPPORTED_INTF, \ - "neighbor discovery unsupported interface") \ - _ (ROUTER_SOLICITATION_RADV_NOT_CONFIG, \ - "neighbor discovery not configured") \ - _ (ROUTER_ADVERTISEMENT_SOURCE_NOT_LINK_LOCAL, \ - "router advertisement source not link local") \ - _ (ROUTER_ADVERTISEMENTS_TX, "router advertisements sent") \ - _ (ROUTER_ADVERTISEMENTS_RX, "router advertisements received") \ - _ (DST_LOOKUP_MISS, "icmp6 dst address lookup misses") \ - _ (DEST_UNREACH_SENT, "destination unreachable response sent") \ - _ (PACKET_TOO_BIG_SENT, "packet too big response sent") \ - _ (TTL_EXPIRE_SENT, "hop limit exceeded response sent") \ - _ (PARAM_PROBLEM_SENT, "parameter problem response sent") \ - _ (DROP, "error message dropped") \ - _ (ALLOC_FAILURE, "buffer allocation failure") - - -typedef enum -{ -#define _(f,s) ICMP6_ERROR_##f, - foreach_icmp6_error -#undef _ -} icmp6_error_t; - typedef struct { u8 packet_data[64]; diff --git a/src/vnet/ip/ip.api b/src/vnet/ip/ip.api index aa303500386..23e094b48a0 100644 --- a/src/vnet/ip/ip.api +++ b/src/vnet/ip/ip.api @@ -1450,6 +1450,240 @@ counters ip6 { }; }; +counters icmp4 { + none { + severity info; + type counter64; + units "packets"; + description "valid packets"; + }; + unknown_type { + severity error; + type counter64; + units "packets"; + description "unknown type"; + }; + invalid_code_for_type { + severity error; + type counter64; + units "packets"; + description "invalid code for type"; + }; + invalid_hop_limit_for_type { + severity error; + type counter64; + units "packets"; + description "hop_limit != 255"; + }; + length_too_small_for_type { + severity error; + type counter64; + units "packets"; + description "payload length too small for type"; + }; + options_with_odd_length { + severity error; + type counter64; + units "packets"; + description "total option length not multiple of 8 bytes"; + }; + option_with_zero_length { + severity error; + type counter64; + units "packets"; + description "option has zero length"; + }; + echo_replies_sent { + severity info; + type counter64; + units "packets"; + description "echo replies sent"; + }; + dst_lookup_miss { + severity error; + type counter64; + units "packets"; + description "icmp6 dst address lookup misses"; + }; + dest_unreach_sent { + severity info; + type counter64; + units "packets"; + description "destination unreachable response sent"; + }; + ttl_expire_sent { + severity info; + type counter64; + units "packets"; + description "hop limit exceeded response sent"; + }; + param_problem_sent { + severity info; + type counter64; + units "packets"; + description "parameter problem response sent"; + }; + drop { + severity error; + type counter64; + units "packets"; + description "error message dropped"; + }; +}; + +counters icmp6 { + none { + severity info; + type counter64; + units "packets"; + description "valid packets"; + }; + unknown_type { + severity error; + type counter64; + units "packets"; + description "unknown type"; + }; + invalid_code_for_type { + severity error; + type counter64; + units "packets"; + description "invalid code for type"; + }; + invalid_hop_limit_for_type { + severity error; + type counter64; + units "packets"; + description "hop_limit != 255"; + }; + length_too_small_for_type { + severity error; + type counter64; + units "packets"; + description "payload length too small for type"; + }; + options_with_odd_length { + severity error; + type counter64; + units "packets"; + description "total option length not multiple of 8 bytes"; + }; + option_with_zero_length { + severity error; + type counter64; + units "packets"; + description "option has zero length"; + }; + echo_replies_sent { + severity info; + type counter64; + units "packets"; + description "echo replies sent"; + }; + neighbor_solicitation_source_not_on_link { + severity error; + type counter64; + units "packets"; + description "neighbor solicitations from source not on link"; + }; + neighbor_solicitation_source_unknown { + severity error; + type counter64; + units "packets"; + description "neighbor solicitations for unknown targets"; + }; + neighbor_advertisements_tx { + severity info; + type counter64; + units "packets"; + description "neighbor advertisements sent"; + }; + neighbor_advertisements_rx { + severity info; + type counter64; + units "packets"; + description "neighbor advertisements received"; + }; + router_solicitation_source_not_on_link { + severity error; + type counter64; + units "packets"; + description "router solicitations from source not on link"; + }; + router_solicitation_unsupported_intf { + severity error; + type counter64; + units "packets"; + description "neighbor discovery unsupported interface"; + }; + router_solicitation_radv_not_config { + severity error; + type counter64; + units "packets"; + description "neighbor discovery not configured"; + }; + router_advertisement_source_not_link_local { + severity error; + type counter64; + units "packets"; + description "router advertisement source not link local"; + }; + router_advertisements_tx { + severity info; + type counter64; + units "packets"; + description "router advertisements sent"; + }; + router_advertisements_rx { + severity info; + type counter64; + units "packets"; + description "router advertisements received"; + }; + dst_lookup_miss { + severity error; + type counter64; + units "packets"; + description "icmp6 dst address lookup misses"; + }; + dest_unreach_sent { + severity info; + type counter64; + units "packets"; + description "destination unreachable response sent"; + }; + packet_too_big_sent { + severity info; + type counter64; + units "packets"; + description "packet too big response sent"; + }; + ttl_expire_sent { + severity info; + type counter64; + units "packets"; + description "hop limit exceeded response sent"; + }; + param_problem_sent { + severity info; + type counter64; + units "packets"; + description "parameter problem response sent"; + }; + drop { + severity error; + type counter64; + units "packets"; + description "error message dropped"; + }; + alloc_failure { + severity error; + type counter64; + units "packets"; + description "buffer allocation failure"; + }; +}; + paths { "/err/ip-frag" "ip_frag"; "/err/mpls-frag" "ip_frag"; @@ -1481,6 +1715,10 @@ paths { "/err/ip6-sv-reassembly-output-feature" "ip6"; "/err/ip6-sv-reassembly-custom-next" "ip6"; "/err/ip6-sv-reassembly-expire-walk" "ip6"; + "/err/ip4-icmp-input" "icmp4"; + "/err/ip4-icmp-error" "icmp4"; + "/err/ip6-icmp-input" "icmp6"; + "/err/ip6-icmp-error" "icmp6"; }; /* |