From 6d58272b4cf96f0daa846210dd2104877900f921 Mon Sep 17 00:00:00 2001 From: Paul Jakma Date: Mon, 6 Aug 2007 15:21:45 +0000 Subject: [bgpd] cleanup, compact and consolidate capability parsing code 2007-07-26 Paul Jakma * (general) Clean up and compact capability parsing slightly. Consolidate validation of length and logging of generic TLV, and memcpy of capability data, thus removing such from cap specifc code (not always present or correct). * bgp_open.h: Add structures for the generic capability TLV header and for the data formats of the various specific capabilities we support. Hence remove the badly named, or else misdefined, struct capability. * bgp_open.c: (bgp_capability_vty_out) Use struct capability_mp_data. Do the length checks *before* memcpy()'ing based on that length (stored capability - should have been validated anyway on input, but..). (bgp_afi_safi_valid_indices) new function to validate (afi,safi) which is about to be used as index into arrays, consolidates several instances of same, at least one of which appeared to be incomplete.. (bgp_capability_mp) Much condensed. (bgp_capability_orf_entry) New, process one ORF entry (bgp_capability_orf) Condensed. Fixed to process all ORF entries. (bgp_capability_restart) Condensed, and fixed to use a cap-specific type, rather than abusing capability_mp. (struct message capcode_str) added to aid generic logging. (size_t cap_minsizes[]) added to aid generic validation of capability length field. (bgp_capability_parse) Generic logging and validation of TLV consolidated here. Code compacted as much as possible. * bgp_packet.c: (bgp_open_receive) Capability parsers now use streams, so no more need here to manually fudge the input stream getp. (bgp_capability_msg_parse) use struct capability_mp_data. Validate lengths /before/ memcpy. Use bgp_afi_safi_valid_indices. (bgp_capability_receive) Exported for use by test harness. * bgp_vty.c: (bgp_show_summary) fix conversion warning (bgp_show_peer) ditto * bgp_debug.h: Fix storage 'extern' after type 'const'. * lib/log.c: (mes_lookup) warning about code not being in same-number array slot should be debug, not warning. E.g. BGP has several discontigious number spaces, allocating from different parts of a space is not uncommon (e.g. IANA assigned versus vendor-assigned code points in some number space). --- lib/ChangeLog | 8 ++++++++ lib/log.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/ChangeLog b/lib/ChangeLog index 2d8e5deb..41689d03 100644 --- a/lib/ChangeLog +++ b/lib/ChangeLog @@ -1,3 +1,11 @@ +2007-07-26 Paul Jakma + + * log.c: (mes_lookup) warning about code not being in same-number + array slot should be debug, not warning. E.g. BGP has several + discontigious number spaces, allocating from different parts of a + space is not uncommon (e.g. IANA assigned versus vendor-assigned + code points in some number space). + 2007-07-06 Andrew J. Schorr * sockopt.{c,h}: (setsockopt_multicast_ipv4) Add some comments about diff --git a/lib/log.c b/lib/log.c index cbf76af9..ff47cae0 100644 --- a/lib/log.c +++ b/lib/log.c @@ -769,7 +769,7 @@ mes_lookup (struct message *meslist, int max, int index) { if (meslist->key == index) { - zlog_warn("message index %d [%s] found in position %d (max is %d)", + zlog_debug ("message index %d [%s] found in position %d (max is %d)", index, meslist->str, i, max); return meslist->str; } -- cgit v1.2.1