]> git.ipfire.org Git - thirdparty/bird.git/log
thirdparty/bird.git
2 years agoMerge commit '1518970c' into HEAD
Maria Matejka [Sun, 18 Sep 2022 14:35:40 +0000 (16:35 +0200)] 
Merge commit '1518970c' into HEAD

2 years agoFixing several race-conditions in event code.
Maria Matejka [Mon, 12 Sep 2022 09:09:43 +0000 (11:09 +0200)] 
Fixing several race-conditions in event code.

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.

2 years agoLonger unit test default timeout to prevent spurious build failures on slow virtuals
Maria Matejka [Tue, 13 Sep 2022 09:39:35 +0000 (11:39 +0200)] 
Longer unit test default timeout to prevent spurious build failures on slow virtuals

2 years agoTable: Re-scheduling prune event when another prune loop is pending
Maria Matejka [Mon, 12 Sep 2022 16:27:01 +0000 (18:27 +0200)] 
Table: Re-scheduling prune event when another prune loop is pending

2 years agoExport event doesn't have to be postponed before requeuing as an export-stop event
Maria Matejka [Mon, 12 Sep 2022 10:28:05 +0000 (12:28 +0200)] 
Export event doesn't have to be postponed before requeuing as an export-stop event

2 years agoConverted simple table events to loop flags
Maria Matejka [Mon, 12 Sep 2022 08:25:14 +0000 (10:25 +0200)] 
Converted simple table events to loop flags

2 years agoLoop flags: a simple idempotent event announcement mechanism
Maria Matejka [Mon, 12 Sep 2022 08:24:55 +0000 (10:24 +0200)] 
Loop flags: a simple idempotent event announcement mechanism

2 years agoCancelling all timers when loop stops
Maria Matejka [Sun, 11 Sep 2022 20:26:24 +0000 (22:26 +0200)] 
Cancelling all timers when loop stops

2 years agoRouting tables have their own service loops.
Maria Matejka [Fri, 9 Sep 2022 11:52:37 +0000 (13:52 +0200)] 
Routing tables have their own service loops.

2 years agoMemory pages allocator is now a global simple lockless structure
Maria Matejka [Fri, 9 Sep 2022 18:57:59 +0000 (20:57 +0200)] 
Memory pages allocator is now a global simple lockless structure

2 years agoRevert "Routing tables now have their own loops."
Maria Matejka [Wed, 14 Sep 2022 07:59:45 +0000 (09:59 +0200)] 
Revert "Routing tables now have their own loops."

This reverts commit 878eeec12bf020c9e7460040d225a929bbbd2bd2.

These changes have been done in a different way in the other branch of
the future merge.

2 years agoTable export announcer needs both an event and a timer to do export bundling the...
Maria Matejka [Fri, 9 Sep 2022 17:09:31 +0000 (19:09 +0200)] 
Table export announcer needs both an event and a timer to do export bundling the right way

2 years agoCreated a dedicated settle timer structure
Maria Matejka [Fri, 9 Sep 2022 13:04:36 +0000 (15:04 +0200)] 
Created a dedicated settle timer structure

2 years agoMerge remote-tracking branch 'origin/master' into thread-next
Maria Matejka [Fri, 9 Sep 2022 11:17:24 +0000 (13:17 +0200)] 
Merge remote-tracking branch 'origin/master' into thread-next

2 years agoMerge commit 'd2c1036a42881d413ec97203ede92a69f8cd218f' into thread-next
Maria Matejka [Fri, 9 Sep 2022 11:15:50 +0000 (13:15 +0200)] 
Merge commit 'd2c1036a42881d413ec97203ede92a69f8cd218f' into thread-next

2 years agoMerge branch 'mq-fix-eattr-setting' into thread-next
Maria Matejka [Fri, 9 Sep 2022 11:10:18 +0000 (13:10 +0200)] 
Merge branch 'mq-fix-eattr-setting' into thread-next

2 years agoTable access is now locked.
Maria Matejka [Wed, 7 Sep 2022 11:54:20 +0000 (13:54 +0200)] 
Table access is now locked.

2 years agoTable feed refactoring to allow for locking and unlocking
Maria Matejka [Wed, 7 Sep 2022 18:26:20 +0000 (20:26 +0200)] 
Table feed refactoring to allow for locking and unlocking

