summaryrefslogtreecommitdiffstats
path: root/src/plugins/cdp/cdp_input.c
diff options
context:
space:
mode:
authorDave Barach <dave@barachs.net>2018-09-16 11:03:04 -0400
committerFlorin Coras <florin.coras@gmail.com>2018-09-16 23:35:03 +0000
commit40ea3f59dca497e5f4b5a8440a9c8c2e37396701 (patch)
treebe080d38b01ef4b56ff422efdadc00a4a95b94ed /src/plugins/cdp/cdp_input.c
parentb023d59d4c67a69e559f265aff3d103207b247ce (diff)
Register cdp_input when enabled for the first time
Graceful handling of unknown tlv types Change-Id: Idbc9ed524fc8b865c8e12571813cc73548bde480 Signed-off-by: Dave Barach <dave@barachs.net>
Diffstat (limited to 'src/plugins/cdp/cdp_input.c')
-rw-r--r--src/plugins/cdp/cdp_input.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/plugins/cdp/cdp_input.c b/src/plugins/cdp/cdp_input.c
index fa993b84def..bce8eebe7b0 100644
--- a/src/plugins/cdp/cdp_input.c
+++ b/src/plugins/cdp/cdp_input.c
@@ -276,13 +276,18 @@ cdp_packet_scan (cdp_main_t * cm, cdp_neighbor_t * n)
tlv = (cdp_tlv_t *) cur;
tlv->t = ntohs (tlv->t);
tlv->l = ntohs (tlv->l);
- if (tlv->t >= ARRAY_LEN (tlv_handlers))
- return CDP_ERROR_BAD_TLV;
- handler = &tlv_handlers[tlv->t];
- fp = handler->process;
- e = (*fp) (cm, n, tlv);
- if (e)
- return e;
+ /*
+ * Only process known TLVs. In practice, certain
+ * devices send tlv->t = 0xFF, perhaps as an EOF of sorts.
+ */
+ if (tlv->t < ARRAY_LEN (tlv_handlers))
+ {
+ handler = &tlv_handlers[tlv->t];
+ fp = handler->process;
+ e = (*fp) (cm, n, tlv);
+ if (e)
+ return e;
+ }
/* tlv length includes (t, l) */
cur += tlv->l;
}