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

1340 Commits

Author SHA1 Message Date
Maria Matejka
a920b5111c Properly consted routes inside table 2023-09-24 20:43:04 +02:00
Maria Matejka
206b33fd0b Filter iterator accepts lines instead of filter 2023-09-24 20:43:04 +02:00
Vojtech Vilimek
b43580d77d Renamed channel class pointers
The channel class pointers were strangely named , not .
2023-09-24 20:43:04 +02:00
Maria Matejka
32009cb6eb Logging: Abolished stdio in favor of write() to make the logging faster. 2023-09-24 20:40:06 +02:00
Maria Matejka
88307c31c5 CLI: Dropping the mechanism of echoing log messages
This is better done by running tail -f on a logfile.
2023-09-14 14:45:01 +02:00
Maria Matejka
0faf3bb630 Enhanced tracing of route refresh state 2023-09-14 14:40:33 +02:00
Maria Matejka
51f2e7afaf Conf: Symbol manipulation gets its context explicitly 2023-09-12 15:36:46 +02:00
Maria Matejka
8e177cf35b Conf: Symbol hashes for all scopes
This is a backport cherry-pick of commits
  165156beeb
  cce974e8ea

from the v3.0 branch as we need symbol hashes directly inside their
scopes for more general usage than before.
2023-09-12 15:20:50 +02:00
Maria Matejka
510b1046e1 Hostentry application locking
Due to a race condition between rta_apply_hostentry() and rt_update_hostentry(),
happening when a new route is inserted to a table, this commit makes it mandatory
to lock the next hop resolution table while resolving the next hop.

This may be slow, we'll fix it better in some future release
2023-08-29 10:24:54 +02:00
Ondrej Zajicek
f5140d1027 Conf: Allow keywords to be redefined by user symbols
Most syntactic constructs in BIRD configuration (e.g. protocol options)
are defined as keywords, which are distinct from symbols (user-defined
names for protocols, variables, ...). That may cause backwards
compatibility issue when a new feature is added, as it may collide with
existing user names.

We can allow keywords to be shadowed by symbols in almost all cases to
avoid this issue.

This replaces the previous mechanism, where shadowable symbols have to be
explictly added to kw_syms.
2023-08-25 23:50:44 +02:00
Ondrej Zajicek
32427c9ce1 Nest: Fix missing bar in kw_sym
Thanks to Alexander Zubkov for the notice.
2023-08-25 04:29:32 +02:00
Ondrej Zajicek
f411a19bb0 Conf: Use nonterminal bytestring instead of BYTETEXT
Nonterminal bytestring allows to provide expressions to be evaluated in
places where BYTETEXT is used now: passwords, radv custom option.

Based on the patch from Alexander Zubkov <green@qrator.net>, thanks!
2023-08-24 16:59:23 +02:00
Alexander Zubkov
0dbcc92726 Filter: Use more generic approach for intra-config expressions
Replace f_eval_int() function with a type-generic variant: cf_eval().
Implement similar fuction: cf_eval_int() via inline call to cf_eval().
2023-08-24 04:45:55 +02:00
Alexander Zubkov
fc3547880a Filter: Add bytestring type
- Rename BYTESTRING lexem to BYTETEXT, not to collide with 'bytestring' type name
 - Add bytestring type with id T_BYTESTRING (0x2c)
 - Add from_hex() filter function to create bytestring from hex string
 - Add filter test cases for bytestring type

Minor changes by committer.
2023-08-24 04:33:33 +02:00
Ondrej Zajicek
e3c0eca956 Nest: Treat VRF interfaces as inside respective VRFs
Despite not having defined 'master interface', VRF interfaces should be
treated as being inside respective VRFs. They behave as a loopback for
respective VRFs. Treating the VRF interface as inside the VRF allows
e.g. OSPF to pick up IP addresses defined on the VRF interface.

For this, we also need to tell apart VRF interfaces and regular interfaces.
Extend Netlink code to parse interface type and mark VRF interfaces with
IF_VRF flag.

Based on the patch from Erin Shepherd, thanks!
2023-08-23 16:08:40 +02:00
Ondrej Zajicek
5121101136 Merge branch 'bmp' 2023-08-22 15:28:05 +02:00
Ondrej Zajicek
52641e0866 BMP: Use generic channel feed instead of direct walk over rtable
Now we use rt_notify() and channels for both feed and notifications,
in both import tables (pre-policy) and regular tables (post-policy).

Remove direct walk in bmp_route_monitor_snapshot().
2023-08-21 04:24:15 +02:00
Ondrej Zajicek
ef6ab5ce86 Nest: Use generic rte_announce() also for import tables
Remove special rte_announce_in(), so we can use generic rte_announce()
for bot feed and notifications.
2023-08-21 04:17:21 +02:00
Ondrej Zajicek
f4deef89be BMP: Refactor route monitoring
- Manage BMP state through bmp_peer, bmp_stream, bmp_table structures
 - Use channels and rt_notify() hook for route announcements
 - Add support for post-policy monitoring
 - Send End-of-RIB even when there is no routes
 - Remove rte_update_in_notify() hook from import tables
 - Update import tables to support channels
 - Add bmp_hack (no feed / no flush) flag to channels
