summaryrefslogtreecommitdiff
path: root/bgpd/bgpd.c
AgeCommit message (Collapse)Author
2009-07-19[bgpd] Stability fixes including bugs 397, 492Chris Caputo
I've spent the last several weeks working on stability fixes to bgpd. These patches fix all of the numerous crashes, assertion failures, memory leaks and memory stomping I could find. Valgrind was used extensively. Added new function bgp_exit() to help catch problems. If "debug bgp" is configured and bgpd exits with status of 0, statistics on remaining lib/memory.c allocations are printed to stderr. It is my hope that other developers will use this to stay on top of memory issues. Example questionable exit: bgpd: memstats: Current memory utilization in module LIB: bgpd: memstats: Link List : 6 bgpd: memstats: Link Node : 5 bgpd: memstats: Hash : 8 bgpd: memstats: Hash Bucket : 2 bgpd: memstats: Hash Index : 8 bgpd: memstats: Work queue : 3 bgpd: memstats: Work queue item : 2 bgpd: memstats: Work queue name string : 3 bgpd: memstats: Current memory utilization in module BGP: bgpd: memstats: BGP instance : 1 bgpd: memstats: BGP peer : 1 bgpd: memstats: BGP peer hostname : 1 bgpd: memstats: BGP attribute : 1 bgpd: memstats: BGP extra attributes : 1 bgpd: memstats: BGP aspath : 1 bgpd: memstats: BGP aspath str : 1 bgpd: memstats: BGP table : 24 bgpd: memstats: BGP node : 1 bgpd: memstats: BGP route : 1 bgpd: memstats: BGP synchronise : 8 bgpd: memstats: BGP Process queue : 1 bgpd: memstats: BGP node clear queue : 1 bgpd: memstats: NOTE: If configuration exists, utilization may be expected. Example clean exit: bgpd: memstats: No remaining tracked memory utilization. This patch fixes bug #397: "Invalid free in bgp_announce_check()". This patch fixes bug #492: "SIGBUS in bgpd/bgp_route.c: bgp_clear_route_node()". My apologies for not separating out these changes into individual patches. The complexity of doing so boggled what is left of my brain. I hope this is all still useful to the community. This code has been production tested, in non-route-server-client mode, on a linux 32-bit box and a 64-bit box. Release/reset functions, used by bgp_exit(), added to: bgpd/bgp_attr.c,h bgpd/bgp_community.c,h bgpd/bgp_dump.c,h bgpd/bgp_ecommunity.c,h bgpd/bgp_filter.c,h bgpd/bgp_nexthop.c,h bgpd/bgp_route.c,h lib/routemap.c,h File by file analysis: * bgpd/bgp_aspath.c: Prevent re-use of ashash after it is released. * bgpd/bgp_attr.c: #if removed uncalled cluster_dup(). * bgpd/bgp_clist.c,h: Allow community_list_terminate() to be called from bgp_exit(). * bgpd/bgp_filter.c: Fix aslist->name use without allocation check, and also fix memory leak. * bgpd/bgp_main.c: Created bgp_exit() exit routine. This function frees allocations made as part of bgpd initialization and, to some extent, configuration. If "debug bgp" is configured, memory stats are printed as described above. * bgpd/bgp_nexthop.c: zclient_new() already allocates stream for ibuf/obuf, so bgp_scan_init() shouldn't do it too. Also, made it so zlookup is global so bgp_exit() can use it. * bgpd/bgp_packet.c: bgp_capability_msg_parse() call to bgp_clear_route() adjusted to use new BGP_CLEAR_ROUTE_NORMAL flag. * bgpd/bgp_route.h: Correct reference counter "lock" to be signed. bgp_clear_route() now accepts a bgp_clear_route_type of either BGP_CLEAR_ROUTE_NORMAL or BGP_CLEAR_ROUTE_MY_RSCLIENT. * bgpd/bgp_route.c: - bgp_process_rsclient(): attr was being zero'ed and then bgp_attr_extra_free() was being called with it, even though it was never filled with valid data. - bgp_process_rsclient(): Make sure rsclient->group is not NULL before use. - bgp_processq_del(): Add call to bgp_table_unlock(). - bgp_process(): Add call to bgp_table_lock(). - bgp_update_rsclient(): memset clearing of new_attr not needed since declarationw with "= { 0 }" does it. memset was already commented out. - bgp_update_rsclient(): Fix screwed up misleading indentation. - bgp_withdraw_rsclient(): Fix screwed up misleading indentation. - bgp_clear_route_node(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT. - bgp_clear_node_queue_del(): Add call to bgp_table_unlock() and also free struct bgp_clear_node_queue used for work item. - bgp_clear_node_complete(): Do peer_unlock() after BGP_EVENT_ADD() in case peer is released by peer_unlock() call. - bgp_clear_route_table(): Support BGP_CLEAR_ROUTE_MY_RSCLIENT. Use struct bgp_clear_node_queue to supply data to worker. Add call to bgp_table_lock(). - bgp_clear_route(): Add support for BGP_CLEAR_ROUTE_NORMAL or BGP_CLEAR_ROUTE_MY_RSCLIENT. - bgp_clear_route_all(): Use BGP_CLEAR_ROUTE_NORMAL. Bug 397 fixes: - bgp_default_originate() - bgp_announce_table() * bgpd/bgp_table.h: - struct bgp_table: Added reference count. Changed type of owner to be "struct peer *" rather than "void *". - struct bgp_node: Correct reference counter "lock" to be signed. * bgpd/bgp_table.c: - Added bgp_table reference counting. - bgp_table_free(): Fixed cleanup code. Call peer_unlock() on owner if set. - bgp_unlock_node(): Added assertion. - bgp_node_get(): Added call to bgp_lock_node() to code path that it was missing from. * bgpd/bgp_vty.c: - peer_rsclient_set_vty(): Call peer_lock() as part of peer assignment to owner. Handle failure gracefully. - peer_rsclient_unset_vty(): Add call to bgp_clear_route() with BGP_CLEAR_ROUTE_MY_RSCLIENT purpose. * bgpd/bgp_zebra.c: Made it so zclient is global so bgp_exit() can use it. * bgpd/bgpd.c: - peer_lock(): Allow to be called when status is "Deleted". - peer_deactivate(): Supply BGP_CLEAR_ROUTE_NORMAL purpose to bgp_clear_route() call. - peer_delete(): Common variable listnode pn. Fix bug in which rsclient was only dealt with if not part of a peer group. Call bgp_clear_route() for rsclient, if appropriate, and do so with BGP_CLEAR_ROUTE_MY_RSCLIENT purpose. - peer_group_get(): Use XSTRDUP() instead of strdup() for conf->host. - peer_group_bind(): Call bgp_clear_route() for rsclient, and do so with BGP_CLEAR_ROUTE_MY_RSCLIENT purpose. - bgp_create(): Use XSTRDUP() instead of strdup() for peer_self->host. - bgp_delete(): Delete peers before groups, rather than after. And then rather than deleting rsclients, verify that there are none at this point. - bgp_unlock(): Add assertion. - bgp_free(): Call bgp_table_finish() rather than doing XFREE() itself. * lib/command.c,h: Compiler warning fixes. Add cmd_terminate(). Fixed massive leak in install_element() in which cmd_make_descvec() was being called more than once for the same cmd->strvec/string/doc. * lib/log.c: Make closezlog() check fp before calling fclose(). * lib/memory.c: Catch when alloc count goes negative by using signed counts. Correct #endif comment. Add log_memstats_stderr(). * lib/memory.h: Add log_memstats_stderr(). * lib/thread.c: thread->funcname was being accessed in thread_call() after it had been freed. Rearranged things so that thread_call() frees funcname. Also made it so thread_master_free() cleans up cpu_record. * lib/vty.c,h: Use global command_cr. Add vty_terminate(). * lib/zclient.c,h: Re-enable zclient_free().
2009-07-17[bgpd] Bug #533: Fix crash with copy/pasted commands, inc 'no bgp ...'Paul Jakma
* bgpd.c: Removal of (struct bgp *) from the master list was being left to bgp_free time. This meant there was a window of time between bgp_delete and refcounts hitting 0 (e.g. routes to be processed) where bgp_lookup's could return a deleted (struct bgp *). (bgp_delete) This is the logical place where a (struct bgp *) should lose its visibility, so move the deletion from the bgp-master list to here, from bgp_free. Many thanks to Fritz Reichmann for his thorough debugging of the problem and testing of fixes and Chris Caputo for his further analysis.
2009-06-18[bgpd] reference count the BGP instanceStephen Hemminger
When a BGP instance is deleted with lots of routes and neighbors it is possible for the peer rsclient queue to run after bgp_delete has been called. This would lead to bgpd crashing, see https://bugzilla.vyatta.com/show_bug.cgi?id=3436 The fix is to add reference counting to the BGP instance and defer actual freeing until all references are gone. This patch also fixes a memory leak where the self-reference peer instance was being created but never freed. The check in bgp_clear_route is no longer valid because it is possible for it to be called when peer is in Deleted state during cleanup.
2009-06-12[cleanup] functions taking no args should be declared with void argsStephen Hemminger
Use Ansi-C prototypes rather than old K&R method of declaring function without arguments
2009-06-02[bgp] Fix crash on SIGHUP, deref of freed workqueuesSteve Hill
* lib/workqueue.c: free-ing workqueues had never been tested obviously, queue's thread was not being stopped * bgpd/bgpd.c: null out freed workqueues, to prevent acting on freed workqueues
2009-04-30[bgpd] AS4 bugfix by Chris Caputo <ccaputo@alt.net>Denis Ovsienko
* bgpd/bgp_aspath.c: (aspath_make_str_count) "assert (len < str_size)" was getting hit under certain 4-byte ASN conditions. New realloc strategy. * bgpd/bgp_aspath.c: (aspath_key_make) const warning fix. "%d" -> "%u" 4-byte ASN corrections. Prevent negative number when ASN is above 2^31.
2008-08-26Revert "[bgpd] Add 'bgp open-accept' option, to send OPEN immediately on ↵Paul Jakma
accepted conns" Revert commit d664ae1182c29b74b409bc8594b7bd0575e91ce9. An experimental patch which violates RFC4271 quite badly, but managed to accidently sneak its way in.
2008-08-22[bgpd] Add 'bgp open-accept' option, to send OPEN immediately on accepted connsPaul Jakma
2007-08-31 Paul Jakma <paul.jakma@sun.com> * (general) Add 'bgp open-accept' option, to allow bgpd to send OPEN on accepted connections, i.e. to not wait till after collision-detect to send OPEN, which appears to be allowed in RFC4271. This may help speed up establishing sessions, or help avoid FSM problems with sessions to certain peers. Not enabled by default though.
2008-07-21[bgpd] TCP-MD5: password vty configuration and initial Linux supportPaul Jakma
2008-07-21 Paul Jakma <paul.jakma@sun.com> * bgp_packet.c: (bgp_open_receive) fix warning in a zlog call * bgp_vty.c: (bgp_vty_return) add return code * bgpd.c: (bgp_master_init) setup the socket list. * bgp_network.c: Remove the dual IPv4/6 socket thing for now, which was implemented by Michael, until such time as its clear its required for Linux (see sockopt comments). IPv6 support, including IPv4 sessions on AF_INET6 sockets, therefore is broken, and the '-l 0.0.0.0' arguments would need to be given to bgpd to make things work here. 2008-07-21 Michael H. Warfield <mhw@wittsend.com> YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> Tomohiko Kusuda <kusuda@inetcore.com> Leigh Brown <leigh@solinno.co.uk> * bgp_network.c: (bgp_md5_set_one) shim between libzebra tcp-md5 sockopt and bgpd. (bgp_md5_set_socket) Helper for bgp_connect (bgp_md5_set) setup TCP-MD5SIG for the given peer. (bgp_connect) call out to bgp_md5_set_socket for the outgoing connect socket. (bgp_socket) save references to the listen sockets, needed if TCP-MD5SIG is applied later or changed. * bgp_vty.c: (*neighbor_password_cmd) New 'neighbor ... password' commands. * bgpd.c: (peer_{new,delete) manage TCP-MD5 password (peer_group2peer_config_copy) inherit TCP-MD5 password (peer_password_{un,}set) orchestrate the whole add/remove of TCP-MD5 passwords: applying checks, stopping peers, and trying to return errors to UI, etc. (bgp_config_write_peer) save password. Fix missing newline in writeout of neighbor ... port. 2008-07-21 Paul Jakma <paul.jakma@sun.com> * sockunion.c: ifdef out various places that converted v4mapped sockets to pure v4. Doesn't seem necessary at all, presumably a workaround for now historical inet_ntop bugs (?) 2008-07-21 Michael H. Warfield <mhw@wittsend.com> YOSHIFUJI Hideaki <yoshfuji@linux-ipv6.org> * sockopt.{c,h}: (sockopt_tcp_signature) Add TCP-MD5SIG support.
2008-07-02[bgpd] Fix double-free crash in bgp_table_finish, seen with rs-clientPaul Jakma
2008-07-02 Stephen Hemminger <stephen.hemminger@vyatta.com> * bgp_table.{c,h}: (bgp_table_finish) Take a double pointer and scrub pointer in caller, so fixing double-free crashes seen with route-server-client configuration. * *.c: Adjust all callers of bgp_table_finish 2008-07-02 Paul Jakma <paul.jakma@sun.com> * bgp_table.{c,h}: (bgp_node_delete, bgp_table_free) shouldn't be exported.
2007-11-012007-10-30 Nick Hilliard <nick@inex.ie>Paul Jakma
* bgp_main.c: Add 'listenon' argument, to pass address to bind to. * bgp_network.c: (bgp_socket) Extend to take bind address. * bgpd.c: (bgp_init) Pass stored address. * bgpd.h: (struct bgp_master) storage for bind address 2007-11-01 Paul Jakma <paul.jakma@sun.com> * tools/multiple-bgpd.sh: New, quick script to launch a bunch of bgpds.
2007-04-10[bgpd] bug #352: IPv6/Multicast address-family config not written outPaul Jakma
2007-04-07 Paul Jakma <paul.jakma@sun.com> * bgpd.c: (general) Fix bug #352 (bgp_config_write_family_header) write ipv6/multicast address family header. (bgp_config_write) write out ipv6 multicast AF config.
2006-10-22[bgpd] struct peer must have bgp field valid (redistribute crash)Paul Jakma
2006-10-19 Paul Jakma <paul.jakma@sun.com> * bgpd.c: (peer_new) bgp element of peer absolutely must be filled in, make peer_new() require it as argument and update all callers. Fixes a crash reported by Jan 'yanek' Bortl and Andrew Schorr where bgpd would crash in bgp_pcount_adjust trying to dereference the bgp member of bgp->peer_self, triggered through redistribution. * bgp_route.c: (bgp_pcount_adjust) assert sanity of arguments.
2006-09-19[bgpd] Trivial fix of printf format/arg mismatchAndrew J. Schorr
2006-09-19 Andrew J. Schorr <ajschorr@alumni.princeton.edu> * bgpd.c: (peer_uptime) Fix printf format/arg mismatch in zlog_warn message (%ld/size_t -> %lu/u_long).
2006-09-14[bgpd] simplify peer refcounts, squash slow peer leakPaul Jakma
2006-09-14 Paul Jakma <paul.jakma@sun.com> * (general) fix the peer refcount issue exposed by previous, by just removing refcounting of peer threads, which is mostly senseless as they're references leading from struct peer, which peer_free cancels anyway. No need to muck around.. * bgp_fsm.h: Just remove the refcounting from the various TIMER/READ/WRITE/EVENT ON/OFF/ADD macros. * bgp_fsm.c: (bgp_stop) use BGP_EVENT_FLUSH, no refcounts attached to events anymore. (bgp_event) remove peer_unlock, events not refcounted. * bgpd.c: (peer_free) flush events before free.
2006-09-14[bgpd] Fix 0.99 shutdown regression, introduce Clearing and Deleted statesPaul Jakma
2006-09-14 Paul Jakma <paul.jakma@sun.com> * (general) Fix some niggly issues around 'shutdown' and clearing by adding a Clearing FSM wait-state and a hidden 'Deleted' FSM state, to allow deleted peers to 'cool off' and hit 0 references. This introduces a slow memory leak of struct peer, however that's more a testament to the fragility of the reference counting than a bug in this patch, cleanup of reference counting to fix this is to follow. * bgpd.h: Add Clearing, Deleted states and Clearing_Completed and event. * bgp_debug.c: (bgp_status_msg[]) Add strings for Clearing and Deleted. * bgp_fsm.h: Don't allow timer/event threads to set anything for Deleted peers. * bgp_fsm.c: (bgp_timer_set) Add Clearing and Deleted. Deleted needs to stop everything. (bgp_stop) Remove explicit fsm_change_status call, the general framework handles the transition. (bgp_start) Log a warning if a start is attempted on a peer that should stay down, trying to start a peer. (struct .. FSM) Add Clearing_Completed events, has little influence except when in state Clearing to signal wait-state can end. Add Clearing and Deleted states, former is a wait-state, latter is a placeholder state to allow peers to disappear quietly once refcounts settle. (bgp_event) Try reduce verbosity of FSM state-change debug, changes to same state are not interesting (Established->Established) Allow NULL action functions in FSM. * bgp_packet.c: (bgp_write) Use FSM events, rather than trying to twiddle directly with FSM state behind the back of FSM. (bgp_write_notify) ditto. (bgp_read) Remove the vague ACCEPT_PEER peer_unlock, or else this patch crashes, now it leaks instead. * bgp_route.c: (bgp_clear_node_complete) Clearing_Completed event, to end clearing. (bgp_clear_route) See extensive comments. * bgpd.c: (peer_free) should only be called while in Deleted, peer refcounting controls when peer_free is called. bgp_sync_delete should be here, not in peer_delete. (peer_delete) Initiate delete. Transition to Deleted state manually. When removing peer from indices that provide visibility of it, take great care to be idempotent wrt the reference counting of struct peer through those indices. Use bgp_timer_set, rather than replicating. Call to bgp_sync_delete isn't appropriate here, sync can be referenced while shutting down and finishing deletion. (peer_group_bind) Take care to be idempotent wrt list references indexing peers.
2006-07-27[bgpd] Potential bug#287 fix, peer_delete should NULL out freed buffersPaul Jakma
2006-07-27 Paul Jakma <paul.jakma@sun.com> * bgpd.c: (peer_delete) Ensure freed buffers can not be accidently reused. A potential fix for bug #287.
2006-03-30[bgpd] release peer specific clear queue in peer_freePaul Jakma
2006-03-22 Paul Jakma <paul.jakma@sun.com> * bgpd.c: (peer_free) release the per-peer workqueue when freeing the peer.
2006-02-21[bgpd] Record afi/safi in bgp_table. Serialise peer clear with FSM.Paul Jakma
2006-02-21 Paul Jakma <paul.jakma@sun.com> * bgpd.h: move the clear_node_queue to be peer specific. Add a new peer status flag, PEER_STATUS_CLEARING. * bgp_table.h: (struct bgp_table) Add fields to record afi, safi of the table. (bgp_table_init) Take afi and safi to create table for. * bgp_table.c: (bgp_table_init) record the afi and safi. * bgp_nexthop.c: Update all calls to bgp_table_init. * bgp_vty.c: ditto. * bgpd.c: ditto. * bgp_fsm.c: (bgp_timer_set) dont bring up a session which is clearing. * bgp_route.c: (general) Update all bgp_table_init calls. (bgp_process_{rsclient,main}) clear_node is serialised via PEER_STATUS_CLEARING and fsm now. (struct bgp_clear_node_queue) can be removed. struct bgp_node can be the queue item data directly, as struct peer can be kept in the new wq global user data and afi/safi can be retrieved via bgp_node -> bgp_table. (bgp_clear_route_node) fix to get peer via wq->spec.data, afi/safi via bgp_node->bgp_table. (bgp_clear_node_queue_del) no more item data to delete, only unlock the bgp_node. (bgp_clear_node_complete) only need to unset CLEARING flag and unlock struct peer. (bgp_clear_node_queue_init) queue attaches to struct peer now. record peer name as queue name. (bgp_clear_route_table) If queue transitions to active, serialise clearing by setting PEER_STATUS_CLEARING rather than plugging process queue, and lock peer while queue active. Update to pass only bgp_node as per-queue-item specific data.
2006-01-19[compiler] miscellaneous trivial compiler warning fixespaul
2006-01-19 Paul Jakma <paul.jakma@sun.com> * (general) various miscellaneous compiler warning fixes. Remove redundant break statements from switch clauses which return. return from main, not exit, cause it annoys SOS. Remove stray semi-colons which cause empty-statement warnings. * zebra/main.c: (sighup) remove private declaration of external function.
2005-06-282005-06-28 Paul Jakma <paul.jakma@sun.com>paul
* (global) The great bgpd extern and static'ification. * bgp_routemap.c: remove unused ROUTE_MATCH_ASPATH_OLD code (route_set_metric_compile) fix u_int32_t to ULONG_MAX comparison warnings. * bgp_route.h: (bgp_process, bgp_withdraw, bgp_update) export these used by various files which had their own private declarations, in the case of mplsvpn - incorrect.
2005-06-152005-06-15 Paul Jakma <paul.jakma@sun.com>paul
* bgpd.c: (bgp_terminate) workqueue's are lazy allocated and its possible to terminate bgpd before workqueues were setup, causing an abort/crash. Reported by Ashish Mehta of Sun.
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
2005-05-26 * bgpd.c: Deleting bgp->rsclient list needs fix similar to pree-groupshasso
deleting fix. Avoid leaking bgp->group, bgp->peer and bgp->rsclient lists. [backport candidate]
2005-05-26 * bgpd.c: Don't crash while deleting list of peer-groups.hasso
[backport candidate]
2005-05-25 * bgpd.c: Fix obvious (routeserver patch) merge error. This makes "nohasso
neighbor x.x.x.x routemap [export|import] commands work again. Fixes bugzilla #184. [backport candidate]
2005-05-192005-05-19 Paul Jakma <paul@dishone.st>paul
* bgp_network.c: (bgp_accept) use XSTRDUP * bgpd.c: (peer_delete) XFREE the correct memtype, not free. (peer_create) use XSTRDUP * bgp_packet.c: (bgp_stream_dup) deleted, stream_dup should be used (various) update -> s/bgp_stream_dup/stream_dup
2005-05-192005-05-19 Paul Jakma <paul@dishone.st>paul
* bgp_fsm.c: (bgp_stop) use sockunion_free, not XFREE.. * bgp_network.c: (bgp_getsockname) ditto * bgp_routemap.c: (route_match_peer) ditto, als use a ret value and remove one sockunion_free. * bgpd.c: (peer_delete) ditto
2005-04-08 * bgpd.texi: Document new "bgp bestpath as-path confed" command.hasso
* bgp_aspath.[ch], bgp_route.c, bgp_vty.c, bgpd.[ch]: Allow to enable the length of confederation path segments to be included during the as-path length check in the best path decision.
2005-04-072005-04-07 Paul Jakma <paul.jakma@sun.com>paul
* (global): Fix up list loops to match changes in lib/linklist, and some basic auditing of usage. * configure.ac: define QUAGGA_NO_DEPRECATED_INTERFACES * HACKING: Add notes about deprecating interfaces and commands. * lib/linklist.h: Add usage comments. Rename getdata macro to listgetdata. Rename nextnode to listnextnode and fix its odd behaviour to be less dangerous. Make listgetdata macro assert node is not null, NULL list entries should be bug condition. ALL_LIST_ELEMENTS, new macro, forward-referencing macro for use with for loop, Suggested by Jim Carlson of Sun. Add ALL_LIST_ELEMENTS_RO for cases which obviously do not need the "safety" of previous macro. LISTNODE_ADD and DELETE macros renamed to ATTACH, DETACH, to distinguish from the similarly named functions, and reflect their effect better. Add a QUAGGA_NO_DEPRECATED_INTERFACES define guarded section with the old defines which were modified above, for backwards compatibility - guarded to prevent Quagga using it.. * lib/linklist.c: fix up for linklist.h changes. * ospf6d/ospf6_abr.c: (ospf6_abr_examin_brouter) change to a single scan of the area list, rather than scanning all areas first for INTER_ROUTER and then again for INTER_NETWORK. According to 16.2, the scan should be area specific anyway, and further ospf6d does not seem to implement 16.3 anyway.
2005-02-02 * bgp_route.c, bgp_vty.c, bgp_zebra.c, bgpd.[ch]: "enforce-multihop"hasso
-> "disable-connected-check". [merge from GNU Zebra]
2005-02-02 * bgp_fsm.c, bgp_open.c, bgp_packet.c, bgp_route.[ch], bgp_vty.c,hasso
bgpd.[ch]: Add BGP_INFO_STALE flag and end-of-rib support. "bgp graceful-restart" commands added. Show numbers of individual messages in "show ip bgp neighbor" command. Final pieces of graceful restart. [merge from GNU Zebra]
2005-02-01 * bgp_open.c, bgp_packet.c, bgp_vty.c, bgpd.[ch]: Remove "no neighborhasso
capability route-refresh" commands. Route refresh capability is sent anyway now. Preserve dummy deprecated commands. [merge from GNU Zebra]
2005-02-01 * bgp_attr.c, bgp_snmp.c, bgp_vty.c, bgpd.[ch]: Remove support for oldhasso
draft - ie. "neighbor version 4-" commands. Preserve dummy "neighbor version" command as deprecated. [merge from GNU Zebra]
2005-02-01 * bgpd.[ch], bgp_vty.c, bgp_route.c: "Restart session afterhasso
maximum-prefix limit" feature support. [merge from GNU Zebra]
2005-02-01 * bgp_nexthop.c: Improve debug.hasso
* bgpd.[ch], bgp_nexthop.c, bgp_snmp.c: Remove useless bgp_get_master() function. * bgp_packet.c: MP AFI_IP update and withdraw parsing. * bgp_fsm.c: Reset peer synctime in bgp_stop(). bgp_fsm_change_status() is better place to log about peer status change than bgp_event(). Log in bgp_connect_success(). * bgp_vty.c: Fix typo in comment. * bgp_attr.c: Better log about unknown attribute. [merge from GNU Zebra]
2004-12-09Add comments with warnings obtained on NetBSD/i386. Both are due togdt
size_t being used for streams. Perhaps cast to unsigned long before printf? Surely that's big enough even if size_t could be larger in theory. (no changelog, since only comment changes)
2004-10-312004-10-31 Paul Jakma <paul@dishone.st>paul
* {bgpd,bgp_attr}.c: size_t printf format should be ld.
2004-10-132004-10-13 Paul Jakma <paul@dishone.st>paul
* (global) more const'ification and fixups of types to clean up code. * bgp_mplsvpn.{c,h}: (str2tag) fix abuse. Still not perfect, should use something like the VTY_GET_INTEGER macro, but without the vty_out bits.. * bgp_routemap.c: (set_aggregator_as) use VTY_GET_INTEGER_RANGE (no_set_aggregator_as) ditto. * bgpd.c: (peer_uptime) fix unlikely bug, where no buffer is returned, add comments about troublesome return value.
2004-10-03Common router id.hasso
2004-09-132004-09-13 Jose Luis Rubio <jrubio@dit.upm.es>paul
(at Technical University of Madrid as part of Euro6ix Project) Enhanced Route Server functionality and Route-Maps: * bgpd/bgpd.h: Modified 'struct peer' and 'struct bgp_filter' to support rs-clients. A 'struct bgp_table *rib' has been added to the first (to mantain a separated RIB for each rs-client) and two new route-maps have been added to the last (for import/export policies). Added the following #defines: RMAP_{IN|OUT|IMPORT|EXPORT|MAX}, PEER_RMAP_TYPE_{IMPORT|EXPORT} and BGP_CLEAR_SOFT_RSCLIENT. * bgpd/bgpd.c: Modified the functions that create/delete/etc peers in order to consider the new fields included in 'struct peer' for supporting rs-clients, i.e. the import/export route-maps and the 'struct bgp_table'. * bgpd/bgp_route.{ch}: Modified several functions related with receiving/sending announces in order to support the new Route Server capabilities. Function 'bgp_process' has been reorganized, creating an auxiliar function for best path selection ('bgp_best_selection'). Modified 'bgp_show' and 'bgp_show_route' for displaying information about any RIB (and not only the main bgp RIB). Added commands for displaying information about RS-clients RIBs: 'show bgp rsclient (A.B.C.D|X:X::X:X)', 'show bgp rsclient (A.B.C.D|X:X::X:X) X:X::X:X/M', etc * bgpd/bgp_table.{ch}: The structure 'struct bgp_table' now has two new fields: type (which can take the values BGP_TABLE_{MAIN|RSCLIENT}) and 'void *owner' which points to 'struct bgp' or 'struct peer' which owns the table. When creating a new bgp_table by default 'type=BGP_TABLE_MAIN' is set. * bgpd/bgp_vty.c: The commands 'neighbor ... route-server-client' and 'no neighbor ... route-server-client' now not only set/unset the flag PEER_FLAG_RSERVER_CLIENT, but they create/destroy the 'struct bgp_table' of the peer. Special actions are taken for peer_groups. Command 'neighbor ... route-map WORD (in|out)' now also supports two new kinds of route-map: 'import' and 'export'. Added commands 'clear bgp * rsclient', etc. These commands allow a new kind of soft_reconfig which affects only the RIB of the specified RS-client. Added commands 'show bgp rsclient summary', etc which display a summary of the rs-clients configured for the corresponding address family. * bgpd/bgp_routemap.c: A new match statement is available, 'match peer (A.B.C.D|X:X::X:X)'. This statement can only be used in import/export route-maps, and it matches when the peer who announces (when used in an import route-map) or is going to receive (when used in an export route-map) the route is the same than the one specified in the statement. For peer-groups the statement matches if the specified peer is member of the peer-group. A special version of the command, 'match peer local', matches with routes originated by the Route Server (defined with 'network ...', redistributed routes and default-originate). * lib/routemap.{ch}: Added a new clause 'call NAME' for use in route-maps. It jumps into the specified route-map and when it returns the first route-map ends if the called RM returns DENY_MATCH, or continues in other case.
2004-05-21Merge graceful restart capability display and some small fixes from Zebrahasso
repository by Rivo Nurges.
2004-05-20Merge bgpd changeset 1176 from Zebra repository by Rivo Nurges.hasso
2004-05-012004-05-01 Paul Jakma <paul@dishone.st>paul
* Revert the attempted clean-up of the dummy peer hack, reverts patchsets 435 (see 2004-02-17 below) and 456.
2004-04-202004-04-16 rivo nurges <rix@estpak.ee>paul
* bgpd.h: update cease subcodes to draft-ietf-idr-cease-subcode-05 * bgpd.h, bgpd.c, bgp_route.c, bgp_route.h: fix UNH IOL BGP-4.1.6a
2004-02-172004-02-17 Paul Jakma <paul@dishone.st>paul
* bgpd.h: (bgp_peer) add fd_local and fd_accept file descriptor's, fd becomes a pointer to one of these. * bgpd.c: (global) adjust for fact that fd is now a pointer. (peer_create_accept) removed. * bgp_route.c: (global) adjust for change of peer fd to pointer * bgp_packet.c: (bgp_collision_detect) adjust and remove the "replace with other peer" hack. * bgp_network.c: (bgp_accept) Remove the dummy peer hack. Update peer->fd_accept instead. (global) Adjust fd references - now a pointer. * bgp_fsm.c: (global) adjust peer fd to pointer. (bgp_connection_stop) new function, to stop connection. (global) adjust everything which closed peer fd to use bgp_connection_stop().
2003-08-132003-08-13 kunihiro <kunihiro@zebra.org>paul
* bgpd/bgp{_fsm.c,_vty.c,d.c,d.h}: Add support for "bgp log-neighbor-changes" command.
2002-12-13Initial revisionpaul