summaryrefslogtreecommitdiff
path: root/lib/table.c
AgeCommit message (Collapse)Author
2024-11-25lib: Remove route_node_match_ipv[4|6] not being usedDonald Sharp
These functions are not being used. Let's just remove them from our code base. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-10-10Revert "lib: add link-state prefixes"Donald Sharp
This reverts commit c8172af6825ad4b10e68b33b8edc22e6e2dc1524.
2023-10-10Revert "bgpd: store bgp link-state prefixes"Donald Sharp
This reverts commit 39a8d354c11f6f063fa5154f5807e7a0c9b04b46.
2023-09-18bgpd: store bgp link-state prefixesLouis Scalbert
Add the ability to store link-state prefixes in the BGP table. Store a raw copy of the BGP link state NLRI TLVs as received in the packet in 'p.u.prefix_linkstate.ptr'. Signed-off-by: Olivier Dugeon <olivier.dugeon@orange.com> Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-09-18lib: add link-state prefixesLouis Scalbert
Add to the library the link-state type of prefixes. Link-state prefixes contain much more data than the current prefixes and they only make sense for BGP Link-State. Storing all the data in "struct prefix" is not relevant because it would increase the memory usage of all daemons. Instead a pointer to a structure that contains all the information is used. Printing link-state prefixes can be delegated to a hook function. Signed-off-by: Louis Scalbert <louis.scalbert@6wind.com>
2023-08-22bgpd: Convert from struct bgp_node to struct bgp_destYuqing Zhao
This is based on @donaldsharp's work The current code base is the struct bgp_node data structure. The problem with this is that it creates a bunch of extra data per route_node. The table structure generates ‘holder’ nodes that are never going to receive bgp routes, and now the memory of those nodes is allocated as if they are a full bgp_node. After splitting up the bgp_node into bgp_dest and route_node, the memory of ‘holder’ node which does not have any bgp data will be allocated as the route_node, not the bgp_node, and the memory usage is reduced. The memory usage of BGP node will be reduced from 200B to 96B. The total memory usage optimization of this part is ~16.00%. Signed-off-by: Donald Sharp <sharpd@nvidia.com> Signed-off-by: Yuqing Zhao <xiaopanghu99@163.com>
2023-02-09*: auto-convert to SPDX License IDsDavid Lamparter
Done with a combination of regex'ing and banging my head against a wall. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2022-05-11*: Properly use memset() when zeroingDonatas Abraitis
Wrong: memset(&a, 0, sizeof(struct ...)); Good: memset(&a, 0, sizeof(a)); Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
2021-10-22lib: finish fixing spelling in lib filesewlumpkin
Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
2021-07-01*: Replace IPV4_MAX_PREFIXLEN to IPV4_MAX_BITLENDonatas Abraitis
Just drop IPV4_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-07-01*: Replace IPV6_MAX_PREFIXLEN to IPV6_MAX_BITLENDonatas Abraitis
Just drop IPV6_MAX_PREFIXLEN at all, no need keeping both. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2021-03-17*: require semicolon after DEFINE_<typesafe...>David Lamparter
Again, see previous commits. Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17*: require semicolon after DEFINE_MTYPE & coDavid Lamparter
Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
2020-10-23lib, bgpd: convert lttng tracepoints to frrtrace()Quentin Young
- tracepoint() -> frrtrace() - tracelog() -> frrtracelog() - tracepoint_enabled() -> frrtrace_enabled() Also removes copypasta'd #ifdefs for those LTTng macros, those are handled in lib/trace.h Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23lib: move trace.h -> libfrr_trace.hQuentin Young
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-23lib: add tracepoint for route table getQuentin Young
Signed-off-by: Quentin Young <qlyoung@nvidia.com>
2020-10-17*: Create/Use accessor functions for lock countDonald Sharp
Create appropriate accessor functions for the rn->lock data. We should be accessing this data through accessor functions since it is private data to the data structure. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2020-04-08*: Do not cast to the same typeDonatas Abraitis
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2019-06-21lib: use MTYPE_STATICDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-05-21lib/table: remove nonsensical const, add pureDavid Lamparter
Passing the struct route_table *ptr as const doesn't really help; if anything it semantically would imply that the returned route_node is const too since constness should propagate (but it doesn't in C.) The right thing to do here - which actually helps the compiler optimize the code too - is to tag functions with __attribute__((pure)). The compiler does this automatically if it has the function body (and the body of all called functions) available. That should cover most "static inline" functions in headers, as well as functions in the same file. However, this doesn't work (at least without LTO) for extern functions. Hence, add "ext_pure" for this case. (Built-in "extern" to make lines shorter.) Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-21lib/table: remove odd castsDavid Lamparter
Working with a proper struct route_node gets us around a bunch of weird casts here and makes the code slightly more robust. Signed-off-by: David Lamparter <equinox@diac24.net>
2019-05-02lib: Convert table code to use new hash typeDonald Sharp
This converts the new table code to use the new hash type provided by David. The following test is 1 million routes installed and how much memory we are using: Old mem usage: Memory statistics for zebra: System allocator statistics: Total heap allocated: 574 MiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 536 MiB Free small blocks: 33 MiB Free ordinary blocks: 4600 KiB Ordinary blocks: 0 Small blocks: 0 Holding blocks: 0 New Memory usage: Memory statistics for zebra: System allocator statistics: Total heap allocated: 542 MiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 506 MiB Free small blocks: 3374 KiB Free ordinary blocks: 33 MiB Ordinary blocks: 0 Small blocks: 0 Holding blocks: 0 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-05-02Revert "Zebra diet"Lou Berger
2019-05-01lib: Convert table code to use new hash typeDonald Sharp
This converts the new table code to use the new hash type provided by David. The following test is 1 million routes installed and how much memory we are using: Old mem usage: Memory statistics for zebra: System allocator statistics: Total heap allocated: 574 MiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 536 MiB Free small blocks: 33 MiB Free ordinary blocks: 4600 KiB Ordinary blocks: 0 Small blocks: 0 Holding blocks: 0 New Memory usage: Memory statistics for zebra: System allocator statistics: Total heap allocated: 542 MiB Holding block headers: 0 bytes Used small blocks: 0 bytes Used ordinary blocks: 506 MiB Free small blocks: 3374 KiB Free ordinary blocks: 33 MiB Ordinary blocks: 0 Small blocks: 0 Holding blocks: 0 Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-15Merge pull request #3180 from qlyoung/prefixlen-u8-to-u16Renato Westphal
lib: convert prefixlen to 16-bit integer
2018-10-19*: Replace hash_cmp function return value to a boolDonald Sharp
The ->hash_cmp and linked list ->cmp functions were sometimes being used interchangeably and this really is not a good thing. So let's modify the hash_cmp function pointer to return a boolean and convert everything to use the new syntax. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-15lib: convert prefixlen to 16-bit integerQuentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2018-03-30lib: prefix support for flowspecPhilippe Guibert
prefix structure is used to handle flowspec prefixes. A new AFI is introduced: AF_FLOWSPEC. A sub structure named flowspec_prefix is used in prefix to host the flowspec entry. Reason to introduce that new kind is that prefixlen from prefix structure is too short to all the flowspec needs, since NLRI can go over 0xff bytes. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2018-03-27*: use C99 standard fixed-width integer typesQuentin Young
The following types are nonstandard: - u_char - u_short - u_int - u_long - u_int8_t - u_int16_t - u_int32_t Replace them with the C99 standard types: - uint8_t - unsigned short - unsigned int - unsigned long - uint8_t - uint16_t - uint32_t Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-10-16lib: No need to call apply_mask 2 timesDonald Sharp
route_node_set is only called by route_node_get which calls apply_mask. There is no need to do this again. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2017-08-29lib: apply_mask to route_node_getChirag Shah
remove address of prefix while typecasting to apply_mask Singed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-08-28lib: call apply_mask in route_node_getChirag Shah
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2017-08-17lib: inline route_node_lock()/route_node_unlock()Jorge Boncompte
Avoid function calls. Signed-off-by: Jorge Boncompte <jbonor@gmail.com>
2017-08-04Merge pull request #909 from opensourcerouting/isis-perfDonald Sharp
IS-IS: improve spf performance
2017-08-03lib: add missed apply_mask()Quentin Young
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2017-08-03lib: move prefix hash key to prefix.c to allow global useChristian Franke
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
2017-07-19lib: route_node_lookup() needs to apply_mask() to prefixDaniel Walton
Signed-off-by: Daniel Walton <dwalton@cumulusnetworks.com> Reviewed-by: <qlyoung@cumulusnetworks.com>
2017-07-17*: reindentreindent-master-afterwhitespace / reindent
indent.py `git ls-files | pcregrep '\.[ch]$' | pcregrep -v '^(ldpd|babeld|nhrpd)/'` Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11lib: table: use hash for exact-match lookupsDavid Lamparter
Most read accesses of route_table are actually exact matches where walking down the tree is wildly inefficient. Use a parallel hash structure instead. This significantly speeds up processes that are performance-bound by table accesses, e.g. BGP withdraw processing. In other locations, the improvement is not seen as strongly, e.g. when filter processing is the limiting factor. [includes fix to ignore prefix host bits in hash comparison] Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11lib: table: maintain parallel hash for route_tableDavid Lamparter
See next commit for description. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11lib: add some abstraction guards for table codeDavid Lamparter
route_node->parent and route_node->link shouldn't be touched by user code since that is a recipe for trouble once we have a hash table in parallel. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-07-11lib: use "union prefixconstptr" in table codeDavid Lamparter
This allows passing struct prefix_{ipv4,ipv6,evpn} * in addition to struct prefix * without an extra cast (since the union uses the gcc transparent-union extension present in all compilers that we support.) Also applies some "const" while we're at it. Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2017-05-15*: make consistent & update GPLv2 file headersDavid Lamparter
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>
2017-01-30lib: add cleanup hook to route tableChristian Franke
2017-01-30lib: add second-level route_table for srcdestDavid Lamparter
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]
2017-01-30lib: add route_node_lookup_maynullDavid Lamparter
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>
2017-01-13frr: Remove HAVE_IPV6 from code baseDonald Sharp
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2016-11-28zebra/lib: plug several memleaksRenato Westphal
Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2016-09-30lib: add route_table_get_default_delegateLou Berger
2016-09-19*: split & distribute memtypes and stop (re|ab)using lib/ MTYPEsDavid Lamparter
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>