2 years agoTable long-locking debug code
Maria Matejka [Wed, 7 Sep 2022 13:06:22 +0000 (15:06 +0200)] 
Table long-locking debug code

2 years agoNext hop updater has its own event
Maria Matejka [Wed, 7 Sep 2022 11:12:44 +0000 (13:12 +0200)] 
Next hop updater has its own event

2 years agoNext hop refactoring to allow for table locking
Maria Matejka [Tue, 6 Sep 2022 17:38:40 +0000 (19:38 +0200)] 
Next hop refactoring to allow for table locking

2 years agoBetter profylaction recursive route loops
Maria Matejka [Fri, 22 Oct 2021 17:43:55 +0000 (19:43 +0200)] 
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.

2 years agoNext hop update triggered at the very end of hostcache update
Maria Matejka [Mon, 5 Sep 2022 10:55:36 +0000 (12:55 +0200)] 
Next hop update triggered at the very end of hostcache update

2 years agoExporter routine refactoring to allow for nicer table locking
Maria Matejka [Mon, 5 Sep 2022 04:58:42 +0000 (06:58 +0200)] 
Exporter routine refactoring to allow for nicer table locking

2 years agoAdded an indirection to the export announcement routine
Maria Matejka [Thu, 1 Sep 2022 09:17:35 +0000 (11:17 +0200)] 
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.

2 years agoROA subscriptions are also converted to export requests.
Maria Matejka [Thu, 1 Sep 2022 08:39:56 +0000 (10:39 +0200)] 
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.

2 years agoFlowspec revalidate notification converted to an export hook
Maria Matejka [Wed, 31 Aug 2022 14:04:36 +0000 (16:04 +0200)] 
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.

2 years agoHostcache update notification converted to an export hook
Maria Matejka [Wed, 31 Aug 2022 12:01:59 +0000 (14:01 +0200)] 
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.

2 years agoMiscellaneous refactoring
Maria Matejka [Wed, 31 Aug 2022 09:58:27 +0000 (11:58 +0200)] 
Miscellaneous refactoring

2 years agoTable debug is now a per-table setting and has categories.
Maria Matejka [Tue, 30 Aug 2022 17:40:58 +0000 (19:40 +0200)] 
Table debug is now a per-table setting and has categories.

2 years agoDefault tables are not created unless actually used.
Maria Matejka [Thu, 1 Sep 2022 12:21:56 +0000 (14:21 +0200)] 
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.

2 years agoTables: Requesting prune only after export cleanup
Maria Matejka [Tue, 30 Aug 2022 16:05:00 +0000 (18:05 +0200)] 
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.

2 years agoMerge branch 'mq-fix-eattr-setting' into backport
Maria Matejka [Thu, 18 Aug 2022 20:07:50 +0000 (22:07 +0200)] 
Merge branch 'mq-fix-eattr-setting' into backport

2 years agoSimplified the protocol hookup code in Makefiles
Maria Matejka [Thu, 18 Aug 2022 16:32:33 +0000 (18:32 +0200)] 
Simplified the protocol hookup code in Makefiles

2 years agoFixed initialization of Linux kernel route attributes
Maria Matejka [Thu, 18 Aug 2022 15:44:00 +0000 (17:44 +0200)] 
Fixed initialization of Linux kernel route attributes

3 years agoMerge branch 'backport' into thread-next
Maria Matejka [Fri, 5 Aug 2022 09:14:33 +0000 (11:14 +0200)] 
Merge branch 'backport' into thread-next

3 years agoMerge commit '082905a8' into thread-next
Maria Matejka [Fri, 5 Aug 2022 09:09:44 +0000 (11:09 +0200)] 
Merge commit '082905a8' into thread-next

3 years agoMerge commit '534d0a4b' into thread-next
Maria Matejka [Fri, 5 Aug 2022 08:37:53 +0000 (10:37 +0200)] 
Merge commit '534d0a4b' into thread-next

3 years agoMerge commit '2e484f8d' into thread-next
Maria Matejka [Fri, 5 Aug 2022 08:31:40 +0000 (10:31 +0200)] 
Merge commit '2e484f8d' into thread-next

