summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-12-21Bytestring: implement bytestring literals and constantsMikael Magnusson
Implement byte string literals on the format b"xxx" and b64"xxx" which can be used as literals and in constants. The format b"xxx" supports character data and octal and hexadecimal data using C escapes (\n, \nn, \nnn, \xn and \xnn). The format b64"xxx" supports base64 encoded strings (RFC1341).
2023-12-21Unix: Implement sk_connect_unixMikael Magnusson
Support abstract socket in sk_unix_connect Implement SK_UNIX_ACTIVE
2023-12-13Log: Add support for UDP loggingOndrej Zajicek
Add support for UDP logging, using RFC 3164 syslog protocol. Based on the patch from Alexander Zubkov <green@qrator.net>, thanks!
2023-10-06Conf: Bytestrings with hex: should use the same general format as ones without.Ondrej Zajicek
Either hex:01234567, or hex:01:23:45:67. No confusing formats like hex:0123:4567:ab:cdef, which looks like there is an implicit zero byte.
2023-10-04Lib: Extend MPLS label allocator bitmapOndrej Zajicek
Add function lmap_last_one_in_range() for finding the last active label in a label range.
2023-10-04MPLS subsystemOndrej Zajicek
The MPLS subsystem manages MPLS labels and handles their allocation to MPLS-aware routing protocols. These labels are then attached to IP or VPN routes representing label switched paths -- LSPs. There was already a preliminary MPLS support consisting of MPLS label net_addr, MPLS routing tables with static MPLS routes, remote labels in next hops, and kernel protocol support. This patch adds the MPLS domain as a basic structure representing local label space with dynamic label allocator and configurable label ranges. To represent LSPs, allocated local labels can be attached as route attributes to IP or VPN routes with local labels as attributes. There are several steps for handling LSP routes in routing protocols -- deciding to which forwarding equivalence class (FEC) the LSP route belongs, allocating labels for new FECs, announcing MPLS routes for new FECs, attaching labels to LSP routes. The FEC map structure implements basic code for managing FECs in routing protocols, therefore existing protocols can be made MPLS-aware by adding FEC map and delegating most work related to local label management to it.
2023-10-04Lib: Indirect bitmap for MPLS label allocatorOndrej Zajicek (work)
2023-09-26Aggregator: Fixed hashing of adataMaria Matejka
2023-08-24Lib: Add functions for reading and writing of bytestringsOndrej Zajicek
Based on patch from Alexander Zubkov, thanks!
2023-06-02IO: Add current_time_now() function for immediate timestampToke Høiland-Jørgensen
Add a current_time_now() function which gets an immediate monotonic timestamp instead of using the cached value from the event loop. This is useful for callers that need precise times, such as the Babel RTT measurement code. Minor changes by committer.
2023-05-18Lib: Improve IP/net hashingOndrej Zajicek
Backport some changes from branch oz-parametric-hashes. Replace naive hash function for IPv6 addresses, fix hashing of VPNx (where upper half of RD was ignored), fix hashing of MPLS labels (where identity was used).
2023-04-27Conf: Fix symbol lookupOndrej Zajicek
The symbol table used just symbol name as a key, and used a trick with active flag to find symbols in active scopes with one hash table lookup. The disadvantage is that it can degenerate to O(n) for negative queries in situations where are many symbols with the same name in different scopes. Thanks to Yanko Kaneti for the bugreport.
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