From 37387046750c3427f5bca2b725e0589cc441c075 Mon Sep 17 00:00:00 2001 From: Vincent Bernat Date: Fri, 31 Oct 2008 19:43:13 +0100 Subject: [PATCH] Correctly compute discarded TLV for each port --- src/agent.c | 7 +++++-- src/cdp.c | 1 + src/edp.c | 1 + src/lldp.c | 2 ++ src/lldpd.h | 1 + 5 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/agent.c b/src/agent.c index 44f5aea2..7d58e0a2 100644 --- a/src/agent.c +++ b/src/agent.c @@ -436,12 +436,15 @@ agent_h_stats(struct variable *vp, oid *name, size_t *length, return (u_char *)&long_ret; case LLDP_SNMP_STATS_RX_DISCARDED: case LLDP_SNMP_STATS_RX_ERRORS: + /* We discard only frame with errors. Therefore, the two values + * are equal */ long_ret = hardware->h_rx_discarded_cnt; return (u_char *)&long_ret; case LLDP_SNMP_STATS_RX_TLVDISCARDED: case LLDP_SNMP_STATS_RX_TLVUNRECOGNIZED: - /* Not really handled */ - long_ret = 0; + /* We discard only unrecognized TLV. Malformed TLV + implies dropping the whole frame */ + long_ret = hardware->h_rx_unrecognized_cnt; return (u_char *)&long_ret; case LLDP_SNMP_STATS_RX_AGEOUTS: long_ret = hardware->h_rx_ageout_cnt; diff --git a/src/cdp.c b/src/cdp.c index d2fb90e3..9ff735e5 100644 --- a/src/cdp.c +++ b/src/cdp.c @@ -364,6 +364,7 @@ cdp_decode(struct lldpd *cfg, char *frame, int s, LLOG_DEBUG("unknown CDP TLV type (%d) received on %s", ntohs(tlv->tlv_type), hardware->h_ifname); f += sizeof(struct cdp_tlv_head) + len; + hardware->h_rx_unrecognized_cnt++; } } if (!software && platform) { diff --git a/src/edp.c b/src/edp.c index 0275074d..ffd317ab 100644 --- a/src/edp.c +++ b/src/edp.c @@ -408,6 +408,7 @@ edp_decode(struct lldpd *cfg, char *frame, int s, default: LLOG_DEBUG("unknown EDP TLV type (%d) received on %s", tlv->tlv_type, hardware->h_ifname); + hardware->h_rx_unrecognized_cnt++; } f += len; } diff --git a/src/lldp.c b/src/lldp.c index c0475c9c..0eb945a4 100644 --- a/src/lldp.c +++ b/src/lldp.c @@ -523,10 +523,12 @@ lldp_decode(struct lldpd *cfg, char *frame, int s, default: /* Unknown Dot3 TLV, ignore it */ f += size; + hardware->h_rx_unrecognized_cnt++; } } else { LLOG_INFO("unknown org tlv received on %s", hardware->h_ifname); + hardware->h_rx_unrecognized_cnt++; f += size; } break; diff --git a/src/lldpd.h b/src/lldpd.h index 6d27c847..38e6d4fe 100644 --- a/src/lldpd.h +++ b/src/lldpd.h @@ -122,6 +122,7 @@ struct lldpd_hardware { u_int64_t h_rx_cnt; u_int64_t h_rx_discarded_cnt; u_int64_t h_rx_ageout_cnt; + u_int64_t h_rx_unrecognized_cnt; u_int8_t *h_proto_macs; time_t h_start_probe; -- 2.47.2