2023-08-18 03:53:58 +02:00
Ondrej Zajicek
3cf91fb9eb Nest: Add tests and benchmark for FIB
Basic fib_get() / fib_find() test for random prefixes, FIB_WALK() test,
and benchmark for fib_find(). Also generalize and reuse some code from
trie tests.
2023-05-16 13:25:48 +02:00
Maria Matejka
fcbf22d1f6 Properly protecting the route src global index by RCU read lock and atomic operations
There was a bug occuring when one thread sought for a src by its global id
and another one was allocating another src with such an ID that it caused
route src global index reallocation. This brief moment of inconsistency
led to a rare use-after-free of the old global index block.
2023-05-11 11:41:01 +02:00
Maria Matejka
a818a3011e Channel: configurable feed block size 2023-05-11 11:41:01 +02:00
Maria Matejka
318ac8720f OLocks in BGP must be freed early 2023-05-09 10:33:23 +02:00
Maria Matejka
ed91d884d3 Hostentry: fix pool locking 2023-05-06 10:50:31 +02:00
Maria Matejka
7d8e541057 Linpool state save and restore refactoring 2023-05-06 10:50:31 +02:00
Maria Matejka
91471531a1 Fixed race condition in hostentry allocation 2023-05-03 21:30:29 +02:00
Ondrej Zajicek
a8a64ca0fe Conf: Improve handling of keywords
For whatever reason, parser allocated a symbol for every parsed keyword
in each scope. That wasted time and memory. The effect is worsened with
recent changes allowing local scopes, so keywords often promote soft
scopes (with no symbols) to real scopes.

Do not allocate a symbol for a keyword. Take care of keywords that could
be promoted to symbols (kw_sym) and do it explicitly.
2023-04-27 18:41:01 +02:00
Maria Matejka
ce7495b49a Refactoring of domains connected to pools 2023-04-25 09:52:28 +02:00
Maria Matejka
22f54eaee6 Resource pools are now bound with domains.
Memory allocation is a fragile part of BIRD and we need checking that
everybody is using the resource pools in an appropriate way. To assure
this, all the resource pools are associated with locking domains and
every resource manipulation is thoroughly checked whether the
appropriate locking domain is locked.

With transitive resource manipulation like resource dumping or mass free
operations, domains are locked and unlocked on the go, thus we require
pool domains to have higher order than their parent to allow for this
transitive operations.

Adding pool locking revealed some cases of insecure memory manipulation
and this commit fixes that as well.
2023-04-24 10:33:28 +02:00
Maria Matejka
6230d87c74 Protocols and tables now use the birdloop pools as primary 2023-04-22 21:20:19 +02:00
Maria Matejka
1141ce4e2d Resource pool closing has its dedicated function 2023-04-22 20:49:58 +02:00
Maria Matejka
b3f805ce29 Socket closing has its dedicated function 2023-04-22 20:48:42 +02:00
Maria Matejka
074739e0e9 Global protocol list is typed to avoid typecast confusion 2023-04-22 20:48:42 +02:00
Maria Matejka
787fb56da3 IO: added a specific loop pickup group for BFD; to be done better in future 2023-04-17 13:30:14 +02:00
Ondrej Zajicek (work)
4d56b70dc5 BMP: Remove duplicate functions for update encoding
Use existing BGP functions also for BMP update encoding.
2023-04-16 20:06:00 +02:00
Pawel Maslanka
a848dad40a BMP protocol support
Initial implementation of a basic subset of the BMP (BGP Monitoring
Protocol, RFC 7854) from Akamai team. Submitted for further review
and improvement.
2023-04-16 20:05:15 +02:00
Maria Matejka
dc75d3e305 Merge commit '231c6385' into thread-next-iface 2023-04-14 14:00:54 +02:00
Maria Matejka
eb978f3a83 Merge commit '0851fcde' into thread-next-iface 2023-04-14 11:37:23 +02:00
Maria Matejka
571c4f69bf More efficient IO loop event execution to avoid long loops
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-04 17:00:59 +02:00
Maria Matejka
d9f0f4af7d Resource dumps also write out block addresses 2023-04-04 17:00:59 +02:00
Maria Matejka
0b7657a9dc Route feed marks only the relevant pending exports as done 2023-04-04 17:00:58 +02:00
Maria Matejka
98f69aa419 Propagated const through route feed routines 2023-04-04 17:00:58 +02:00
Maria Matejka
3a53a12af4 Moved channel export hooks to rt.h as the channel refactoring isn't going to take place soon 2023-04-04 17:00:58 +02:00
Maria Matejka
731ec00840 Allowing to restart a route refresh.
Repeated pipe refeed should not end route refresh as the prune routine
may start pruning otherwise valid routes.