3 years agoMerge commit '971721c9' into thread-next
Maria Matejka [Fri, 5 Aug 2022 08:26:13 +0000 (10:26 +0200)] 
Merge commit '971721c9' into thread-next

3 years agoMerge commit '4d48ede5' into thread-next
Maria Matejka [Fri, 5 Aug 2022 07:26:23 +0000 (09:26 +0200)] 
Merge commit '4d48ede5' into thread-next

3 years agoMerge commit 'c7d0c5b2' into thread-next
Maria Matejka [Wed, 3 Aug 2022 18:01:42 +0000 (20:01 +0200)] 
Merge commit 'c7d0c5b2' into thread-next

3 years agoMerge commit '18f66055' into thread-next
Maria Matejka [Wed, 3 Aug 2022 16:00:17 +0000 (18:00 +0200)] 
Merge commit '18f66055' into thread-next

3 years agoMerge commit '038fcf1c' into thread-next
Maria Matejka [Wed, 3 Aug 2022 15:37:16 +0000 (17:37 +0200)] 
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.

3 years agoMerge commit '082905a8' into HEAD
Maria Matejka [Wed, 3 Aug 2022 13:04:42 +0000 (15:04 +0200)] 
Merge commit '082905a8' into HEAD

3 years agorip_rte_better() uses the IGP_METRIC_UNKNOWN instead of protocol-specific infinity
Maria Matejka [Fri, 22 Jul 2022 14:09:37 +0000 (16:09 +0200)] 
rip_rte_better() uses the IGP_METRIC_UNKNOWN instead of protocol-specific infinity

3 years agoMerge commit '97476e00' into thread-next
Maria Matejka [Wed, 3 Aug 2022 12:07:53 +0000 (14:07 +0200)] 
Merge commit '97476e00' into thread-next

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.

3 years agoBGP: The bucket/prefix hashes are now a resource to allow for proper cleanup
Maria Matejka [Wed, 3 Aug 2022 09:57:29 +0000 (11:57 +0200)] 
BGP: The bucket/prefix hashes are now a resource to allow for proper cleanup

3 years agoMerge commit 'f0507f05ce57398e135651896dace4cb68eeed54' into thread-next
Maria Matejka [Tue, 2 Aug 2022 20:08:59 +0000 (22:08 +0200)] 
Merge commit 'f0507f05ce57398e135651896dace4cb68eeed54' into thread-next

3 years agoMerge branch 'ballygarvan' into HEAD
Maria Matejka [Tue, 2 Aug 2022 15:58:14 +0000 (17:58 +0200)] 
Merge branch 'ballygarvan' into HEAD

Replacing the old 3.0-alpha0 cork mechanism with another one inside the
routing table. This version should be simpler and also quite clear what
it does, why and when.

3 years agoRevert "Split route table event into separate events"
Maria Matejka [Tue, 2 Aug 2022 15:55:50 +0000 (17:55 +0200)] 
Revert "Split route table event into separate events"

This reverts commit 445eeaf3df126af2c7b61e71c4f08a583eb4fa60.

3 years agoRevert "Table cork: Stop creating updates when there are too many pending."
Maria Matejka [Tue, 2 Aug 2022 15:55:47 +0000 (17:55 +0200)] 
Revert "Table cork: Stop creating updates when there are too many pending."

This reverts commit 3b20722a1fc777c27ab2e0451d0ea3fee7fa81a2.

3 years agoAlso next hop update routines are corking themselves when congestion is detected
Maria Matejka [Tue, 2 Aug 2022 15:51:58 +0000 (17:51 +0200)] 
Also next hop update routines are corking themselves when congestion is detected

3 years agoBGP: respecting table cork
Maria Matejka [Tue, 2 Aug 2022 10:54:11 +0000 (12:54 +0200)] 
BGP: respecting table cork

3 years agoRoute table cork: Indicate whether the export queues are congested.
Maria Matejka [Thu, 28 Jul 2022 11:50:59 +0000 (13:50 +0200)] 
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.

3 years agoIntroducing basic RCU primitives for lock-less shared data structures
Maria Matejka [Fri, 12 Nov 2021 21:58:40 +0000 (22:58 +0100)] 
Introducing basic RCU primitives for lock-less shared data structures

