summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-04-20Linpool: Fix lp_restore()Maria Matejka
When lp_save() is called on an empty linpool, then some allocation is done, then lp_restore() is called, the linpool is restored but the used chunks are inaccessible. Fix it.
2023-03-06Net: Replace runtime checks with STATIC_ASSERT()Ondrej Zajicek
2023-03-06Printf test suite fails on systems with musl libc because tests for "%m"Petr Vaněk
and "%M" formats expect "Input/output error" message but musl returns "I/O error". Proposed change compares the printf output with string returned from strerror function for EIO constant. See-also: https://bugs.gentoo.org/836713 Minor change from committer.
2023-02-22Linpool flush drops all the allocated pages but oneMaria Matejka
When a linpool is used to allocate a one-off big load of memory, it makes no sense to keep that amount of memory for future use inside the linpool. Contrary to previous implementations where the memory was directly free()d, we now use the page allocator which has an internal cache which keeps the released pages for us and subsequent allocations simply get these released pages back. And even if the page cleanup routine kicks in inbetween, the pages get only madvise()d, not munmap()ed so performance aspects are negligible. This may fix some memory usage peaks in extreme cases.
2023-01-12Log message before abortingMike Crute
Log message before aborting due to watchdog timeout. We have to use async-safe write to debug log, as it is done in signal handler. Minor changes from committer.
2022-05-30Merge commit '692055e3df6cc9f0d428d3b0dd8cdd8e825eb6f4' into haugesund-to-2.0Maria Matejka
2022-04-06All linpools use pages to allocate regular blocksMaria Matejka
2022-04-06Converted Slab allocator to typed listsMaria Matejka
2022-04-06Slab allocator can free the blocks without knowing the parent structureMaria Matejka
2022-04-06Typed lists for easier walking and stronger type checkingMaria Matejka
2022-03-16Lib: Allow use of 240.0.0.0/4 as a private rangeOndrej Zajicek (work)
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.
2022-03-15Printf variant with a result allocated inside a pool / linpoolMaria Matejka
2022-03-14Slab memory allocator unit testMaria Matejka
2022-03-09Merge commit '5cff1d5f' into haugesundMaria Matejka
Conflicts: proto/bgp/attrs.c proto/pipe/pipe.c
2022-03-09Fixed resource initialization in unit testsMaria Matejka
2022-03-09Linpools with pages fixed to the final page allocator versionMaria Matejka
2022-03-09Merge commit '0c59f7ff' into haugesundMaria Matejka
2022-03-09Revert "Bound allocated pages to resource pools with page caches to avoid ↵Maria Matejka
unnecessary syscalls" This reverts commit 7f0e59820899c30a243c18556ce2e3fb72d6d221.
2022-03-09Revert "fixup! Bound allocated pages to resource pools with page caches to ↵Maria Matejka
avoid unnecessary syscalls" This reverts commit bea582cbb53e30dd32a5b6829c7443e0e5558d11.
2022-03-09Revert "Multipage allocation"Maria Matejka
This reverts commit 6cd37713781a3092f8166b2178fae35cbfec1e28.
2022-03-09Single-threaded version of sark-branch memory page managementMaria Matejka
2022-03-02Replaced custom linpools in tests for the common tmp_linpoolMaria Matejka
2022-03-02Introducing an universal temporary linpool flushed after every taskMaria Matejka
2022-03-02Static list initializerMaria Matejka
2022-03-02Merge commit '2c13759136951ef0e70a3e3c2b2d3c9a387f7ed9' into haugesundMaria Matejka
2022-02-07Lib: Update alignment of slabsOndrej Zajicek (work)
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.
2022-02-06Merge branch 'oz-trie-table'Ondrej Zajicek (work)
2022-02-06Nest: Attach prefix trie to rtable for faster LPM and interval queriesOndrej Zajicek (work)
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 (?)
2022-01-08IO: Support nonlocal bind in socket interfaceAlexander Zubkov
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.
2021-11-27Memory statistics split into Effective and OverheadMaria Matejka
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.
2021-11-24Directly mapped pages are kept for future use if temporarily not neededMaria Matejka
2021-11-13Trie: Simplify network matching codeOndrej Zajicek (work)
Introduce ipX_prefix_equal() and use it to simplify network matching code.
2021-10-13Preference moved to RTA and set explicitly in protocolsMaria Matejka
2021-10-13Multipage allocationMaria Matejka
We can also quite simply allocate bigger blocks. Anyway, we need these blocks to be aligned to their size which needs one mmap() two times bigger and then two munmap()s returning the unaligned parts. The user can specify -B <N> on startup when <N> is the exponent of 2, setting the block size to 2^N. On most systems, N is 12, anyway if you know that your configuration is going to eat gigabytes of RAM, you are almost forced to raise your block size as you may easily get into memory fragmentation issues or you have to raise your maximum mapping count, e.g. "sysctl vm.max_map_count=(number)".
2021-10-13Linpools may use pages instead of xmallocMaria Matejka
2021-10-13fixup! Bound allocated pages to resource pools with page caches to avoid ↵Maria Matejka
unnecessary syscalls
2021-09-25Filter: Faster prefix setsOndrej Zajicek (work)
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).
2021-09-10Bound allocated pages to resource pools with page caches to avoid ↵Maria Matejka
unnecessary syscalls
2021-09-10Fixed memory poisoning in slabMaria Matejka
2021-06-06Lib: Fix static assert macroOndrej Zajicek (work)
2021-06-06Nest: Allow MAC algorithms to specify min/max key lengthToke Høiland-Jørgensen
Add min/max key length fields to the MAC algorithm description and validate configured keys before they are used.
2021-06-06Nest: Allow specifying security keys as hex bytes as well as stringsToke Høiland-Jørgensen
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.
2021-06-06Lib: Add tests for blake2s and blake2bToke Høiland-Jørgensen
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.
2021-06-06Lib: Add Blake2s and Blake2b hash functionsToke Høiland-Jørgensen
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.
2021-06-06sysdep: Add wrapper to get random bytes - updateOndrej Zajicek (work)
Simplify the code and fix an issue with getentropy() return value.
2021-06-06sysdep: Add wrapper to get random bytesToke Høiland-Jørgensen
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.
2021-05-30Babel: Seqno requests are properly decoupled from neighbors when the ↵Maria Matejka
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.
2021-05-18Flowspec: Documentation updateOndrej Zajicek (work)
2021-05-18Flowspec: Label field should use numeric operator and not bitmask operatorOndrej Zajicek (work)
2021-05-18Flowspec: Do not use comma for bitmask operatorsOndrej Zajicek (work)
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.