The same applies for BGP repeated route refresh.
2023-04-04 17:00:58 +02:00
Maria Matejka
765bf99b69 Fixed default table configuration
When changing default table behavior, I missed that it enabled to
configure multiple master4 and master6 tables. Now BIRD recognizes it
and fails properly.
2023-04-04 17:00:58 +02:00
Maria Matejka
88fc87afe6 Fixed use-after-free of old protocol name pointer copied into rte_owner structure 2023-04-04 17:00:58 +02:00
Maria Matejka
90de93ca03 Fixed unwanted reloads while reconfiguring protocols with import table on 2023-04-04 17:00:58 +02:00
Maria Matejka
97d2875e99 Fixed bad filter re-evaluation with import table if filtered->accepted
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-04-04 17:00:58 +02:00
Maria Matejka
aa5fc3b99d Fixed channel stopping when reload is active 2023-04-04 17:00:58 +02:00
Maria Matejka
7d6fe6dfb1 Fix obvious mistake in protocol debug dump 2023-04-04 17:00:58 +02:00
Maria Matejka
c8507c1247 Fixed stopping of import request with no imports in idle table 2023-04-04 17:00:58 +02:00
Maria Matejka
03bfb8b59d Moved table hostcache updater to table service routines to not bother the mainloop 2023-04-04 17:00:58 +02:00
Maria Matejka
9073eda854 Reducing initial channel bitmap sizes to help extreme cases 2023-04-04 17:00:58 +02:00
Maria Matejka
e565e045b6 Flowspec links must have the destination table service loop locked 2023-04-04 17:00:58 +02:00
Maria Matejka
6543303ad4 BFD notifications respect protocol loop settings 2023-04-04 17:00:58 +02:00
Maria Matejka
b8a230e478 Interface subsystem locking 2023-04-04 17:00:58 +02:00
Maria Matejka
a26d307eab Proto: published protocol-loop connections 2023-04-04 16:44:54 +02:00
Johannes Moos
231c63851e Add missing references to "show route in" in the cli-help and doc.
The feature of showing all prefixes inside the given one has been added
in v2.0.9 but not well documented. Fixing it by this update.

Text in doc and commit message added by commiter.
2023-03-18 15:36:05 +01:00
Maria Matejka
9508cd85ce Protocol shutdown/restart from limits is respecting the loops 2023-02-07 14:28:25 +01:00
Maria Matejka
a2fd889a3b Merge commit '0bb04d5390f21b0c96fc4894ba5d5510c541f0ef' into HEAD 2023-02-07 14:27:23 +01:00
Maria Matejka
c354e8f4c1 Interface updates are asynchronous
Instead of propagating interface updates as they are loaded from kernel,
they are enqueued and all the notifications are called from a
protocol-specific event. This change allows to break the locking loop
between protocols and interfaces.

Anyway, this change is based on v2 branch to keep the changes between v2
and v3 smaller.
2023-02-02 15:57:21 +01:00
Maria Matejka
64e0877525 Proto: Adding a list of associated neighbors
This makes for safer and faster pruning and notifying as protocol now on
its shutdown prunes only its neighbors and nothing else.
2023-02-02 14:40:00 +01:00
Maria Matejka
e077d0e770 Moved interface list flush to device protocol cleanup hook.
The interface list must be flushed when device protocol is stopped. This
was done in a hardcoded specific hook inside generic protocol routines.
The cleanup hook was originally used for table reference counting late
cleanup, yet it can be also simply used for prettier interface list flush.
2023-02-02 14:40:00 +01:00
Ondrej Zajicek
0ab62f2674 Build: Partial revert of one of previous changes
There are many compatibility issues with echo -e, scratch that.
2023-02-01 19:30:21 +01:00
Ondrej Zajicek
23f3dd5cfb Nest: Minor cleanup in buildsystem
There ware missing dependencies for proto-build.c generation, which
sometimes lead to failed builds, and ignores changes in the set of
built protocols. Fix that, and also improve formatting of proto-build.c
2023-02-01 17:31:18 +01:00
Maria Matejka
05d8c3699d Object locks use events
Instead of calling custom hooks from object locks, we use standard event
sending mechanism to inform protocols about object lock changes. This is
a backport from version 3 where these events are passed across threads.

