summaryrefslogtreecommitdiffstats
path: root/lib/table.h (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: make consistent & update GPLv2 file headersDavid Lamparter2017-05-151-4/+3
| | | | | | | | | | | The FSF's address changed, and we had a mixture of comment styles for the GPL file header. (The style with * at the beginning won out with 580 to 141 in existing files.) Note: I've intentionally left intact other "variations" of the copyright header, e.g. whether it says "Zebra", "Quagga", "FRR", or nothing. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: add cleanup hook to route tableChristian Franke2017-01-301-0/+1
|
* lib: add second-level route_table for srcdestDavid Lamparter2017-01-301-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | IPv6 srcdest routes need to be keyed by both destination and source prefix. Since the lookup order is destination first, the simplest thing to do here is to add a second route_table to destination entries, which then contain source entries. Sadly, the result is somewhat confusing since a route_node might now be either a source node or a destination node. There are helper functions to get source and destination prefix from a given route node (which can be either a destination or a source route). The following bits have been added by Christian Franke <chris@opensourcerouting.org>: - make srcdest routing table reusable by moving it into lib - make the srcdest routing table structure more opaque - implement a srcdest routing table iterator - fix a refcounting issue in src_node_lookup - match route_node_lookup behavior with srcdest_rnode_lookup - add accessor for the route_node table and table_info - add string formatter srcdest_rnode2str Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org> [v3: adapted for cmaster-next as of 2016-12-05]
* lib: add route_node_lookup_maynullDavid Lamparter2017-01-301-0/+2
| | | | | | | | The sourcedest code needs to get the route_node even if its info pointer is NULL (which occurs when there are srcdest routes, but no general destination route.) Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* frr: Remove HAVE_IPV6 from code baseDonald Sharp2017-01-131-2/+0
| | | | Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* zebra/lib: plug several memleaksRenato Westphal2016-11-281-0/+5
| | | | Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* lib: add route_table_get_default_delegateLou Berger2016-09-301-0/+3
|
* *: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter2016-09-191-0/+3
| | | | | | | | | | | | | | | | | | | This is a rather large mechanical commit that splits up the memory types defined in lib/memtypes.c and distributes them into *_memory.[ch] files in the individual daemons. The zebra change is slightly annoying because there is no nice place to put the #include "zebra_memory.h" statement. bgpd, ospf6d, isisd and some tests were reusing MTYPEs defined in the library for its own use. This is bad practice and would break when the memtype are made static. Acked-by: Vincent JARDIN <vincent.jardin@6wind.com> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com> [CF: rebased for cmaster-next] Signed-off-by: David Lamparter <equinox@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org>
* route table: constify some APIsTimo Teräs2016-05-261-2/+2
| | | | | | Signed-off-by: Timo Teräs <timo.teras@iki.fi> Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit 3293bc280f15d8e3c04e0bf9b0a8d54d342a87a9)
* *: remove stray extra semicolonsDavid Lamparter2016-05-261-1/+1
| | | | | | | Some places had extra semicolons where none belong. Remove them. Signed-off-by: David Lamparter <equinox@opensourcerouting.org> (cherry picked from commit b7d5021bfa161f797cbfb1e92bf5b94327fb1b71)
* lib/table: add route_table_get_next() and iteratorAvneesh Sachdev2012-09-261-0/+126
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/table.[ch] - Add a function (route_table_get_next()) to get the route_node in a tree that succeeds a given prefix in iteration order. This allows one to reliably walk nodes in a tree while allowing modifications, and is useful for achieving scale and performance. Other approaches are also possible -- the main plus point of this one is that it does not require any state about the walk to be maintained in the table data structures. - Add an iterator for walking the nodes in a tree. This introduces a new structure (route_table_iter_t) and the following main functions. route_table_iter_init() route_table_iter_pause() route_table_iter_next() route_table_iter_cleanup() The iterator normally uses node pointers and the existing route_next() function to walk nodes efficiently. When an iteration is 'paused' with route_table_iter_pause(), it stores the last prefix processed. The next call to route_table_iter_next() transparently invokes route_table_get_next() with the prefix to resume iteration. * bgpd/bgp_table.[ch] Add wrappers for the new table features described above. * tests/table_test.c Add tests for the new table code. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: prepare table code for reuse by bgp_tableAvneesh Sachdev2012-09-261-15/+63
| | | | | | | | | | | | | | | | | | | | | | | | | | | | * lib/table.[ch] - Add a macro (ROUTE_NODE_FIELDS) that expands to all the fields of a route_node structure. - Add the route_table_delegate_t structure, a function vector which allows clients to customize the behavior of one or more tables. The delegate currently contains the 'create_node' and 'destroy_node' functions, and hence enables a table to use an alternative node structure. The alternative node is expected to embed the fields of a route_node using ROUTE_NODE_FIELDS. - Add route_table_init_with_delegate() to create a new table with a given delegate. - Make route_table_init() a thin wrapper around route_table_init_with_delegate(). The delegate it passes in simply creates/destroys route_node structures as before. - Add a user data pointer (info) to the route_table structure. This can be used by a client to keep per-table state. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: bring some changes over from bgp_table to tableAvneesh Sachdev2012-09-261-3/+5
| | | | | | | | | | | | | | | | | | * lib/table.c - Maintain table node count. Expose it via the route_table_count() function (from revision cbdfbaa5). - route_unlock_node(): Add assertion (from revision 228da428). - route_table_free(): Make static and fix up cleanup code (from revision 228da428). - route_node_delete(): Change to be static. - Add 'const' qualifier in a couple places. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
* lib: make match functions take const argsStephen Hemminger2009-12-081-6/+6
| | | | | | | | | * table.c: general type safety and compiler help: * maskbit[]: become const * route_node_match(): take const args * route_node_match_ipv4(): idem * route_node_match_ipv6(): idem * check_bit(): idem, plus adjust local vars typing
* 2005-05-06 Paul Jakma <paul@dishone.st>paul2005-05-061-13/+17
| | | | | | | | | | | | | | | | | | | | | | | | | | * (general) extern and static'ification of functions in code and header. Cleanup any definitions with unspecified arguments. Add casts for callback assignments where the callback is defined, typically, as passing void *, but the function being assigned has some other pointer type defined as its argument, as gcc complains about casts from void * to X* via function arguments. Fix some old K&R style function argument definitions. Add noreturn gcc attribute to some functions, as appropriate. Add unused gcc attribute to some functions (eg ones meant to help while debugging) Add guard defines to headers which were missing them. * command.c: (install_node) add const qualifier, still doesnt shut up the warning though, because of the double pointer. (cmp_node) ditto * keychain.c: (key_str2time) Add GET_LONG_RANGE() macro, derived fromn vty.h ones to fix some of the (long) < 0 warnings. * thread.c: (various) use thread_empty (cpu_record_hash_key) should cast to uintptr_t, a stdint.h type * vty.h: Add VTY_GET_IPV4_ADDRESS and VTY_GET_IPV4_PREFIX so they removed from ospfd/ospf_vty.h * zebra.h: Move definition of ZEBRA_PORT to here, to remove dependence of lib on zebra/zserv.h
* Initial revisionpaul2002-12-131-0/+74