3 years agoFixed main birdloop init in unit tests
Maria Matejka [Mon, 1 Aug 2022 13:17:41 +0000 (15:17 +0200)] 
Fixed main birdloop init in unit tests

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.)

3 years agoSending an event must also ping the target IO loop
Maria Matejka [Thu, 28 Jul 2022 17:52:19 +0000 (19:52 +0200)] 
Sending an event must also ping the target IO loop

3 years agoMoved the thread starting code to IO loop code
Maria Matejka [Thu, 28 Jul 2022 17:49:03 +0000 (19:49 +0200)] 
Moved the thread starting code to IO loop code

3 years agoMerge commit '03bf6b90' into thread-next
Maria Matejka [Thu, 28 Jul 2022 17:22:58 +0000 (19:22 +0200)] 
Merge commit '03bf6b90' into thread-next

3 years agoRevert "Adding a generic cork mechanism for events"
Maria Matejka [Thu, 28 Jul 2022 17:22:48 +0000 (19:22 +0200)] 
Revert "Adding a generic cork mechanism for events"

This reverts commit 6e841b3153565632b6753f6b1fe74850c37f2808.

3 years agoMerge branch 'master' into backport
Ondrej Zajicek [Tue, 26 Jul 2022 22:47:24 +0000 (00:47 +0200)] 
Merge branch 'master' into backport

3 years agoNetlink: Restrict route replace for IPv6
Ondrej Zajicek [Tue, 26 Jul 2022 16:45:20 +0000 (18:45 +0200)] 
Netlink: Restrict route replace for IPv6

Seems like the previous patch was too optimistic, as route replace is
still broken even in Linux 4.19 LTS (but fixed in Linux 5.10 LTS) for:

  ip route add 2001:db8::/32 via fe80::1 dev eth0
  ip route replace 2001:db8::/32 dev eth0

It ends with two routes instead of just the second.

The issue is limited to direct and special type (e.g. unreachable)
routes, the patch restricts route replace for cases when the new route
is a regular route (with a next hop address).

3 years agoNetlink: Simplify handling of IPv6 ECMP routes
Ondrej Zajicek [Sun, 24 Jul 2022 22:11:40 +0000 (00:11 +0200)] 
Netlink: Simplify handling of IPv6 ECMP routes

When IPv6 ECMP support first appeared in Linux kernel, it used different
API than IPv4 ECMP. Individual next hops were updated and announced
separately, instead of using RTA_MULTIPATH as in IPv4. This has several
drawbacks and requires complex code to merge received notifications to
one multipath route.

When Linux came with IPv6 RTA_MULTIPATH support, the initial versions
were somewhat buggy, so we kept using the old API for updates (splitting
multipath routes to sequences of route updates), while accepting both
old-style routes and RTA_MULTIPATH routes in scans / notifications.

As IPv6 RTA_MULTIPATH support is here for a long time, this patch fully
switches Netlink to the IPv6 RTA_MULTIPATH API and removes old complex
code for handling individual next hop announces.

The required Linux version is at least 4.11 for reliable operation.

Thanks to Daniel Gröber for the original patch.

3 years agoMerge branch 'master' into backport
Ondrej Zajicek [Sun, 24 Jul 2022 18:08:02 +0000 (20:08 +0200)] 
Merge branch 'master' into backport

3 years agoKRT: Scan routing tables separetely on linux to avoid congestion
Ondrej Zajicek [Sun, 24 Jul 2022 00:15:20 +0000 (02:15 +0200)] 
KRT: Scan routing tables separetely on linux to avoid congestion

Remove compile-time sysdep option CONFIG_ALL_TABLES_AT_ONCE, replace it
with runtime ability to run either separate table scans or shared scan.

On Linux, use separate table scans by default when the netlink socket
option NETLINK_GET_STRICT_CHK is available, but retreat to shared scan
when it fails.

Running separate table scans has advantages where some routing tables are
managed independently, e.g. when multiple routing daemons are running on
the same machine, as kernel routing table modification performance is
significantly reduced when the table is modified while it is being
scanned.

Thanks Daniel Gröber for the original patch and Toke Høiland-Jørgensen
for suggestions.