This implementation of object locks doesn't use mutexes to lock the
whole data structure. In version 3, this data structure may get accessed
from multiple threads and must be protected by mutex.
2023-01-26 13:22:28 +01:00
Maria Matejka
4334f86251 VRF setting reduced to one argument, using default dummy iface for default vrf 2023-01-25 13:33:31 +01:00
Maria Matejka
f7c2a886c9 Object locks use events
Instead of calling custom hooks from object locks, we use standard event
sending mechanism to inform protocols about object lock changes. As
event sending is lockless, the unlocking protocol simply enqueues the
appropriate event to the given loop when the locking is done.
2023-01-24 11:34:36 +01:00
Maria Matejka
7bb93efc27 Merge commit '6d1ae197d189d50e60279796441c6e74272ddc54' into thread-next 2023-01-23 19:03:16 +01:00
Maria Matejka
21c4c8eafb Merge commit '1e47b9f203aaaad0fb658d40a1670f1d0437f1f8' into thread-next 2023-01-21 23:49:52 +01:00
Maria Matejka
343628d8c0 Fixed various build problems on FreeBSD and/or CLang 2023-01-20 18:31:57 +01:00
Maria Matejka
4d8d81f144 Table prune routine doesn't walk over lists unless needed.
If no channel is flushing, table prune doesn't walk over routes in nets
and also doesn't walk over importing channel lists. This helps to
alleviate the memory caching burdens a lot.
2023-01-19 11:10:25 +01:00
Maria Matejka
59a5bf18f9 CLI closing fix when its action is run asynchronously.
Some CLI actions, notably "show route", are run by queuing an event
somewhere else. If the user closes the socket, in case such an action is
being executed, the CLI must free the socket immediately from the error
hook but the pool must remain until the asynchronous event finishes and
cleans everything up.
2023-01-19 11:03:31 +01:00
Ondrej Zajicek
b28431e557 Nest: Fix leaking internal attributes in RIP and Babel
During backporting attribute changes from 3.0-branch, some internal
attributes (RIP iface and Babel seqno) leaked to 'show route all' output.
Allow protocols to hide specific attributes with GA_HIDDEN value.

Thanks to Nigel Kukard for the bugreport.
2023-01-03 17:01:54 +01:00
Ondrej Zajicek
6d1ae197d1 Nest: Fix several issues with pflags
There were some confusion about validity and usage of pflags, which
caused incorrect usage after some flags from (now removed) protocol-
specific area were moved to pflags.

We state that pflags:

 - Are secondary data used by protocol-specific hooks
 - Can be changed on an existing route (in contrast to copy-on-write
   for primary data)
 - Are irrelevant for propagation (not propagated when changed)
 - Are specific to a routing table (not propagated by pipe)

The patch did these fixes:

 - Do not compare pflags in rte_same(), as they may keep cached values
   like BGP_REF_STALE, causing spurious propagation.

 - Initialize pflags to zero in rte_get_temp(), avoid initialization in
   protocol code, fixing at least two forgotten initializations (krt
   and one case in babel).

 - Improve documentation about pflags
2023-01-01 20:10:23 +01:00
Ondrej Zajicek
4c19a8a984 CLI: Fix for long-lived sessions during high loads
When there is a continuos stream of CLI commands, cli_get_command()
always returns 1 (there is a new command). Anyway, the socket receive
buffer was reset only when there was no command at all, leading to a
strange behavior: after a while, the CLI receive buffer came to its end,
then read() was called with zero size buffer, it returned 0 which was
interpreted as EOF.

The patch fixes that by resetting the buffer position after each command
and moving remaining data at the beginning of buffer.

Thanks to Maria Matejka for examining the bug and for the original bugfix.
2022-12-10 17:32:42 +01:00
Ondrej Zajicek
e80156d936 Nest: Avoid spurious announcements triggered by filtered routes
When filtered routes (enabled by 'import keep filtered' option) are
updated, they trigger announcements by rte_announce(). For regular
channels (e.g. type RA_OPTIMAL or RA_ANY) such announcement is just
ignored, but in case of RA_ACCEPTED (BGP peer with 'secondary' option)
it just reannounces the old (and still valid) best route.

