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

1174 Commits

Author SHA1 Message Date
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