summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2023-04-14Merge commit '231c6385' into thread-next-ifaceMaria Matejka
2023-04-14Merge commit '6c058ae4' into thread-next-ifaceMaria Matejka
2023-04-06Loop: keep running the same loop for some time if there is work to doMaria Matejka
2023-04-04Sockets: Unified API for main and other loopsMaria Matejka
Now sk_open() requires an explicit IO loop to open the socket in. Also specific functions for socket RX pause / resume are added to allow for BGP corking. And last but not least, socket reloop is now synchronous to resolve weird cases of the target loop stopping before actually picking up the relooped socket. Now the caller must ensure that both loops are locked while relooping, and this way all sockets always have their respective loop.
2023-04-04More efficient IO loop event execution to avoid long loopsMaria Matejka
If there are lots of loops in a single thread and only some of the loops are actually active, the other loops are now kept aside and not checked until they actually get some timers, events or active sockets. This should help with extreme loads like 100k tables and protocols. Also ping and loop pickup mechanism was allowing subtle race conditions. Now properly handling collisions between loop ping and pickup.
2023-04-04Resource dumps also write out block addressesMaria Matejka
2023-04-04Linpool: State restoration works in initial linpool stateMaria Matejka
2023-04-04Propagated const through route feed routinesMaria Matejka
2023-04-04Fixed bad filter re-evaluation with import table if filtered->acceptedMaria Matejka
The import table feed wasn't resetting the table-specific route values like REF_FILTERED and thus made the route look like filtered even though it should have been re-evaluated as accepted.
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-02-07Protocol shutdown/restart from limits is respecting the loopsMaria Matejka
2023-02-07Merge commit '0bb04d5390f21b0c96fc4894ba5d5510c541f0ef' into HEADMaria Matejka
2023-02-02Macro: stringifyMaria Matejka
2023-02-02Lists: fixed bugs in expensive checks in quirky usecasesMaria Matejka
2023-02-02Typed lists: shortcut for simple nodesMaria Matejka
2023-01-23Merge commit '7fb23041a52d01754c53ba963e2282e524813364' into thread-nextMaria Matejka
2023-01-20Fixed various build problems on FreeBSD and/or CLangMaria Matejka
2023-01-19Decoupling loops from threads to allow fixed thread countMaria Matejka
On large configurations, too many threads would spawn with one thread per loop. Therefore, threads may now run multiple loops at once. The thread count is configurable and may be changed during run. All threads are spawned on startup. This change helps with memory bloating. BIRD filters need large temporary memory blocks to store their stack and also memory management keeps its hot page storage per-thread. Known bugs: * Thread autobalancing is not yet implemented. * Low latency loops are executed together with standard loops.
2023-01-19Removed config reparsing from unrelated testsMaria Matejka
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-11-07Merge commit '8478de88' into thread-nextMaria Matejka
2022-10-12Attribute blocks are now allocated from slabs instead of malloc()Maria Matejka
2022-10-12Tamed slab signedness warning on 32-bit architecturesMaria Matejka
2022-09-21Local page allocationMaria Matejka
2022-09-18Fixing several race-conditions in event code.Maria Matejka
After a suggestion by Santiago, I added the direct list pointer into events and the events are now using this value to check whether the route is active or not. Also the whole trick with sentinel node unioned with event list is now gone. For debugging, there is also an internal circular buffer to store what has been recently happening in event code before e.g. a crash happened. By default, this debug is off and must be manually enabled in lib/event.c as it eats quite some time and space.
2022-09-18Loop flags: a simple idempotent event announcement mechanismMaria Matejka
2022-09-18Routing tables have their own service loops.Maria Matejka
2022-09-18Memory pages allocator is now a global simple lockless structureMaria Matejka
2022-09-09Created a dedicated settle timer structureMaria Matejka
2022-09-08Table access is now locked.Maria Matejka
2022-08-03Merge commit '038fcf1c' into thread-nextMaria Matejka
It was necessary to update the code to match removal of rta, as well as existence of cached nested attribute lists.
2022-08-03Merge commit '97476e00' into thread-nextMaria Matejka
Had to fix route source locking inside BGP export table as we need to keep the route sources properly allocated until even last BGP pending update is sent out, therefore the export table printout is accurate.
2022-08-02Merge commit 'f0507f05ce57398e135651896dace4cb68eeed54' into thread-nextMaria Matejka
2022-08-02Introducing basic RCU primitives for lock-less shared data structuresMaria Matejka
2022-08-01Fixed main birdloop init in unit testsMaria Matejka
Some unit tests weren't initializing the birdloop, trying to write the birdloop ping into stdin. Fixed this and also forced stdin close on startup of every test just to be sure that CI and local build behave the same in this. (CI was failing on this while local build not.)
2022-07-28Sending an event must also ping the target IO loopMaria Matejka
2022-07-28Moved the thread starting code to IO loop codeMaria Matejka
2022-07-18Event lists rewritten to a single linked listMaria Matejka
In multithreaded environment, we need to pass messages between workers. This is done by queuing events to their respective queues. The double-linked list is not really useful for that as it needs locking everywhere. This commit rewrites the event subsystem to use a single-linked list where events are enqueued by a single atomic instruction and the queue is processed after atomically moving the whole queue aside.
2022-07-18Merge commit '94eb0858' into thread-nextMaria Matejka
2022-07-18Merge commit 'a4451535' into thread-nextMaria Matejka
2022-07-18Fixed an annoying warning in ea_get_storage()Maria Matejka
2022-07-18Merge commit 'a845651b' into thread-nextMaria Matejka
2022-07-15Merge commit 'c70b3198' into thread-next [lots of conflicts]Maria Matejka
There were more conflicts that I'd like to see, most notably in route export. If a bisect identifies this commit with something related, it may be simply true that this commit introduces that bug. Let's hope it doesn't happen.
2022-07-13Merge commit '2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f' into thread-nextMaria Matejka
2022-07-12Removing the rte_modify APIMaria Matejka
For BGP LLGR purposes, there was an API allowing a protocol to directly modify their stale routes in table before flushing them. This API was called by the table prune routine which violates the future locking requirements. Instead of this, BGP now requests a special route export and reimports these routes into the table, allowing for asynchronous execution without locking the table on export.
2022-07-12Route refresh in tables uses a stale counter.Maria Matejka
Until now, we were marking routes as REF_STALE and REF_DISCARD to cleanup old routes after route refresh. This needed a synchronous route table walk at both beginning and the end of route refresh routine, marking the routes by the flags. We avoid these walks by using a stale counter. Every route contains: u8 stale_cycle; Every import hook contains: u8 stale_set; u8 stale_valid; u8 stale_pruned; u8 stale_pruning; In base_state, stale_set == stale_valid == stale_pruned == stale_pruning and all routes' stale_cycle also have the same value. The route refresh looks like follows: + ----------- + --------- + ----------- + ------------- + ------------ + | | stale_set | stale_valid | stale_pruning | stale_pruned | | Base | x | x | x | x | | Begin | x+1 | x | x | x | ... now routes are being inserted with stale_cycle == (x+1) | End | x+1 | x+1 | x | x | ... now table pruning routine is scheduled | Prune begin | x+1 | x+1 | x+1 | x | ... now routes with stale_cycle not between stale_set and stale_valid are deleted | Prune end | x+1 | x+1 | x+1 | x+1 | + ----------- + --------- + ----------- + ------------- + ------------ + The pruning routine is asynchronous and may have high latency in high-load environments. Therefore, multiple route refresh requests may happen before the pruning routine starts, leading to this situation: | Prune begin | x+k | x+k | x -> x+k | x | ... or even | Prune begin | x+k+1 | x+k | x -> x+k | x | ... if the prune event starts while another route refresh is running. In such a case, the pruning routine still deletes routes not fitting between stale_set and and stale_valid, effectively pruning the remnants of all unpruned route refreshes from before: | Prune end | x+k | x+k | x+k | x+k | In extremely rare cases, there may happen too many route refreshes before any route prune routine finishes. If the difference between stale_valid and stale_pruned becomes more than 128 when requesting for another route refresh, the routine walks the table synchronously and resets all the stale values to a base state, while logging a warning.
2022-07-11Export tables merged with BGP prefix hashMaria Matejka
Until now, if export table was enabled, Nest was storing exactly the route before rt_notify() was called on it. This was quite sloppy and spooky and it also wasn't reflecting the changes BGP does before sending. And as BGP is storing the routes to be sent anyway, we are simply keeping the already-sent routes in there to better rule out unneeded reexports. Some of the route attributes (IGP metric, preference) make no sense in BGP, therefore these will be probably replaced by something sensible. Also the nexthop shown in the short output is the BGP nexthop.
2022-07-11Hash: iterable now per partes by an iteratorMaria Matejka
It's now possible to pause iteration through hash. This requires struct hash_iterator to be allocated somewhere handy. The iteration itself is surrounded by HASH_WALK_ITER and HASH_WALK_ITER_END. Call HASH_WALK_ITER_PUT to ask for pausing; it may still do some more iterations until it comes to a suitable pausing point. The iterator must be initalized to an empty structure. No cleanup is needed if iteration is abandoned inbetween.