The patch ensures that such no-change is ignored even for these channels.
2022-12-06 19:51:50 +01:00
Maria Matejka
7bbd0b5a3b Merge commit '37b64441' into thread-next 2022-11-07 10:28:01 +01:00
Maria Matejka
54179a1ab3 Merge commit '8f79e6b9' into thread-next 2022-11-07 10:24:56 +01:00
Maria Matejka
96d3804057 Merge commit '8478de88' into thread-next 2022-11-07 10:18:19 +01:00
Maria Matejka
34e803c6c3 Merge commit '54430df9' into thread-next 2022-11-07 10:09:01 +01:00
Maria Matejka
37b6444137 Moved config-related allocations to config_pool and showing its size in memory usage 2022-11-01 16:38:24 +01:00
Alexander Zubkov
5aebce5e0c Doc: Add documentation for "show route (import|export) table" 2022-10-18 04:25:29 +02:00
Maria Matejka
8d7f516b2a Attribute blocks are now allocated from slabs instead of malloc() 2022-10-12 18:04:39 +02:00
Maria Matejka
d3af586da4 Removed an accidentally merged debug call introduced in 5395880908 2022-10-12 18:02:34 +02:00
Maria Matejka
ff24f027a6 Merge commit '53958809' into thread-next 2022-10-12 11:30:27 +02:00
Maria Matejka
c4957647b4 Merge commit '4ba991f1' into thread-next 2022-10-12 11:24:23 +02:00
Maria Matejka
fdacb89a53 BGP refeed and reload with Adj-RIB-In/Out is done without route refresh 2022-10-12 10:05:16 +02:00
Maria Matejka
c1cb2dc31c TES_HUNGRY doesn't inhibit export cleanup any more 2022-10-12 10:05:16 +02:00
Maria Matejka
6d5929be24 More thorough logging of route update corner cases 2022-10-12 10:05:16 +02:00
Maria Matejka
26552a7ec8 Fixed BGP reload limits 2022-10-12 10:05:14 +02:00
Maria Matejka
b83a9d5f9a Limited value must never go under zero 2022-10-12 10:05:14 +02:00
Maria Matejka
02dc895550 CLI fix to break busy-loop waiting for corked show-route exports 2022-10-12 10:05:14 +02:00
Maria Matejka
2ae32374dd Fixed export hook stopping in some corner cases.
Notably, it's in a corked state and also when refeed is pending.
2022-10-12 10:05:14 +02:00
Ondrej Zajicek
8f79e6b93e BGP: Add option 'next hop prefer global'
Add BGP channel option 'next hop prefer global' that modifies BGP
recursive next hop resolution to use global next hop IPv6 address instead
of link-local next hop IPv6 address for immediate next hop of received
routes.
2022-10-10 05:06:19 +02:00
Maria Matejka
4d687d7aec Fixed previously untested paths in RPKI 2022-10-05 16:33:34 +02:00
Maria Matejka
dc9351d326 Merge commit '67256d50' into HEAD 2022-10-04 16:15:36 +02:00
Maria Matejka
f69ba3921a Merge commit 'fb7fb674' into HEAD 2022-10-04 16:09:41 +02:00
Maria Matejka
0eba27c69f Merge commit 'a32cee78' into HEAD 2022-10-04 15:59:15 +02:00
Maria Matejka
4e1c582cad Merge commit '71b434a9' into HEAD 2022-10-04 15:53:12 +02:00
Ondrej Zajicek
8478de8817 Nest: Add channel config flag to distinguish new or copy
It is useful to distinguish whehter channel config returned from
channel_config_get() was allocated new, or existing from template.
Caller may want to initialize new ones.
2022-10-03 20:18:12 +02:00
Ondrej Zajicek
54430df953 BGP: Do not assume that all channels are struct bgp_channel
In principle, the channel list is a list of parent struct proto and can
contain general structures of type struct channel, That is useful e.g.
for adding MPLS channels to BGP.
2022-10-03 20:18:12 +02:00
Ondrej Zajicek
92a8565547 Filter: Add some minor functions for f_tree and EC
Add some supportive functions for f_tree and EC. These functions are used
by L3VPN code.
2022-10-03 20:18:12 +02:00
Maria Matejka
6cfe2066ab Higher export settle times when route refresh is running.
This helps the route refresh procedures to finish or at least
do more work before the exporters jump in and steal all the CPU time
for themselves.
2022-09-26 12:09:14 +02:00
Maria Matejka
ecaa3df3c4 More verbose logging of table auxiliary export states 2022-09-23 09:58:00 +02:00
Maria Matejka
5338a779c9 Fixed possible race condition in hostcache trie matching code not triggering HCU 2022-09-23 09:57:40 +02:00
Maria Matejka
b1ade5efa1 Fixed the export settle timer to be actually a settle timer 2022-09-21 18:47:43 +02:00
Maria Matejka
896dbbfe4a Local page allocation 2022-09-21 11:49:35 +02:00
Maria Matejka
28d4ac6c97 Fixed display of standby memory 2022-09-20 14:57:43 +02:00
Maria Matejka
4ba52a2687 Route export may get corked on refeed startup 2022-09-20 12:40:23 +02:00
Maria Matejka
28427a68c3 Merge commit 'adf37d8e' into thread-next 2022-09-20 09:14:39 +02:00
Maria Matejka
f33793acf7 Merge commit '4f3fa162' into HEAD 2022-09-18 16:36:07 +02:00
Maria Matejka
cf38092b2d Fix for table hostcache corking and shutdown race conditions 2022-09-18 16:35:49 +02:00
Maria Matejka
c9d18e5ec5 Table: Re-scheduling prune event when another prune loop is pending 2022-09-18 16:33:51 +02:00
Maria Matejka
ff86f23dc7 Export event doesn't have to be postponed before requeuing as an export-stop event 2022-09-18 16:33:51 +02:00
Maria Matejka
769224d79c Converted simple table events to loop flags 2022-09-18 16:33:51 +02:00
Maria Matejka
c49ee6e1a6 Routing tables have their own service loops. 2022-09-18 16:33:51 +02:00
Maria Matejka
b80823fe82 Memory pages allocator is now a global simple lockless structure 2022-09-18 16:33:51 +02:00
Maria Matejka
3d627d09d4 Table export announcer needs both an event and a timer to do export bundling the right way 2022-09-09 19:09:31 +02:00
Maria Matejka
974f16b1f7 Created a dedicated settle timer structure 2022-09-09 18:53:15 +02:00
Maria Matejka
26bfd4cc03 Merge commit 'd2c1036a42881d413ec97203ede92a69f8cd218f' into thread-next 2022-09-09 13:15:50 +02:00
Maria Matejka
fb7fb67445 Table access is now locked. 2022-09-08 15:24:02 +02:00
Maria Matejka
a42877b9bf Table feed refactoring to allow for locking and unlocking 2022-09-08 15:13:38 +02:00
Maria Matejka
5103de4e8e Table long-locking debug code 2022-09-08 15:13:37 +02:00
Maria Matejka
e2c6120636 Next hop updater has its own event 2022-09-08 15:13:37 +02:00
Maria Matejka
a61a04b5c8 Next hop refactoring to allow for table locking 2022-09-07 13:54:55 +02:00
Maria Matejka
71b3456eed 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.
2022-09-06 15:15:03 +02:00
Maria Matejka
28accd4f05 Next hop update triggered at the very end of hostcache update 2022-09-05 12:55:36 +02:00
Maria Matejka
636bc44e61 Exporter routine refactoring to allow for nicer table locking 2022-09-05 12:19:38 +02:00
Maria Matejka
66ccdc2a0c Added an indirection to the export announcement routine
There are performance reasons for this, mostly that we don't want to
ping the table service routine with every import.
2022-09-01 22:22:31 +02:00
Maria Matejka
dd786e338c ROA subscriptions are also converted to export requests.
By this, the requesting channels do the timers in their own loops,
avoiding unnecessary synchronization when the central timer went off.

