aboutsummaryrefslogtreecommitdiffstats
path: root/lib
Commit message (Collapse)AuthorAgeFilesLines
* Lib: Allow use of 240.0.0.0/4 as a private rangeOndrej Zajicek (work)2022-03-161-10/+14
| | | | | | | | There were several requests to allow use of 240.0.0.0/4 as a private range, and Linux kernel already allows such routes, so perhaps we can allow that too. Thanks to Vincent Bernat and others for suggestion and patches.
* Lib: Update alignment of slabsOndrej Zajicek (work)2022-02-071-2/+2
| | | | | | Alignment of slabs should be at least sizeof(ptr) to avoid unaligned pointers in slab structures. Fixme: Use proper way to choose alignment for internal allocators.
* Merge branch 'oz-trie-table'Ondrej Zajicek (work)2022-02-064-2/+103
|\
| * Nest: Attach prefix trie to rtable for faster LPM and interval queriesOndrej Zajicek (work)2022-02-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | Attach a prefix trie to IP/VPN/ROA tables. Use it for net_route() and net_roa_check(). This leads to 3-5x speedups for IPv4 and 5-10x speedup for IPv6 of these calls. TODO: - Rebuild the trie during rt_prune_table() - Better way to avoid trie_add_prefix() in net_get() for existing tables - Make it configurable (?)
| * Trie: Simplify network matching codeOndrej Zajicek (work)2021-11-132-0/+84
| | | | | | | | Introduce ipX_prefix_equal() and use it to simplify network matching code.
| * Filter: Faster prefix setsOndrej Zajicek (work)2021-09-252-2/+18
| | | | | | | | | | | | | | | | | | Use 16-way (4bit) branching in prefix trie instead of basic binary branching. The change makes IPv4 prefix sets almost 3x faster, but with more memory consumption and much more complicated algorithm. Together with a previous filter change, it makes IPv4 prefix sets about ~4.3x faster and slightly smaller (on my test data).
* | IO: Support nonlocal bind in socket interfaceAlexander Zubkov2022-01-081-0/+1
| | | | | | | | | | | | | | | | | | Add option to socket interface for nonlocal binding, i.e. binding to an IP address that is not present on interfaces. This behaviour is enabled when SKF_FREEBIND socket flag is set. For Linux systems, it is implemented by IP_FREEBIND socket flag. Minor changes done by commiter.
* | Memory statistics split into Effective and OverheadMaria Matejka2021-11-274-24/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature is intended mostly for checking that BIRD's allocation strategies don't consume much memory space. There are some cases where withdrawing routes in a specific order lead to memory fragmentation and this output should give the user at least a notion of how much memory is actually used for data storage and how much memory is "just allocated" or used for overhead. Also raising the "system allocator overhead estimation" from 8 to 16 bytes; it is probably even more. I've found 16 as a local minimum in best scenarios among reachable machines. I couldn't find any reasonable method to estimate this value when BIRD starts up. This commit also fixes the inaccurate computation of memory overhead for slabs where the "system allocater overhead estimation" was improperly added to the size of mmap-ed memory.
* | Directly mapped pages are kept for future use if temporarily not neededMaria Matejka2021-11-241-0/+1
|/
* Lib: Fix static assert macroOndrej Zajicek (work)2021-06-061-1/+2
|
* Nest: Allow MAC algorithms to specify min/max key lengthToke Høiland-Jørgensen2021-06-062-1/+3
| | | | | Add min/max key length fields to the MAC algorithm description and validate configured keys before they are used.
* Nest: Allow specifying security keys as hex bytes as well as stringsToke Høiland-Jørgensen2021-06-062-0/+28
| | | | | | | Add support for specifying a password in hexadecimal format, The result is the same whether a password is specified as a quoted string or a hex-encoded byte string, this just makes it more convenient to input high-entropy byte strings as MAC keys.
* Lib: Add tests for blake2s and blake2bToke Høiland-Jørgensen2021-06-062-0/+4221
| | | | | | | | | | Import the blake2-kat.h header with test vector output from the blake reference implementation, and add tests to mac_test.c to compare the output of the Bird MAC algorithm implementations with that reference output. Since the reference implementation only has test vectors for the full output size, there are no tests for the smaller-sized output variants.
* Lib: Add Blake2s and Blake2b hash functionsToke Høiland-Jørgensen2021-06-068-6/+969
| | | | | | | | | | | | | | | The Babel MAC authentication RFC recommends implementing Blake2s as one of the supported algorithms. In order to achieve do this, add the blake2b and blake2s hash functions for MAC authentication. The hashing function implementations are the reference implementations from blake2.net. The Blake2 algorithms allow specifying an arbitrary output size, and the Babel MAC spec says to implement Blake2s with 128-bit output. To satisfy this, we add two different variants of each of the algorithms, one using the default size (256 bits for Blake2s, 512 bits for Blake2b), and one using half the default output size. Update to BIRD coding style done by committer.
* sysdep: Add wrapper to get random bytes - updateOndrej Zajicek (work)2021-06-061-2/+1
| | | | Simplify the code and fix an issue with getentropy() return value.
* sysdep: Add wrapper to get random bytesToke Høiland-Jørgensen2021-06-061-0/+3
| | | | | | Add a wrapper function in sysdep to get random bytes, and required checks in configure.ac to select how to do it. The configure script tries, in order, getrandom(), getentropy() and reading from /dev/urandom.
* Babel: Seqno requests are properly decoupled from neighbors when the ↵Maria Matejka2021-05-301-0/+2
| | | | | | | | | underlying interface disappears When an interface disappears, all the neighbors are freed as well. Seqno requests were anyway not decoupled from them, leading to strange segfaults. This fix adds a proper seqno request list inside neighbors to make sure that no pointer to neighbor is kept after free.
* Flowspec: Documentation updateOndrej Zajicek (work)2021-05-181-2/+2
|
* Flowspec: Label field should use numeric operator and not bitmask operatorOndrej Zajicek (work)2021-05-182-3/+3
|
* Flowspec: Do not use comma for bitmask operatorsOndrej Zajicek (work)2021-05-182-12/+3
| | | | | | | | | For numeric operators, comma is used for disjunction in expressions like "10, 20, 30..40". But for bitmask operators, comma is used for conjunction in a way that does not really make much sense. Use always explicit logical operators (&& and ||) to connect bitmask operators. Thanks to Matt Corallo for the bugreport.
* Filter: Add MPLS label route attributeTrisha Biswas2021-05-171-0/+2
| | | | | | | Add support to set or read outgoing MPLS labels using filters. Currently this supports the addition of one label per route for the first next hop. Minor changes by committer.
* Flowspec: Fix values for true/false operatorsOndrej Zajicek (work)2021-05-141-2/+2
| | | | RFC 8955 is pretty clear that 000 is false and 111 is true.
* Flowspec: Add code for conversion of flowspec parts to interval listsOndrej Zajicek (work)2021-05-141-15/+220
| | | | | | Implement function flow_explicate_part() to convert flowspec numeric expressions to a simple list of (disjoint, sorted) intervals. That could be used in filters to build f_tree-based int-sets from them.
* Lib: Fix handling of buffers in timestamp formattingOndrej Zajicek (work)2021-04-121-2/+3
| | | | | | | The code in tm_format_real_time() mixed up two buffers and their sizes, which may cause crash in MRT dumping code. Thanks to Piotr Wydrych for the bugreport.
* Resources: added mb_move() to complement rmove() for memory blocksMaria Matejka2021-03-302-0/+16
|
* Slab: head now uses bitmask for used/free nodes info instead of listsMaria Matejka2021-03-253-67/+66
| | | | | | | | | | | From now, there are no auxiliary pointers stored in the free slab nodes. This led to strange debugging problems if use-after-free happened in slab-allocated structures, especially if the structure's first member is a next pointer. This also reduces the memory needed by 1 pointer per allocated object. OTOH, we now rely on pages being aligned to their size's multiple, which is quite common anyway.
* Rate-limit scheduling of work-eventsOndrej Zajicek (work)2021-03-122-1/+58
| | | | | | | | | | | | | | In general, events are code handling some some condition, which is scheduled when such condition happened and executed independently from I/O loop. Work-events are a subgroup of events that are scheduled repeatedly until some (often significant) work is done (e.g. feeding routes to protocol). All scheduled events are executed during each I/O loop iteration. Separate work-events from regular events to a separate queue and rate limit their execution to a fixed number per I/O loop iteration. That should prevent excess latency when many work-events are scheduled at one time (e.g. simultaneous reload of many BGP sessions).
* Filter: Recursive filter iteration codeOndrej Zajicek (work)2021-02-071-0/+2
| | | | | Add macros for recursive filter iteration that allows to examine all instructions reachable from a filter.
* lib/slab: introduce sl_allocz() function and use it in BabelToke Høiland-Jørgensen2020-11-242-0/+25
| | | | | | | | | | | | | | | | The babel protocol code was initialising objects returned from the slab allocator by assigning to each of the struct members individually, but wasn't touching the NODE member while doing so. This leads to warnings on debug builds since commit: baac7009063d ("List expensive check.") To fix this, introduce an sl_allocz() variant of the slab allocator which will zero out the memory before returning it, and switch all the babel call sites to use this version. The overhead for doing this should be negligible for small objects, and in the case of babel, the largest object being allocated was being zeroed anyway, so we can drop the memset in babel_read_tlv().
* Slab: Init node in slab head to NULLs.Maria Matejka2020-05-011-2/+5
|
* Timer: Adding missing initializer.Maria Matejka2020-05-011-1/+1
|
* Lists: Replaced replace_node() by update_node() which is the only use of ↵Maria Matejka2020-05-013-26/+17
| | | | that function.
* Lists: fix a stupid sanitizer bugMaria Matejka2020-05-011-2/+6
|
* Uninitialized list nodes fixesMaria Matejka2020-05-011-0/+1
|
* List expensive check.Maria Matejka2020-05-011-0/+61
|
* Expensive check declarationMaria Matejka2020-05-011-0/+7
| | | | | Intended to be run at every operation with complex data structures to check their consistency and validity.
* IPv6 address parser: fail on incomplete addressesMaria Matejka2020-05-012-8/+34
|
* Non-null function argument declarationMaria Matejka2020-05-011-0/+1
|
* More assertion categoriesMaria Matejka2020-04-281-1/+5
|
* Not calling memcpy with n=0.Maria Matejka2020-04-281-0/+9
|
* Configuration strings are constant.Maria Matejka2020-04-093-5/+5
| | | | This is merely a const propagation. There was no problem in there.
* Fletcher16 test fixed to work at bigendian architectures.Maria Matejka2020-04-051-10/+21
| | | | To be honest, it was wrong in concept, anyway it accidentally worked.
* Flowspec: Fix testsOndrej Zajicek (work)2020-03-031-4/+2
| | | | Missing dst no longer generates error.
* BGP: Handle flowspec rules without dst partOndrej Zajicek (work)2020-03-032-10/+4
| | | | | | | | | The RFC 5575 does not explicitly reject flowspec rules without dst part, it just requires dst part in validation procedure for feasibility, which we do not implement anyway. Thus flow without dst prefix is syntactically valid, but unfeasible (if feasibilty testing is done). Thanks to Alex D. for the bugreport.
* BGP: Support for MD5SIG together with remote rangeOndrej Zajicek (work)2020-02-271-1/+1
| | | | | | | | When dynamic BGP with remote range is configured, MD5SIG needs to use newer socket option (TCP_MD5SIG_EXT) to specify remote addres range for listening socket. Thanks to Adam Kułagowski for the suggestion.
* Filter: Add support for src/dst accessors for Flowspec and SADROndrej Zajicek (work)2019-12-092-2/+29
|
* Nest: Use bitmaps to keep track of exported routesOndrej Zajicek (work)2019-11-262-0/+8
| | | | | | | Use a hierarchical bitmap in a routing table to assign ids to routes, and then use bitmaps (indexed by route id) in channels to keep track whether routes were exported. This avoids unreliable and inefficient re-evaluation of filters for old routes in order to determine whether they were exported.
* Lib: Basic and hierarchical bitmapsOndrej Zajicek (work)2019-11-265-2/+443
| | | | | | Basic bitmap is obvious. Hierarchical bitmap is structure of several bitmaps, where higher levels are conjunctions of intervals on level below, allowing for efficient lookup of first unset bit.
* BGP: Fix processing of IPv6 FlowspecOndrej Zajicek (work)2019-11-183-34/+111
| | | | | | | | | | | | During NLRI parsing of IPv6 Flowspec, dst prefix was not properly extracted from NLRI, therefore a received flow was stored in a different position in flowspec routing table, and was not reachable by command 'show route <flow>'. Add proper prefix part accessors to flowspec code and use them from BGP NLRI parsing code. Thanks to Alex D. for the bugreport.
* Support for address family constantsOndrej Zajicek (work)2019-11-031-0/+7
| | | | We already had them defined on BGP level, but they are more general.