3 years agoFixed a rarely used part of Babel: comparing two routes in table by their metric
Maria Matejka [Fri, 22 Jul 2022 13:48:20 +0000 (15:48 +0200)] 
Fixed a rarely used part of Babel: comparing two routes in table by their metric

3 years agoRevert "Export table: Delay freeing of old stored route."
Maria Matejka [Fri, 22 Jul 2022 13:37:21 +0000 (15:37 +0200)] 
Revert "Export table: Delay freeing of old stored route."

This reverts commit cee0cd148c9b71bf47d007c850193b5fbf9486c1.
This change is not needed in version 2 and the surrounding code has
disappeared mostly in version 3.

3 years agoEvent lists rewritten to a single linked list
Maria Matejka [Fri, 24 Jun 2022 17:53:34 +0000 (19:53 +0200)] 
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.

3 years agoMerge commit '94eb0858' into thread-next
Maria Matejka [Mon, 18 Jul 2022 10:33:00 +0000 (12:33 +0200)] 
Merge commit '94eb0858' into thread-next

3 years agoMerge commit 'a4451535' into thread-next
Maria Matejka [Mon, 18 Jul 2022 09:11:46 +0000 (11:11 +0200)] 
Merge commit 'a4451535' into thread-next

3 years agoFixed an annoying warning in ea_get_storage()
Maria Matejka [Mon, 18 Jul 2022 08:56:20 +0000 (10:56 +0200)] 
Fixed an annoying warning in ea_get_storage()

3 years agoFixing build issues caused by a nonportable Makefile rule
Maria Matejka [Mon, 18 Jul 2022 08:26:55 +0000 (10:26 +0200)] 
Fixing build issues caused by a nonportable Makefile rule

3 years agoMerge commit 'a845651b' into thread-next
Maria Matejka [Mon, 18 Jul 2022 08:19:59 +0000 (10:19 +0200)] 
Merge commit 'a845651b' into thread-next

3 years agoMerge commit 'c70b3198' into thread-next [lots of conflicts]
Maria Matejka [Fri, 15 Jul 2022 12:57:02 +0000 (14:57 +0200)] 
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.

3 years agoFixed invalid routes handling
Maria Matejka [Thu, 14 Jul 2022 09:09:23 +0000 (11:09 +0200)] 
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.

3 years agoMerge branch 'backport' into thread-next
Maria Matejka [Wed, 13 Jul 2022 12:46:36 +0000 (14:46 +0200)] 
Merge branch 'backport' into thread-next

3 years agoMerge commit '2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f' into thread-next
Maria Matejka [Wed, 13 Jul 2022 12:14:37 +0000 (14:14 +0200)] 
Merge commit '2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f' into thread-next

3 years agoMerge commit 'd429bc5c841a8e9d4c81786973edfa56d20a407e' into thread-next
Maria Matejka [Wed, 13 Jul 2022 10:54:20 +0000 (12:54 +0200)] 
Merge commit 'd429bc5c841a8e9d4c81786973edfa56d20a407e' into thread-next

3 years agoMerge commit '7e9cede1fd1878fb4c00e793bccd0ca6c18ad452' into thread-next
Maria Matejka [Wed, 13 Jul 2022 10:02:34 +0000 (12:02 +0200)] 
Merge commit '7e9cede1fd1878fb4c00e793bccd0ca6c18ad452' into thread-next

3 years agoFixed bug in repeated show route command
Maria Matejka [Wed, 13 Jul 2022 09:19:00 +0000 (11:19 +0200)] 
Fixed bug in repeated show route command

Introduced by 13ef5e53dd4a98c80261139b4c9ce4b1074cac40, the CLI was not
properly cleaned up when the command finished, causing BIRD to not parse
any other command after "show route".

3 years agoMerge commit 'f18968f5' into thread-next
Maria Matejka [Tue, 12 Jul 2022 13:05:04 +0000 (15:05 +0200)] 
Merge commit 'f18968f5' into thread-next

3 years agoBGP: Minor improvements to BGP roles
Ondrej Zajicek [Tue, 12 Jul 2022 13:03:17 +0000 (15:03 +0200)] 
BGP: Minor improvements to BGP roles