This is of course less effective for now, yet it allows to easily
implement selective reloads in future.
2022-09-01 18:46:40 +02:00
Maria Matejka
cd628d124d Flowspec revalidate notification converted to an export hook
Instead of synchronous notifications, we use the asynchronous export
framework to notify flowspec src route updates. This allows us to
invoke flowspec revalidation without locking collisions.
2022-09-01 18:46:40 +02:00
Maria Matejka
ecdb1ec6ea Hostcache update notification converted to an export hook
Instead of synchronous notifications, we use the asynchronous export
framework to notify also hostcache updates. This allows us to do the
hostcache update and the subsequent next hop update notification without
locking collisions.
2022-09-01 18:46:40 +02:00
Maria Matejka
7450eea071 Miscellaneous refactoring 2022-09-01 18:46:40 +02:00
Maria Matejka
83ceb91b50 Table debug is now a per-table setting and has categories. 2022-09-01 18:46:40 +02:00
Maria Matejka
397fec4741 Default tables are not created unless actually used.
This allows for setting default table values at the beginning of config
file before "master4" and "master6" tables are initialized.
2022-09-01 17:44:46 +02:00
Maria Matejka
34912b029b Tables: Requesting prune only after export cleanup
We can't free the network structures before the export has been cleaned
up, therefore it makes more sense to request prune only after export
cleanup. This change also reduces prune calls on table shutdown.
2022-08-30 18:05:06 +02:00
Maria Matejka
dc28c6ed1c Simplified the protocol hookup code in Makefiles 2022-08-18 22:07:30 +02:00
Maria Matejka
74eb4bad5f Merge commit 'c7d0c5b2' into thread-next 2022-08-03 20:01:42 +02:00
Maria Matejka
e60b83d8ac Merge commit '18f66055' into thread-next 2022-08-03 18:00:17 +02:00
Maria Matejka
70e01358a0 Merge commit '038fcf1c' into thread-next
It was necessary to update the code to match removal of rta, as well as
existence of cached nested attribute lists.
2022-08-03 17:37:16 +02:00
Maria Matejka
71b434a987 Merge commit 'f0507f05ce57398e135651896dace4cb68eeed54' into thread-next 2022-08-02 22:08:59 +02:00
Maria Matejka
db9153e216 Also next hop update routines are corking themselves when congestion is detected 2022-08-02 17:51:58 +02:00
Maria Matejka
f8500b5943 Route table cork: Indicate whether the export queues are congested.
These routines detect the export congestion (as defined by configurable
thresholds) and propagate the state to readers. There are no readers for
now, they will be added in following commits.
2022-08-02 17:34:38 +02:00
Maria Matejka
e858dce757 Moved the thread starting code to IO loop code 2022-07-28 19:49:03 +02:00
Maria Matejka
4d48ede51d Revert "Export table: Delay freeing of old stored route."
This reverts commit cee0cd148c.
This change is not needed in version 2 and the surrounding code has
disappeared mostly in version 3.
2022-07-22 15:37:21 +02:00
Maria Matejka
e91754f5b9 Event lists rewritten to a single linked list
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-18 13:28:35 +02:00
Maria Matejka
08c8484608 Merge commit '94eb0858' into thread-next 2022-07-18 12:33:00 +02:00
Maria Matejka
812edb85e1 Fixing build issues caused by a nonportable Makefile rule 2022-07-18 10:26:55 +02:00
Maria Matejka
05673b16a8 Merge commit 'c70b3198' into thread-next [lots of conflicts]
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-15 14:57:02 +02:00
Maria Matejka
1c2851ecfa Fixed invalid routes handling
The invalid routes were filtered out before they could ever get
exported, yet some of the routines need them available, e.g. for
display or import reload.

