summaryrefslogtreecommitdiffstats
path: root/lib/qpthreads.c
Commit message (Collapse)AuthorAgeFilesLines
* Fix problems with handling of oversize BGP messagesex24bChris Hall2012-05-071-48/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The objective is to (as gracefully as possible) deal with outgoing UPDATE messages which simply do not in the maximum size BGP message. This can happen if very large AS_PATH or Community attributes come in, and are then extended. (Sending an UPDATE to an AS2 speaking peer can create a complete second copy of the AS_PATH !) Previous versions of Quagga would crash under these circumstances. Recent version were changed to tolerate and detect oversize messages. Any oversize message is logged as an error and discarded. This version will also withdraw prefixes if the selected route simply cannot be advertised. This version also corrects the handling of messages which are limited to the maximum BGP message size -- in particular UPDATE messages which carry a large number of IPv4/Unicast prefixes. (This was broken by the earlier efforts to handle oversize messages.) Changes in this commit: * update version to 0.99.20ex24b * where a set of attributes is too big to fit into a BGP message, or so big that not even one prefix will also fit into a BGP message, the following steps are now taken: - the BGP message is discarded and an error logged (as in other recent versions -- Quagga does not crash). - any prefixes which should have been advertised with the (broken) attributes will be withdrawn, if they have been advertised earlier with valid attributes. A further error is logged, listing the affected prefixes. - prefixes which are suppressed in this way are not counted as having been sent. At present there is no "show" command which will show which prefixes have been suppress -- TBA. * for all AFI/SAFI announce as many withdrawn prefixes as will fit in a BGP message. Previously, all AFI/SAFI other than IPv4/Unicast would send one withdrawn prefix per message. (This is still the case for announcements. It seems unlikely that many IPv6 prefixes will have the same attributes... so this does not seem worth fixing immediately.) * ensure that NOTIFICATION message cannot exceed the maximum length of a BGP message, no matter how much data is sent (!). * where IPv4/Unicast prefixes share the same attributes, they are now announced in the order received. Previously, when prefixes were added to the list hung off the 'struct bgp_advertise_attr', they were in LIFO order. * add SAFI name table. * log pthread attributes when creating a pthread. * fix scheduling of withdrawn prefixes to reduce number of BGP messages generated. Bug fixes: * fix discard of invalid IPv6 link-local nexthop (recent bug). * where amount of information that is put into a BGP message is limited by the maximum message size, fix so that this works again. (This was broken recently.) * set "Bottom of Stack" bit in MPLS VPN "tag" in MP_REACH and MP_UNREACH outgoing attributes.
* Improve error handling in lib/qpthreads and lib/qtimeChris Hall2012-04-191-22/+116
| | | | | | | | | | | | | | | | | | | | Error handling now: * gives name of mutex when fails. * if clock_gettime() fails, this is fatal for CLOCK_REALTIME and CLOCK_MONOTONIC (as before) but not for any other clock (new behaviour). * log errors (and other anomalies) in pthread_getcpuclockid(), but do not abort. Remove a couple of warnings about variable "format" values for printf-like functions. Fix bug in new vtysh/extract.pl -- change mechanics of extracting CMD_INSTALL_TABLE entries, so that deals better with #if etc between entries.
* Tidy up after testing on FreeBSD 9.0Chris Hall2012-04-171-3/+14
| | | | | | | | | | | | | | | | gcc 4.6.1 picked up a couple of (spurious) "may be used unitialised" variables -- fixed. For reasons unknown FreeBSD unistd.h declares _POSIX_THREAD_SAFE_FUNCTIONS as -1... which tripped a CONFIRM(). _POSIX_SPIN_LOCKS is declared 200112, and according to POSIX-2004 _POSIX_SPIN_LOCKS => _POSIX_THREAD_SAFE_FUNCTIONS -- so it is a bit of a surprise (though the statement in POSIX is in the context of support for "Advanced Realtime Threads", which includes _POSIX_SPIN_LOCKS)... Recast to warn instead of generate compilation error. Fixed test-prefix.c to work with uint8_t sa_family_t !
* Watch-Dog Work-in-ProgressChris Hall2012-04-161-5/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Added -W command line argument to bgpd to start watch-dog: -W99[,[+]path] where: 99 is the watch-dog interval, eg. 2 or 5 path is file that watch-dog writes to -- default is stderr. if '+' is given, will append to the file. Watch-Dog looks out for: * not being woken up when expected. * CLOCK_REALTIME and CLOCK_MONOTONIC not advancing together. * pthreads stalling. * mutexes being locked for long periods. * CPU consumption by each pthread in each watch-dog interval. If pthreads are locking up or going into a flat spin, the Watch-Dog should spot it. Pro tem: outputs pthread properties to stderr at start-up.
* Remove CONFIRM(_POSIX_REENTRANT_FUNCTIONS) -- not POSIX !Chris Hall2012-04-121-38/+231
| | | | | | | | | | | | | Turns out that _POSIX_REENTRANT_FUNCTIONS is not a POSIX feature test macro... name notwithstanding. It appears to be quite well known, but in some cases appears to be a feature request, and in others a feature test :-( So, since it adds no value -- and breaks FreeBSD -- the CONFIRM is removed. Further work in progress for Watch-Dog -- all known mutexes are held in an all known mutexes list, complete with name of mutex for diagnostic purposes.
* Further work on Watch-Dog and extend "debug bgp update"Chris Hall2012-04-111-0/+57
| | | | | | | | | | | | | | | | | For "debug bgp update out" log the dispatch of UPDATE messages by the BGP Engine -- so the logging shows what the Routing Engine decided to send, and the BGP Engine show what was actually written away. [In passing, in bgp_connection_write_action() treat a zero return from write() and an EAGAIN/EWOULDBLOCK.] Watch-Dog now tracks the CPU utilisation for each nexus, and checks that each one runs at least once between watch-do runs. The pthread_getcpuclockid() may or may not be supported, and that must be determined at run-time. So, some changes made to the qlib_init_first_stage() to capture this.
* Remove a number of "assigned but unused" warnings and other WIPChris Hall2012-04-101-1/+171
| | | | | | | | | | | | | | -Wunused-but-set-variable throws up a number of errors, this patch removes some of thos in bgpd, lib and zebra. Fix crash in vty when using ">*" /dev/null output pipe. Work in Progress (WIP): 1) adding "Watch-Dog" pthread to keep an eye on all other pthreads and state of mutexes etc. 2) creation of Integrated Configuration in vtysh.
* Tidy up some XMALLOC items that were not being XFREE'd.Chris Hall2012-03-221-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | * bgp_peer_index replace unused bgp_peer_index_reset() by bgp_peer_index_finish() and call same at bgp shut-down. discard unused bgp_peer_index_mutex_free() and replace bgp_peer_index_mutex_init() by bgp_peer_index_init_r(). * lib/command.c and command_parse.c add cmd_parser_finish() to discard store of "words" and arrange to call same in cmd_table_terminate(). * reset vector of files in qps_selection_ream(), so that frees the vector body -- which it should have been doing ! * add mem_mt_show_stderr() for debug (for all the use it may be). * fix qpt_mutex_destroy(), qpt_cond_destroy() and qpt_spin_destroy() so that if fail when !qpthreads_active will log the error (and not crash). Sweeps issues under the carpet, but does not hide same.
* Avoid crashing if fails to destroy mutex etc at shut-downChris Hall2012-03-181-13/+46
| | | | | | At shut-down it is possible that mutexes etc. may not be in a suitable state to be destroyed. But since is shutting down, there is no point in triggering an abort().
* vtysh partly restored. bgpd not crashing on over-size messages.Chris Hall2012-02-191-18/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | NB: this is a partial interim version -- NOT for production. Reinstate vtysh. In bgpd: cope better with generating oversize messages. The "pipework" branch is no more. There is now "euro_ix" and "euro_ix_b", where 'b' stands for 'bleedin'. The "pipework" is currently in 'bleedin'. Version updated to: 0.99.18ex20b Major changes in this commit: * modified bgpd to avoid crashing if an oversize message is created. At present, any oversize messages are simply discarded. This may be a mistake... since it is possible that some routes that should have been withdrawn are not. TBA. The stream lib facilities have been overhauled to may this easier. * restoring vtysh. At present the vtysh is thought to work, except that it does not currently create integrated configuration files. For the time being, *only* the following compile: lib, bgpd, zebra, vtysh, tests All other daemons will fail to compile, and must be disabled.
* Merging of euro_ix branch into pipework.Chris Hall2011-09-021-12/+54
| | | | | | | | Bring in fixes for bgp dumping with pthreaded BGP Engine. Bring in new "show nexus xxx" command. Fix removal of '~' prompt.
* Upgrade of "pipework" -- including piping to/from shell commandsex11pChris Hall2011-03-211-74/+138
| | | | | | Version 0.99.15ex11p A major overhaul.
* Fixes to compile on FreeBSD 8.0 with gcc 4.2.1Chris Hall2010-04-161-3/+3
|
* Add qpthreads_thread_created to lib/qpthreadsChris Hall2010-01-051-1/+3
| | | | | Flag indicates that at least one thread has been created. (To be used to ensure no surprises when daemonising !)
* Initial commit for bgp_engine branch -- seeding new files...Chris Hall2010-01-041-9/+41
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On branch bgp_engine modified: .gitignore modified: bgpd/Makefile.am new file: bgpd/bgp.h new file: bgpd/bgp_common.c new file: bgpd/bgp_common.h new file: bgpd/bgp_connection.c new file: bgpd/bgp_connection.h modified: bgpd/bgp_debug.c new file: bgpd/bgp_engine.c new file: bgpd/bgp_engine.h modified: bgpd/bgp_fsm.c modified: bgpd/bgp_fsm.h modified: bgpd/bgp_network.c modified: bgpd/bgp_network.h new file: bgpd/bgp_notification.c new file: bgpd/bgp_notification.h modified: bgpd/bgp_open.c new file: bgpd/bgp_open_state.c new file: bgpd/bgp_open_state.h modified: bgpd/bgp_packet.c new file: bgpd/bgp_peer.c new file: bgpd/bgp_peer.h modified: bgpd/bgp_route.c new file: bgpd/bgp_session.c new file: bgpd/bgp_session.h modified: bgpd/bgp_vty.c modified: bgpd/bgp_zebra.c modified: bgpd/bgpd.c modified: bgpd/bgpd.h modified: lib/Makefile.am modified: lib/memtypes.c modified: lib/mqueue.c modified: lib/mqueue.h new file: lib/qafi_safi.h modified: lib/qpselect.c modified: lib/qpselect.h modified: lib/qpthreads.c modified: lib/qpthreads.h modified: lib/sockopt.c modified: lib/sockunion.c modified: lib/sockunion.h modified: lib/stream.c modified: lib/stream.h modified: lib/symtab.h modified: lib/zebra.h
* Add qpt_thread_join() to lib/qpthreadsChris Hall (GMCH)2009-12-171-0/+28
|
* Introduced qpthreads_enabled flag in lib/qpthreadsChris Hall (GMCH)2009-12-101-43/+186
| | | | | | This supports running without pthreads, but with code that is made thread-safe. A Big Switch -- qpthreads_enabled -- enables or disables all pthread functions. When disabled, all mutex calls become NOPs.
* Ensure all timeouts are timeout times in qtime_mono_t.Chris Hall (GMCH)2009-12-091-9/+31
| | | | | | | | | | | | | | | | | | Introduced separate types for qtime_mono_t and qtime_real_t, to distinguish the time base of a given value. Revised all users of timeouts so that they are all expressed as qtime_mono_t values, so are all Quagga monotonic time based. Revised qpt_cond_timedwait() so that all condition variables use the same timebase (CLOCK_MONOTONIC if available, by default). Now all timeout times are qtime_mono_t, and are converted to whatever the condition variable is set to, if necessary. Added explicit timeout to mqueue. Fixed qps_pselect() to zeroise result vectors if no fds are reported pending -- seems the O/S does not do this.
* Enabled qpt_mutex_recursive in lib/qpthreads.Chris Hall (GMCH)2009-12-071-0/+64
| | | | | | | | | This allows mutexes to be initialised as recursive. Required correctly placed setting of _GNU_SOURCE (for gcc). It is assumed that "config.h" will enable the required pthreads features -- which are now documented in lib/qpthread.c.
* Updates to lib/qpthreads.c & .hChris Hall (GMCH)2009-12-061-0/+3
| | | | | | Added qpt_thread_self(). Initialised output sigset_t before setting it in qpt_thread_sigmask().
* Add signal functions to lib/qpthreads.cChris Hall (GMCH)2009-12-031-0/+46
| | | | Adding qpt_thread_sigmask() and qpt_thread_signal().
* Pthreads infrastructure -- initial commitChris Hall (GMCH)2009-12-021-0/+435
New files: lib/qpthreads.c & .h Encapsulates the Pthreads facilities to be used in Quagga. Implicitly documents the sub-set of Pthreads being used. Provides error checking for a number of functions which may return errors, but are not generally expected to and for whom an error is treated as fatal. Could be modified to "null out" the use of Pthreads. New files: lib/qtime.c & .h Defines a 64-bit integer time value which is a lot easier to handle than the usual timespec and timeval structures. (C99 requires a 64-bit integer.) Provides front ends for gettimeofday() & clock_gettime() which return 64-bit time value. Also conversions to and from timespec and timeval. Provides a monotonic clock for when CLOCK_MONOTONIC is not available. (This is based on code from Joakim Tjernlund.) New files: lib/heap.c & .h Implements a heap data structure closely allied to the vector. This will be used for timer handling. Modified: lib/memtypes.c New memory types for qpthreads structures and for the heap. Modified: lib/zassert.h Added explicit "passert" == assert which is not subject to NDEBUG. Added explicit "nassert" == assert which is subject to NDEBUG. Added zabort, zabort_errno and zabbort_err for when something has gone fatally wrong. (Require changes to lib/log.c which are TBD.)