Add support for bgp_otc in filters and warning for configuration
inside confederations.

3 years agoMerge commit '1df20989' into thread-next
Maria Matejka [Tue, 12 Jul 2022 12:46:17 +0000 (14:46 +0200)] 
Merge commit '1df20989' into thread-next

3 years agoRevert "Special table hooks rectified."
Maria Matejka [Tue, 12 Jul 2022 12:46:06 +0000 (14:46 +0200)] 
Revert "Special table hooks rectified."

This reverts commit 44f26c49f966ca842ff9af55468de0b98c44b73e.

3 years agoRemoving the rte_modify API
Maria Matejka [Tue, 12 Jul 2022 10:40:18 +0000 (12:40 +0200)] 
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.

3 years agoRoute refresh in tables uses a stale counter.
Maria Matejka [Tue, 12 Jul 2022 08:36:10 +0000 (10:36 +0200)] 
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.

3 years agoBGP: Implement BGP roles
Eugene Bogomazov [Mon, 11 Jul 2022 15:19:34 +0000 (17:19 +0200)] 
BGP: Implement BGP roles

Implement BGP roles as described in RFC 9234. It is  a mechanism for
route leak prevention and automatic route filtering based on common BGP
topology relationships. It defines role capability (controlled by 'local
role' option) and OTC route attribute, which is used for automatic route
filtering and leak detection.

Minor changes done by commiter.

3 years agoThere are now no internal tables at all.
Maria Matejka [Mon, 11 Jul 2022 15:08:59 +0000 (17:08 +0200)] 
There are now no internal tables at all.

3 years agoDropped the internal kernel protocol table for learnt routes.
Maria Matejka [Mon, 11 Jul 2022 15:04:52 +0000 (17:04 +0200)] 
Dropped the internal kernel protocol table for learnt routes.

The learnt routes are now pushed all into the connected table, not only
the best one. This shouldn't do any damage in well managed setups, yet
it should be noted that it is a change of behavior.

If anybody misses a feature which they implemented by misusing this
internal learn table, let us know, we'll consider implementing it in a
better way.

3 years agoExport tables merged with BGP prefix hash
Maria Matejka [Mon, 20 Jun 2022 17:10:49 +0000 (19:10 +0200)] 
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.

3 years agoHash: iterable now per partes by an iterator
Maria Matejka [Wed, 29 Jun 2022 11:22:40 +0000 (13:22 +0200)] 
Hash: iterable now per partes by an iterator

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.

3 years agoDo not try to check flowspec validity for piped routes
Maria Matejka [Wed, 29 Jun 2022 10:51:07 +0000 (12:51 +0200)] 
Do not try to check flowspec validity for piped routes

3 years agoFixed bad import table attributes freeing
Maria Matejka [Tue, 28 Jun 2022 10:57:18 +0000 (12:57 +0200)] 
Fixed bad import table attributes freeing

3 years agoAttribute lists split to storage headers and data to save BGP memory
Maria Matejka [Tue, 28 Jun 2022 08:51:00 +0000 (10:51 +0200)] 
Attribute lists split to storage headers and data to save BGP memory

3 years agoShow route uses the export request also for one-net queries
Maria Matejka [Mon, 27 Jun 2022 17:53:06 +0000 (19:53 +0200)] 
Show route uses the export request also for one-net queries

3 years agoAdded forgotten route source locking in flowspec validation
Maria Matejka [Mon, 11 Jul 2022 11:04:01 +0000 (13:04 +0200)] 
Added forgotten route source locking in flowspec validation

3 years agoMerge remote-tracking branch 'origin/master' into backport
Maria Matejka [Mon, 11 Jul 2022 09:08:10 +0000 (11:08 +0200)] 
Merge remote-tracking branch 'origin/master' into backport

3 years agoMerge commit 'beb5f78a' into backport
Maria Matejka [Mon, 11 Jul 2022 08:41:17 +0000 (10:41 +0200)] 
Merge commit 'beb5f78a' into backport

3 years agoMerge version 2.0.10 into backport
Maria Matejka [Sun, 10 Jul 2022 12:19:24 +0000 (14:19 +0200)] 
Merge version 2.0.10 into backport