Now the invalid routes are properly exported and dropped in channel
export routines instead.
2022-07-14 12:13:18 +02:00
Maria Matejka
68a2c9d4c9 Merge commit '2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f' into thread-next 2022-07-13 14:14:37 +02:00
Maria Matejka
5be34f5ab4 Merge commit '7e9cede1fd1878fb4c00e793bccd0ca6c18ad452' into thread-next 2022-07-13 12:02:34 +02:00
Maria Matejka
4ec443b5c2 Fixed bug in repeated show route command
Introduced by 13ef5e53dd, the CLI was not
properly cleaned up when the command finished, causing BIRD to not parse
any other command after "show route".
2022-07-13 11:24:09 +02:00
Maria Matejka
4f16270dd9 Merge commit 'f18968f5' into thread-next 2022-07-12 15:05:04 +02:00
Maria Matejka
bc2ce4aaa8 Removing the rte_modify API
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-12 14:45:27 +02:00
Maria Matejka
080cbd1219 Route refresh in tables uses a stale counter.
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-12 12:22:41 +02:00
Maria Matejka
4ef2262bd5 There are now no internal tables at all. 2022-07-11 17:08:59 +02:00
Maria Matejka
6b0368cc2c Export tables merged with BGP prefix hash
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-11 16:07:09 +02:00
Maria Matejka
b06911f6ef Do not try to check flowspec validity for piped routes 2022-07-11 16:07:09 +02:00
Maria Matejka
61842ff315 Fixed bad import table attributes freeing 2022-07-11 16:07:09 +02:00
Maria Matejka
fd72c69678 Attribute lists split to storage headers and data to save BGP memory 2022-07-11 16:07:09 +02:00
Maria Matejka
dc720a085f Show route uses the export request also for one-net queries 2022-07-11 16:07:09 +02:00
Maria Matejka
b5c8fce284 Added forgotten route source locking in flowspec validation 2022-07-11 13:04:01 +02:00
Maria Matejka
2e5bfeb73a Merge remote-tracking branch 'origin/master' into backport 2022-07-11 11:08:10 +02:00
Maria Matejka
d429bc5c84 Merge commit 'beb5f78a' into backport 2022-07-11 10:41:17 +02:00
Maria Matejka
7e9cede1fd Merge version 2.0.10 into backport 2022-07-10 14:19:24 +02:00
Ondrej Zajicek (work)
cb339a3067 Filter: Implement for loops
For loops allow to iterate over elements in compound data like BGP paths
or community lists. The syntax is:

  for [ <type> ] <variable> in <expr> do <command-body>
2022-06-27 21:13:32 +02:00
Ondrej Zajicek (work)
a2527ee53d Filter: Improve handling of stack frames in filter bytecode
When f_line is done, we have to pop the stack frame. The old code just
removed nominal number of args/vars. Change it to use stored ventry value
modified by number of returned values. This allows to allocate variables
on a stack frame during execution of f_lines instead of just at start.

But we need to know the number of returned values for a f_line. It is 1
for term, 0 for cmd. Store that to f_line during linearization.
2022-06-27 21:13:32 +02:00
Ondrej Zajicek (work)
8f3c6151b4 Nest: Cleanups in as_path_filter()
Use struct f_val as a common argument for as_path_filter(), as suggested
by Alexander Zubkov. That allows to use NULL sets as valid arguments.
2022-06-27 21:13:31 +02:00
Maria Matejka
beb5f78ada Preexport callback now takes the channel instead of protocol as argument
Passing protocol to preexport was in fact a historical relic from the
old times when channels weren't a thing. Refactoring that to match
current extensibility needs.
2022-06-27 19:04:24 +02:00
Maria Matejka
bdd6f72839 Moved nexthop + hostentry display to other eattrs 2022-06-27 13:39:28 +02:00
Maria Matejka
d5cac1a4ef Route attribute display now normalizes ea_lists.
This is needed to display every attribute only once with overlay
attribute lists recently introduced.
2022-06-27 12:44:11 +02:00
Maria Matejka
c431d9c33c Fixed new route comparison 2022-06-27 12:32:47 +02:00
Maria Matejka
d2142ad405 Fixed displaying BGP and RIP attributes after recent reworks 2022-06-27 12:32:47 +02:00
Maria Matejka
0f2f5ac58c Fixed minor bugs in handling some route attributes 2022-06-27 12:32:47 +02:00
Maria Matejka
dfb61dfcea Fixed undefined attribute handling 2022-06-27 12:32:47 +02:00
Maria Matejka
13ef5e53dd The show-route CLI command now uses the route export API
In the multithreaded environment, it is not supposed that anybody
traverses the routing table as the CLI show-route was doing. Now the
routing table traversal is gone and CLI won't hold the table locked
while computing filters.
2022-06-27 12:32:47 +02:00
Maria Matejka
9c9059fd17 Allowed optimized exporting of a subprefix tree
Added an option for export filter to allow for prefiltering based on the
prefix. Routes outside the given prefix are completely ignored. Config
is simple:

	export in <net> <filter>;
