summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2006-03-30[lib] Mark most arguments in DEFUN_CMD_FUNC_TEXT as potentially unusedPaul Jakma
2006-03-30 Paul Jakma <paul.jakma@sun.com> * command.h: (DEFUN_CMD_FUNC_TEXT) Annotate arguments as potentially being unused.
2006-03-30[lib] fix gensub call in memtypes.awk to pass "g", not g.Paul Jakma
2006-03-27 Paul Jakma <paul.jakma@sun.com> * memtypes.awk: Fix gensub call, g should be a string..
2006-03-30[lib] status field/flags no longer used in struct workqueuePaul Jakma
2006-03-25 Paul Jakma <paul.jakma@sun.com> * workqueue.h: (struct work_queue) Remove status field and state flag, no longer used.
2006-03-30[bgpd] trivial: use a distinct memtype for struct bgp_synchronizePaul Jakma
2006-03-19 Paul Jakma <paul.jakma@sun.com> * memtypes.c: Add MTYPE_BGP_SYNCHRONISE. * bgp_advertise.c: Use a distinct memory type for struct bgp_synchronize.
2006-03-30[lib] fix libtool version argument in Makefile.amPaul Jakma
2006-03-16 Paul Jakma <paul.jakma@sun.com> * Makefile.am: Fix -version-info argument.
2006-03-30[lib/memory] Add mallinfo supportPaul Jakma
2006-02-15 Paul Jakma <paul.jakma@sun.com> * configure.ac: Check for mallinfo, being careful to link test so we can detect things like umem being used (which doesn't provide a mallinfo). * lib/memory.c: (mtype_memstr) new helper function to return human friendly string for a byte count. (mtype_stats_alloc) new function, for users to retrieve number of objects allocated. (show_memory_mallinfo) New function, show mallinfo statistics if available. (show_memory_all_cmd) Call show_memory_mallinfo, if mallinfo is available. * lib/memory.h: Export mtype_memstr and mtype_stats_alloc. Provide a define for a reasonable buffer size for mtype_memstr.
2006-03-30[lib/privs] Changing user IDs should be done before dropping privilegesPaul Jakma
2006-03-14 Paul Jakma <paul.jakma@sun.com> * privs.c: (zprivs_caps_init) Change user IDs before lowering privileges, while this seems to work on Linux, on Solaris it rightfully refuses due to PRIV_PROC_SETID having been dropped.
2006-03-06[lib] export show_address_cmd debug command in if.hPaul Jakma
2006-03-06 Paul Jakma <paul.jakma@sun.com> * if.h: export show_address_cmd, for anyone who wishes to use it.
2006-02-21[lib/sockunion] trivial: use XSTRDUP.Paul Jakma
2006-02-21 Paul Jakma <paul.jakma@sun.com> * sockunion.c: (sockunion_{su2str,log}) Use XSTRDUP. Particularly with _su2str, as that string gets XFREEd, which can be annoying if run debug code in memory.c.
2006-02-02[lib/workqueue] remove the useless 'delay' factor.paul
2006-02-02 Paul Jakma <paul.jakma@sun.com> * workqueue.h: (struct work_queue) Remove the delay field. It served no purpose and just introduced bad behaviour. Should be excised before its allowed to escape into 1.0. This removes need for the 'flood' and runs_since_clear fields. * workqueue.c: (general) excise delay factor between queue runs, hence the 'flood' crap too.. See above. * bgp_route.c: (bgp_{clear_node,process}_queue_init) delay field is removed from workqueue spec.
2006-01-19[lib/stream] small compile fix, use uint64_t, not u_int64_t.paul
2006-01-19 Paul Jakma <paul.jakma@sun.com> * stream.c: (stream_getq_from) should use POSIX uint64_t not u_int64_t. Latter is neither a traditional BSD type, nor a POSIX type.
2006-01-172006-01-17 Vincent Jardin <vincent.jardin@6wind.com>vincent
* md5.c: Don't forget to keep const. * regex.c: Cleanup code and remove warnings.
2006-01-17[lib/zclient] Export zclient_create_headerpaul
2006-01-17 Paul Jakma <paul.jakma@sun.com> * zclient.{c,h}: (zclient_create_header) export this, seems others could use it (in lieu of more complete zserv helpers).
2006-01-17[lib/vty] Add 'no terminal monitor' aliaspaul
2006-01-17 Paul Jakma <paul.jakma@sun.com> * vty.c: (no_terminal_monitor_cmd) New ALIAS for terminal_no_monitor, in the more normal negating format, to be kind to my fingers. (vty_init) install new ALIAS.
2006-01-17[lib/md5] md5_loop should take void pointer for more useful caller warnings.paul
2006-01-17 Paul Jakma <paul.jakma@sun.com> * md5.{c,h}: (md5_loop) Is better off taking a void * and doing cast to byte wise type internally, avoids needs for casts in users.
2006-01-16[zserv] Extend Zserv header with version information and marker fieldpaul
2006-01-16 Paul Jakma <paul.jakma@sun.com> * lib/zclient.h: Update the Zserv protocol header with a version field. Define the old command field to be a 'marker', to allow old Zserv and updated Zserv to be differentiated. Future updates will bump the version field obviously. New command field is made wider. Try to stop using the 'zebra_size_t' typedef in the callbacks. * lib/zclient.c: Update to read/write new format header. * zebra/zserv.c: Ditto
2006-01-11[zserv] Update interface flags to 8 bytes wide.paul
2006-01-11 Paul Jakma <paul.jakma@sun.com> * if.h: (struct interface) expand flags to 8 bytes. * zclient.c: (zebra_interface_{add,state}_read) stream read of interface flags now need to use stream_getq. (zebra_interface_if_set_value) ditto 2006-01-11 Paul Jakma <paul.jakma@sun.com> * zserv.c: (zsend_interface_{add,delete,update}) if flags are 8 bytes now, update to write out with stream_putq.
2006-01-10[stream] Add quad-word support and stream_resizepaul
2006-01-10 Paul Jakma <paul.jakma@sun.com> * stream.c: (stream_new) Allocate stream data as seperate object. (stream_free) free the data. (stream_resize) new function, resize stream to new size. (stream_{get,put}q*) new functions to get/put quad word size types. * stream.h: (struct stream) make data seperate from the stream. Export new stream_resize and quad-word get/put functions.
2005-12-292005-12-29 Greg Troxel <gdt@fnord.ir.bbn.com>gdt
* vty.c (vty_hello): add cast to quiet lint (from David Young) (patch-lint)
2005-11-26[c99] change gcc zero-length array to C99 flexible array declarationpaul
2005-11-26 Paul Jakma <paul.jakma@sun.com> * buffer.c: (struct buffer_data) change gcc zero array declaration to C99 incomplete array. * stream.h: (struct stream) same * ospf_api.c: (struct opaque_lsa) same
2005-11-24[lib/zebra.h] fix Linux compile errorpaul
2005-11-24 Paul Jakma <paul.jakma@sun.com> * zebra.h: s/u_int/unsigned int/, u_int is a BSD type, defining __USE_BSD on Linux pulls in further things from netinet/ip.h which dont preprocess for some reason. There is no C99 shorthand type directly equivalent to u_int afaict, so don't use it.
2005-11-24[privs/solaris] Fix unused variable and incorrect format string.paul
2005-11-24 Paul Jakma <paul.jakma@sun.com> * privs.c: (zcaps2sys/solaris) remove unused variable. (zprivs_state_caps/solaris) Format string missing a specifier.
2005-11-14[workqueue] Update workqueue users callbacks to additional argumentspaul
2005-11-14 Paul Jakma <paul.jakma@sun.com> * (general) pass struct work-queue to callback functions. * workqueue.h: (struct work_queue) move the state flag variables to end. Add an opaque pointer to spec, for user-data global to the queue. Pass reference to work_queue to all callbacks. * workqueue.c: (work_queue_item_remove) pass ref to workqueue to user callbacks. (work_queue_run) ditto.
2005-11-14[bug #231] check and include stdint.h, also add std=c99 to gcc CFLAGSpaul
2005-11-14 Paul Jakma <paul.jakma@sun.com> * configure.ac: Tell gcc we like C99. [bug #231] Check and test for stdint.h. * lib/zebra.h: [bug #231] include stdint, if its there.
2005-11-142005-11-14 Paul Jakma <paul.jakma@sun.com>paul
* (general) Add state to detect queue floods. There's no sense trying to be sparing of CPU resources, if the queue is flooding and using ever more memory resources. we should just get on with clearing the queue. The sense of delay and hold were wrong way around, fix. * workqueue.h: (struct work_queue) Add status bitfield. Add 'flood' integer to workqueue spec. Add runs_since_clear counter to workqueue. * workqueue.c: (work_queue_new) set defaults for delay, hold and flood. (work_queue_add) initial schedule should use delay, not hold. (show_work_queues) Print flood field, conserve whitespace. (work_queue_unplug) use delay, not hold. (work_queue_run) consecutive runs should be seperated by hold time, not delay. Keep track of number of consecutive runs, go into 'overdrive' if queue is being flooded, we can't avoid making heavy use of resources, better to use CPU than ever more RAM.
2005-11-12[lib] 'show route-map' should print call action seperate from exit policypaul
2005-11-12 Paul Jakma <paul.jakma@sun.com> * routemap.c: (vty_show_route_map_entry) call action is seperate from exit action, latter should still be printed regardless of whether a call is specified.
2005-11-032005-11-03 Paul Jakma <paul.jakma@sun.com>paul
* memtypes.h: Update auto-built file.
2005-11-032005-11-03 Paul Jakma <paul.jakma@sun.com>paul
* if.c: (connected_free) use MTYPE for connected label. memtypes.c: Add MTYPE_CONNECTED_LABEL
2005-11-032005-11-03 Paul Jakma <paul.jakma@sun.com>paul
* zebra.h: BSD BYTE_ORDER define isn't available everywhere, define if needs be. * checksum.h: new file. checksum.c exports in_cksum, provide a header for it. * checksum.c: (in_cksum) callers shouldn't have to know it uses a u_short internally, change to void *. * Makefile.am: Add checksum.h * command.h: remove bogus trailling slash. * md5.c: (general) Update it for the twentieth century. ANSI declarations are widely supported now.. Don't include system headers, only include zebra.h. Use POSIX types (the alternative is to define u_int64_t in a portable way - rest of Quagga needs same cleanup). Make endian-conditional code be compiler conditional rather than preprocessor conditional, so that breakage gets noticed quicker. * md5.h: POSIX types. Get rid of the odd __P() non-ANSI capable compiler compatibility hack.
2005-10-262005-10-26 Paul Jakma <paul.jakma@sun.com>paul
* command.c: Use MTYPE_HOST, MTYPE_STRVEC. Some other fixups, including fixing some likely leaks in config_write_file. * vty.c: memory macro usage fixes. (vty_read_config) fix leak where relative config file is specified.
2005-10-262005-10-26 Paul Jakma <paul.jakma@sun.com>paul
* (general) Cleanup a some calls to XFREE,strdup, etc. to use the memory.h macros. * memtypes.c: Add MTYPE_IF_RMAP_NAME, MTYPE_PQUEUE, MTYPE_PQUEUE_DATA and MTYPE_HOST. * memtypes.h: update auto-built file. * if_rmap.c: Use MTYPE_IF_RMAP_NAME. * pqueue.c: Use the two MTYPE_PQUEUE mtypes for allocations.
2005-10-212005-10-20 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* sockopt.c: (setsockopt_multicast_ipv4) If IP_ADD_MEMBERSHIP fails with errno equal to EADDRINUSE, then issue an info message and try IP_DROP_MEMBERSHIP followed by IP_ADD_MEMBERSHIP.
2005-10-202005-10-20 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* memory.c: (show_memory_vty) Omit zero statistics. Print separators only if some non-zero stats have been printed in between. (show_separator) New function to print a separator. (show_memory_all) Keep track of whether a separator is needed between the different memory statistics groups.
2005-10-182005-10-18 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* memtypes.h: Add MTYPE_OSPF_VERTEX_PARENT (to match memtypes.c).
2005-10-182005-10-18 Paul Jakma <paul.jakma@sun.com>paul
* (general) SPF memory management cleanup and fix for rare double-free bug. * ospf_spf.h: (struct vertex_parent) New struct to hold parent specific data, eg the backlink and the parent vertex pointer, and point to the appropriate general struct vertex_nexthop. (struct vertex_nexthop) remove parent vertex pointer, so this struct can be shared across vertices. (struct vertex) rename list child to list children. Remove list of nexthops, replace with list of vertex_parents. * ospf_spf.c: (update_stat) trivial, remove cast from void *. (vertex_nexthop_new) remove init of parent - field is gone from struct vertex_nexthop. (ospf_canonical_nexthops_free) Remove the canonical vertex_nexthop memory objects. These are the vertex_nexthops attached to the first level of router vertices from the root. (vertex_parent_new) new function, create a vertex_parent. (vertex_parent_free) ditto, but free it. (ospf_vertex_new) Update to match changes to struct vertex. (ospf_vertex_free) Recursively free a struct vertex and its children. The parent list is used as a reference count. vertex_nexthops must be free seperately, if required. (ospf_vertex_dump) update to match struct vertex changes. Print out backlink of parents too. (ospf_vertex_add_parent) ditto. (ospf_lsa_has_link) update comment. (ospf_nexthop_add_unique) removed, not needed anymore. (ospf_nexthop_merge) ditto. (ospf_spf_consider_nexthop) renamed to ospf_spf_add_parent. Simplified to just create vertex_parent and add it. (ospf_spf_flush_parents) new function, flush out the parent list. (ospf_nexthop_calculation) Take the relevant route_lsa_link as an argument, which simplifies things and removes the need for the hack in ospf_nexthop_add_unique - ospf_spf_next already knew exactly which link the cost calculated was for. Update to match struct vertex changes too. (ospf_spf_next) Don't create a vertex for W unnecessarily, if it's there's a vertex already created for W, use it, and hence there's no need to free it either. Update some manipulation/comparisons of distance to match. Flush the parent list if a lower cost path is found. (ospf_spf_route_free) unused, removed. (ospf_spf_dump) match the struct vertex changes, and dump the ifname if possible. (ospf_spf_calculate) At end of SPF, free the canonical nexthops and call ospf_vertex_free on the root vertex to free the entire tree. * ospf_interface.c: (ospf_vl_set_params) match struct vertex changes. * ospf_route.c: (ospf_intra_route_add) ditto (ospf_route_copy_nexthops_from_vertex) ditto * memtypes.c: (memory_list_ospf) Add MTYPE_OSPF_VERTEX_PARENT.
2005-10-012005-10-01 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* zebra.h: Declare new functions zebra_route_string() and zebra_route_char(). * log.c: (zroute_lookup,zebra_route_string,zebra_route_char) New functions to map zebra route numbers to strings. * zebra_vty.c: (route_type_str) Remove obsolete function: use new library function zebra_route_string() instead. Note that there are a few differences: for IPv6 routes, we now get "ripng" and "ospf6" instead of the old behavior ("rip" and "ospf"). (route_type_char) Remove obsolete function: ues new library function zebra_route_char() instead. Note that there is one difference: the old function returned 'S' for a ZEBRA_ROUTE_SYSTEM route, whereas the new one returns 'X'. (vty_show_ip_route_detail,vty_show_ipv6_route_detail) Replace route_type_str() with zebra_route_string(). (vty_show_ip_route,vty_show_ipv6_route) Replace route_type_char() with zebra_route_char(). * bgp_vty.c: (bgp_config_write_redistribute) Use new library function zebra_route_string instead of a local hard-coded table. * ospf6_asbr.c: Remove local hard-coded tables zroute_name and zroute_abname. Change the ZROUTE_NAME macro to use new library function zebra_route_string(). Remove the ZROUTE_ABNAME macro. (ospf6_asbr_external_route_show): Replace ZROUTE_ABNAME() with a call to zebra_route_char(), and be sure to fix the format string, since we now have a char instead of a char *. * ospf6_zebra.c: Remove local hard-coded tables zebra_route_name and zebra_route_abname. Note that the zebra_route_name[] table contained mixed-case strings, whereas the zebra_route_string() function returns lower-case strings. (ospf6_zebra_read_ipv6): Change debug message to use new library function zebra_route_string() instead of zebra_route_name[]. (show_zebra): Use new library function zebra_route_string() instead of zebra_route_name[]. * ospf_dump.c: Remove local hard-coded table ospf_redistributed_proto. (ospf_redist_string) New function implemented using new library function zebra_route_string(). Note that there are a few differences in the output that will result: the new function returns strings that are lower-case, whereas the old table was mixed case. Also, the old table mapped ZEBRA_ROUTE_OSPF6 to "OSPFv3", whereas the new function returns "ospf6". * ospfd.h: Remove extern struct message ospf_redistributed_proto[], and add extern const char *ospf_redist_string(u_int route_type) instead. * ospf_asbr.c: (ospf_external_info_add) In two messages, use ospf_redist_string instead of LOOKUP(ospf_redistributed_proto). * ospf_vty.c: Remove local hard-coded table distribute_str. (config_write_ospf_redistribute,config_write_ospf_distribute): Use new library function zebra_route_string() instead of distribute_str[]. * ospf_zebra.c: (ospf_redistribute_set,ospf_redistribute_unset, ospf_redistribute_default_set,ospf_redistribute_check) In debug messages, use ospf_redist_string() instead of LOOKUP(ospf_redistributed_proto). * rip_zebra.c: (config_write_rip_redistribute): Remove local hard-coded table str[]. Replace str[] with calls to new library function zebra_route_string(). * ripd.c: Remove local hard-coded table route_info[]. (show_ip_rip) Replace uses of str[] with calls to new library functions zebra_route_char and zebra_route_string. * ripng_zebra.c: (ripng_redistribute_write) Remove local hard-coded table str[]. Replace str[i] with new library function zebra_route_string(i). * ripngd.c: Remove local hard-coded table route_info[]. (show_ipv6_ripng) Use new library function zebra_route_char() instead of table route_info[].
2005-09-292005-09-29 Alain Ritoux <alain.ritoux@6wind.com>vincent
* lib/smux.[ch]: allow to retreive global OID (identified by <0 namelen). * ospf_ism.c: generate SNMP traps on Interface state change * ospf_nsm.c: generate SNMP traps on Neighbour state change * ospf_snmp.[ch]: support for SNMP traps for interface and neighbours.
2005-09-292005-09-29 Paul Jakma <paul.jakma@sun.com>paul
* configure.ac: Add the test for Solaris least-privileges. Set defines for whether capabilities are supported and whether of the linux or solaris variety. Add missing-prototypes, missing-declarations, char-subscripts and cast-qual warnings to default cflags, cause Hasso enjoys warnings, and we really should clean the remaining ones up. (ie isisd..). * (*/*main.c) Update the zebra_capabilities_t arrays in the various daemons to match the changes made in lib/privs.h. * zebra.h: Solaris capabilities requires priv.h to be included. * privs.{c,h}: Add support for Solaris Least-Privileges. privs.h: Reduce some of the abstract capabilities, which do not have rough equivalents on both systems. Rename the net related caps to _NET, as they should have been in first place. (zprivs_terminate) should take the zebra_privs_t as argument so that it can update change pointer. Add an additional privilege state, ZPRIVS_UNKNOWN. * privs.c: (various capability functions) Add Solaris privileges variants. (zprivs_state) Use privs.c specific generic types to represent various capability/privilege related types, so that each can be typedef'd as appropriate on each platform. (zprivs_null_state) static added, to hold the state the null method should report (should be raised by default, and LOWERED if zprivs_terminate has been called) (zprivs_state_null) Report back the zprivs_null_state. (cap_map) Make it able to map abstract capability to multiple system capabilities. (zcaps2sys) Map to abstract capabilities to multiple system privileges/capabilities. (zprivs_init) move capability related init to seperate function, zprivs_caps_init. (zprivs_terminate) ditto, moved to zprivs_caps_terminate. Set the change_state callback to the NULL state, so the user can continue to run and use the callbacks.
2005-09-292005-09-29 Alain Ritoux <alain.ritoux@6wind.com>vincent
* lib/filer.c: show protocol name in filter_show() * lib/plist.c: show protocol name in vty_show_prefix_entry() * routemap.c: show protocol name in vty_show_route_map_entry() * lib/vty.c: in vty_command(), show protocol name if command unknown * zebra/zserv.c: Always provide distance fo route add * ripd/rip_snmp.c: rip2IfConfReceive() sends values in conformance with RFC. Also PeerDomain is now set to a STRING type. * ripd/ripd.h: rip_redistribute_add() API includes metric and distance * ripd/ripd.c: rip_redistribute_add() API i.e. stores metric and distance Now allows a RIP-route to overcome a redistributed route coming from a protocol with worse (higher) administrative distance Metrics from redistribution are shown in show ip rip * ripd/rip_zebra.c: adapt to the rip_redistribute_add() API, i.e. provide distance and metric * ripd/rip_interface.c: adapt to the rip_redistribute_add() API * ripd/rip_routemap.c: no RMAP_COMPILE_ERROR on (metric > 16) usage rather a CMD_WARNING, because set metric ius shared with other protocols using larger values (such as OSPF) The match metric action takes first external metric if present (from redistribution) then RIP metric.
2005-09-282005-09-28 Alain Ritoux <alain.ritoux@6wind.com>vincent
* lib/md5-gnu.h: removed * lib/md5.h: replaces md5-gnu.h * lib/Makefile.am: use correct md5.h * lib/md5.c: import from WIDE * ospfd/ospf_packet.c: use new md5 API * ripd/ripd.c: use new md5 API
2005-09-212005-09-21 Paul Jakma <paul.jakma@sun.com>paul
* memtypes.{c,h}: Add MTYPE_AS_SEG_DATA.
2005-09-19 * configure.ac: Test existance of strndup.hasso
* lib/str.[ch]: Add strndup() from glibc.
2005-09-052005-09-05 Paul Jakma <paul.jakma@sun.com>paul
* command.c: (install_element) be more robust. Eg, cmd_init need not have been called, some applications may use other library subsystems, which call install_element, without the application wanting commands and hence not calling cmd_init.
2005-08-222005-08-22 Hugo Santos <hsantos@av.it.pt>paul
* command.h: (enum node_type) Add BGP_IPV6M_NODE * command.c: (node_parent) Handle BGP_IPV6M_NODE node (config_exit, config_end) ditto * vty.c: (vty_end_config) Handle BGP_IPV6M_NODE node
2005-08-102005-08-10 Greg Troxel <gdt@fnord.ir.bbn.com>gdt
* getopt.h: Don't declare getopt (rather than getopt_long), since quagga doesn't need it. * getopt.c (getopt): Don't define getopt. Fixes build breakage on NetBSD, and seems likely to work on most platforms since it avoids the entire issue of system getopt declarations and whether they conform to POSIX.2. Note that this change doesn't address system getopt_long declarations, but also doesn't change anything about getopt_long.
2005-07-262005-07-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* prefix.c: (prefix_ipv4_new, prefix_ipv6_new): Call prefix_new to allocate the memory to make sure that all struct prefix pointers point to objects of the same length (avoids memory overruns on struct prefix assignments). (prefix_ipv4_free, prefix_ipv6_free): Simply call prefix_free. It is interesting to note that these functions are never actually called anywhere in the code. Instead prefix_free was already being called directly, despite the previous MTYPE incompatibility. [backport candidate]
2005-07-262005-07-26 Andrew J. Schorr <ajschorr@alumni.princeton.edu>ajs
* prefix.c: (ip_masklen) While loop should test that 'pnt' pointer is in range before dereferencing it. [backport candidate]
2005-06-242005-06-24 Pawel Worach <pawel.worach@gmail.com>paul
* getopt.h: add further tests for full getopt declaration on various systems.
2005-06-182005-06-18 Paul Jakma <paul.jakma@sun.com>paul
* memtypes.h: update autobuilt file to match memtypes.c changes
2005-06-012005-06-01 Paul Jakma <paul.jakma@sun.com>paul
* bgpd/(general) refcount struct peer and bgp_info, hence allowing us add work_queues for bgp_process. * bgpd/bgp_route.h: (struct bgp_info) Add 'lock' field for refcount. Add bgp_info_{lock,unlock} helper functions. Add bgp_info_{add,delete} helpers, to remove need for users managing locking/freeing of bgp_info and bgp_node's. * bgpd/bgp_table.h: (struct bgp_node) Add a flags field, and BGP_NODE_PROCESS_SCHEDULED to merge redundant processing of nodes. * bgpd/bgp_fsm.h: Make the ON/OFF/ADD/REMOVE macros lock and unlock peer reference as appropriate. * bgpd/bgp_damp.c: Remove its internal prototypes for bgp_info_delete/free. Just use bgp_info_delete. * bgpd/bgpd.h: (struct bgp_master) Add work_queue pointers. (struct peer) Add reference count 'lock' (peer_lock,peer_unlock) New helpers to take/release reference on struct peer. * bgpd/bgp_advertise.c: (general) Add peer and bgp_info refcounting and balance how references are taken and released. (bgp_advertise_free) release bgp_info reference, if appropriate (bgp_adj_out_free) unlock peer (bgp_advertise_clean) leave the adv references alone, or else call bgp_advertise_free cant unlock them. (bgp_adj_out_set) lock the peer on new adj's, leave the reference alone otherwise. lock the new bgp_info reference. (bgp_adj_in_set) lock the peer reference (bgp_adj_in_remove) and unlock it here (bgp_sync_delete) make hash_free on peer conditional, just in case. * bgpd/bgp_fsm.c: (general) document that the timers depend on bgp_event to release a peer reference. (bgp_fsm_change_status) moved up the file, unchanged. (bgp_stop) Decrement peer lock as many times as cancel_event canceled - shouldnt be needed but just in case. stream_fifo_clean of obuf made conditional, just in case. (bgp_event) always unlock the peer, regardless of return value of bgp_fsm_change_status. * bgpd/bgp_packet.c: (general) change several bgp_stop's to BGP_EVENT's. (bgp_read) Add a mysterious extra peer_unlock for ACCEPT_PEERs along with a comment on it. * bgpd/bgp_route.c: (general) Add refcounting of bgp_info, cleanup some of the resource management around bgp_info. Refcount peer. Add workqueues for bgp_process and clear_table. (bgp_info_new) make static (bgp_info_free) Ditto, and unlock the peer reference. (bgp_info_lock,bgp_info_unlock) new exported functions (bgp_info_add) Add a bgp_info to a bgp_node in correct fashion, taking care of reference counts. (bgp_info_delete) do the opposite of bgp_info_add. (bgp_process_rsclient) Converted into a work_queue work function. (bgp_process_main) ditto. (bgp_processq_del) process work queue item deconstructor (bgp_process_queue_init) process work queue init (bgp_process) call init function if required, set up queue item and add to queue, rather than calling process functions directly. (bgp_rib_remove) let bgp_info_delete manage bgp_info refcounts (bgp_rib_withdraw) ditto (bgp_update_rsclient) let bgp_info_add manage refcounts (bgp_update_main) ditto (bgp_clear_route_node) clear_node_queue work function, does per-node aspects of what bgp_clear_route_table did previously (bgp_clear_node_queue_del) clear_node_queue item delete function (bgp_clear_node_complete) clear_node_queue completion function, it unplugs the process queues, which have to be blocked while clear_node_queue is being processed to prevent a race. (bgp_clear_node_queue_init) init function for clear_node_queue work queues (bgp_clear_route_table) Sets up items onto a workqueue now, rather than clearing each node directly. Plugs both process queues to avoid potential race. (bgp_static_withdraw_rsclient) let bgp_info_{add,delete} manage bgp_info refcounts. (bgp_static_update_rsclient) ditto (bgp_static_update_main) ditto (bgp_static_update_vpnv4) ditto, remove unneeded cast. (bgp_static_withdraw) see bgp_static_withdraw_rsclient (bgp_static_withdraw_vpnv4) ditto (bgp_aggregate_{route,add,delete}) ditto (bgp_redistribute_{add,delete,withdraw}) ditto * bgpd/bgp_vty.c: (peer_rsclient_set_vty) lock rsclient list peer reference (peer_rsclient_unset_vty) ditto, but unlock same reference * bgpd/bgpd.c: (peer_free) handle frees of info to be kept for lifetime of struct peer. (peer_lock,peer_unlock) peer refcount helpers (peer_new) add initial refcounts (peer_create,peer_create_accept) lock peer as appropriate (peer_delete) unlock as appropriate, move out some free's to peer_free. (peer_group_bind,peer_group_unbind) peer refcounting as appropriate. (bgp_create) check CALLOC return value. (bgp_terminate) free workqueues too. * lib/memtypes.c: Add MTYPE_BGP_PROCESS_QUEUE and MTYPE_BGP_CLEAR_NODE_QUEUE