0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-09-20 12:25:20 +00:00
Commit Graph

3849 Commits

Author SHA1 Message Date
Maria Matejka
5f94d684d0 Table prune routines request export announcements directly 2021-12-01 16:21:35 +00:00
Maria Matejka
7092bdc0c9 fixed duplicate routes propagation 2021-12-01 14:02:23 +01:00
Maria Matejka
b50224a003 Merge branch 'master' into HEAD 2021-12-01 13:04:52 +01:00
Maria Matejka
55ee9961e0 Fix of shutdown: premature log cleanup led to use-after-free 2021-12-01 13:00:54 +01:00
Maria Matejka
bb63e99d78 Page allocator moved from pools to IO loops.
The resource pool system is highly hierarchical and keeping spare pages
in pools leads to unnecessarily complex memory management.

Loops have a flat hiearchy, at least for now, and it is therefore much
easier to keep care of pages, especially in cases of excessive virtual memory
fragmentation.
2021-12-01 13:00:54 +01:00
Maria Matejka
385b3ea395 For safer memory allocations, resources are bound to loops.
Also all loops have their basic resource pool for allocations which are
auto-freed when the loop is stopping.
2021-11-30 21:38:25 +01:00
Maria Matejka
f772afc525 Memory statistics split into Effective and Overhead
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-27 22:54:15 +01:00
Maria Matejka
ab0994a10c fixup of table reload bug 2021-11-24 23:20:26 +01:00
Maria Matejka
644e9ca94e Directly mapped pages are kept for future use if temporarily not needed 2021-11-24 19:42:52 +00:00
Maria Matejka
57d0ecb9b7 GDB pretty printer for resource pools 2021-11-24 15:48:13 +00:00
Maria Matejka
5395880908 Fixed pipe reload/refeed 2021-11-23 12:06:27 +00:00
Maria Matejka
821344c781 Stored pages release routine 2021-11-23 11:13:11 +00:00
Maria Matejka
4ba991f19c Fixed channel export map confusion 2021-11-23 11:12:32 +00:00
Maria Matejka
44dbedbe3f BGP: End route refresh before another starts 2021-11-22 19:05:44 +01:00
Maria Matejka
3fd1f46184 RPKI has its own loop 2021-11-22 19:05:44 +01:00
Maria Matejka
20ace7f2e6 RPKI: Use the route refresh mechanism also for the first load 2021-11-22 19:05:44 +01:00
Maria Matejka
1e8e3b7c12 More information on RPKI errors 2021-11-22 19:05:44 +01:00
Maria Matejka
aadf690b14 Higher settle times when route refresh in the source table is running 2021-11-22 19:05:44 +01:00
Maria Matejka
df476c2e5d Corking also feed start to keep BIRD running when refeeds would easily cause congestion 2021-11-22 19:05:44 +01:00
Maria Matejka
0fd1c1d091 Route attribute cache is now lockless on read / clone.
Lots of time was spent locking when accessing route attribute cache.
This overhead should be now reduced to a minimum.
2021-11-22 19:05:44 +01:00
Maria Matejka
2a224a9e1e Route sources have their separate global lock 2021-11-22 19:05:44 +01:00
Maria Matejka
1b39473993 Introducing basic RCU primitives for lock-less shared data structures 2021-11-22 19:05:44 +01:00
Maria Matejka
adf37d8eff VRF setting reduced to one argument, using default dummy iface for default vrf 2021-11-22 19:05:44 +01:00
Maria Matejka
dc160e11e1 Route table import-to-export announcement indirection to reduce pipe traffic 2021-11-22 19:05:44 +01:00
Maria Matejka
794a4eefa1 Keeping un-unmmappable pages until they can be reused
On Linux, munmap() may fail with ENOMEM when virtual memory is too
fragmented. Working this around by just keeping such blocks for future
use.
2021-11-22 19:05:44 +01:00
Maria Matejka
4f3fa1623f Pipe runs in parallel. 2021-11-22 19:05:44 +01:00
Maria Matejka
878eeec12b Routing tables now have their own loops.
This basically means that:
* there are some more levels of indirection and asynchronicity, mostly
  in cleanup procedures, requiring correct lock ordering
* all the internal table operations (prune, next hop update) are done
  without blocking the other parts of BIRD
* the protocols may get their own loops very soon
2021-11-22 19:05:44 +01:00
Maria Matejka
c7d0c5b252 Route subscription uses events 2021-11-22 19:05:44 +01:00
Maria Matejka
18f66055e3 Global table update pool removed 2021-11-22 19:05:44 +01:00
Maria Matejka
038fcf1c8b Locking route attributes cache
To access route attribute cache from multiple threads at once, we have
to lock the cache on writing. The route attributes data structures are
safe to read unless somebody tries to tamper with the cache itself.
2021-11-22 19:05:44 +01:00
Maria Matejka
f0507f05ce Route sources have an explicit owner
This commit prevents use-after-free of routes belonging to protocols
which have been already destroyed, delaying also all the protocols'
shutdown until all of their routes have been finally propagated through
all the pipes down to the appropriate exports.