2022-06-24 15:49:08 +02:00
Maria Matejka
050b4b4e5e Table export generalized to allow for exporting from non-tables 2022-06-24 15:49:08 +02:00
Maria Matejka
becab5072d Import tables are stored as an attribute layer inside the main tables.
The separate import tables were too memory-greedy, there is no need for
them being stored as full-sized tables.
2022-06-20 11:56:38 +02:00
Maria Matejka
8c92f47ac7 Route attribute storage keeps the previous layers 2022-06-17 10:55:23 +02:00
Maria Matejka
54d94f4b1a Showing the nexthop resolution target in import tables 2022-06-16 12:39:08 +02:00
Maria Matejka
4364ee9b6f Merge commit '938742decc6e1d6d3a0375dd012b75172e747bbc' into haugesund 2022-06-08 15:31:28 +02:00
Maria Matejka
cae5979871 Merge commit '950775f6fa3d569a9d7cd05e33538d35e895d688' into haugesund
There were quite a lot of conflicts in flowspec validation code which
ultimately led to some code being a bit rewritten, not only adapted from
this or that branch, yet it is still in a limit of a merge.
2022-06-08 11:47:49 +02:00
Maria Matejka
8fd3811d9d Fixing FlowSpec validation for v3 internal API
Validation is called internally from route table at the same place where
nexthop resolution is done. Also accounting for rte->sender semantics
change (not a channel but the import hook instead).
2022-06-07 12:18:25 +02:00
Ondrej Zajicek
a8a3d95be5 Nest: Improve GC strategy for rtables
Use timer (configurable as 'gc period') to schedule routing table
GC/pruning to ensure that prune is done on time but not too often.

Randomize GC timers to avoid concentration of GC events from different
tables in one loop cycle.

Fix a bug that caused minimum inter-GC interval be 5 us instead of 5 s.

Make default 'gc period' adaptive based on number of routing tables,
from 10 s for small setups to 600 s for large ones.

In marge multi-table RS setup, the patch improved time of flushing
a downed peer from 20-30 min to <2 min and removed 40s latencies.
2022-06-04 17:34:57 +02:00
Maria Matejka
ea109ce3e3 Merge commit '4fe9881d625f10e44109a649e369a413bd98de71' into haugesund 2022-05-31 12:51:34 +02:00
Maria Matejka
1493695c6b Merge commit 'f15f2fcee7eeb5a100bd204a0e67018e25953420' into haugesund 2022-05-30 17:37:08 +02:00
Maria Matejka
7b0c89a47f Merge commit 'f2e725a76882ba6b75c3ce4fb3c760bd83462410' into haugesund 2022-05-30 17:27:03 +02:00
Maria Matejka
41508ceac3 Merge commit '1c30b689ddd032ef8000fb7836348a48ba3184ff' into haugesund 2022-05-30 17:26:25 +02:00
Maria Matejka
65254128e1 Merge commit '702c04fbef222e802ca4dfac645dc75ede522db6' into haugesund 2022-05-30 17:18:46 +02:00
Maria Matejka
1a92ee9d4d Merge commit '337c04c45e1472d6d9b531a3c55f1f2d30ebf308' into haugesund 2022-05-30 17:18:03 +02:00
Maria Matejka
674587d9c8 Merge commit 'd8661a4397e4576ac404661b192dd99d928e7890' into haugesund 2022-05-30 17:11:30 +02:00
Maria Matejka
5051e3c4af Merge commit '17f91f9e6e70f7e3f29502e854823c0d48571eaa' into haugesund 2022-05-30 16:59:24 +02:00
Maria Matejka
c1645b9d5b Merge commit '165156beeb2926472bbceca3c103aacc3f81a8cc' into haugesund 2022-05-30 16:53:18 +02:00
Maria Matejka
b7e2edd441 Merge commit '1d309c4ce6e95b68c64a8f007f6dd2f1830a5707' into haugesund 2022-05-30 16:48:17 +02:00
Maria Matejka
e16e1e4138 Merge commit 'f2f3163f6c3fba7f9ef03640d7b2f6323873d2cc' into haugesund 2022-05-30 16:41:15 +02:00
Maria Matejka
0097f24e2e Merge commit 'de86040b2cf4ec9bfbb64f0e208a19d4d7e51adc' into haugesund 2022-05-30 16:21:48 +02:00
Maria Matejka
86ac1045d7 Merge commit '3fb70b26faca6788aa0bdf1d558414f9f777c6cd' into haugesund 2022-05-30 16:21:02 +02:00