The use-after-free was somehow hypothetic yet theoretically possible in
rare conditions, when one BGP protocol authors a lot of routes and the
user deletes that protocol by reconfiguring in the same time as next hop
update is requested, causing rte_better() to be called on a
not-yet-pruned network prefix while the owner protocol has been already
freed.

In parallel execution environments, this would happen an inter-thread
use-after-free, causing possible heisenbugs or other nasty problems.
2021-11-22 19:05:44 +01:00
Maria Matejka
3b20722a1f Table cork: Stop creating updates when there are too many pending.
The corked procedure gets a callback when uncorked. Supported by table
maintenance routines and also BGP.
2021-11-22 19:05:43 +01:00
Maria Matejka
445eeaf3df Split route table event into separate events
The former rt_event is dropped in favour of separate table events.
This allows for selective corking of NHU and prune.
2021-11-22 19:05:43 +01:00
Maria Matejka
6e841b3153 Adding a generic cork mechanism for events 2021-11-22 19:05:43 +01:00
Maria Matejka
94eb0858c2 Converting the former BFD loop to a universal IO loop and protocol loop.
There is a simple universal IO loop, taking care of events, timers and
sockets. Primarily, one instance of a protocol should use exactly one IO
loop to do all its work, as is now done in BFD.

Contrary to previous versions, the loop is now launched and cleaned by
the nest/proto.c code, allowing for a protocol to just request its own
loop by setting the loop's lock order in config higher than the_bird.

It is not supported nor checked if any protocol changed the requested
lock order in reconfigure. No protocol should do it at all.
2021-11-22 19:05:43 +01:00
Maria Matejka
c84ed60371 Moved BFD IO loop out of BFD as we want to use it as socket-io coroutine 2021-11-22 19:05:43 +01:00
Maria Matejka
a4451535c6 Unified time for whole BIRD
In previous versions, every thread used its own time structures,
effectively leading to different time in every thread and strange
logging messages.

The time processing code now uses global atomic variables to keep
current time available for fast concurrent reading and safe updates.
2021-11-22 19:05:43 +01:00
Maria Matejka
a2af807357 Debug messages with timestamps.
On most of current hardware, getting monotonic clock is fast enough to
get it and write for each debug message.
2021-11-22 19:05:43 +01:00
Maria Matejka
df3264f51f Lock position checking allows for safe lock unions 2021-11-22 19:05:43 +01:00
Maria Matejka
1289c1c5ee Coroutines: A simple and lightweight parallel execution framework. 2021-11-22 19:05:43 +01:00
Maria Matejka
1db83a507a Locking subsystem: Just a global BIRD lock to begin with. 2021-11-22 19:05:43 +01:00
Maria Matejka
feb17ced23 Dropping the POSIX thread-local variables in favor of much easier-to-use C11 thread-local variables 2021-11-22 19:05:43 +01:00
Maria Matejka
b5061659d3 POSIX threads and thread-local storage is needed for concurrent execution 2021-11-22 19:05:43 +01:00
Maria Matejka
a845651bc5 Multithreaded BIRD needs reasonably new software to compile 2021-11-22 19:05:43 +01:00
Maria Matejka
8d706aedba Fixing expensive list checks. Debug only commit. 2021-11-22 19:05:43 +01:00
Maria Matejka
b5ca6a79d3 GDB: SKIP_BACK and linked list tools 2021-11-22 19:05:43 +01:00
Maria Matejka
2d7e42cc59 Type checking in SKIP_BACK macro 2021-11-22 19:05:43 +01:00
Maria Matejka
c70b3198dc Route export is now asynchronous.
To allow for multithreaded execution, we need to break the import-export
chain and buffer the exports before actually processing them.
2021-11-22 19:05:43 +01:00
Maria Matejka
f18968f52f Better profylaction recursive route loops
In some specific configurations, it was possible to send BIRD into an
infinite loop of recursive next hop resolution. This was caused by route
priority inversion.

To prevent priority inversions affecting other next hops, we simply
refuse to resolve any next hop if the best route for the matching prefix
is recursive or any other route with the same preference is recursive.

Next hop resolution doesn't change route priority, therefore it is
perfectly OK to resolve BGP next hops e.g. by an OSPF route, yet if the
same (or covering) prefix is also announced by iBGP, by retraction of
the OSPF route we would get a possible priority inversion.
2021-11-22 19:05:43 +01:00
Maria Matejka
44f26c49f9 Special table hooks rectified.
* internal tables are now more standalone, having their own import and
  export hooks
* route refresh/reload uses stale counter instead of stale flag,
  allowing to drop walking the table at the beginning
* route modify (by BGP LLGR) is now done by a special refeed hook,
  reimporting the modified routes directly without filters
2021-11-22 19:05:43 +01:00