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

81 Commits

Author SHA1 Message Date
Ondrej Zajicek
5d5c431a3c Merge commit '0b684a43bd7ce4a32c9cd7754b88286bcd1815bb' into thread-next 2024-04-01 18:24:10 +02:00
Ondrej Zajicek
f27d1bae0f Merge commit '26dd61ee7f91c15157601b2404de5b6500a6061c' into thread-next 2024-04-01 03:01:59 +02:00
Ondrej Zajicek
46a4932574 Merge commit '44e351d1522f0099687aac9fd65dcea73a04af43' 2024-03-21 15:58:52 +01:00
Job Snijders
e2728c8078 RPKI: Add 'local address' configuration option
Allow to explicitly configure the source IP address for RPKI-To-Router
sessions. Predictable source addresses are useful for minimizing the
holes to be poked in ACLs.

Changed from 'source address' to 'local address' by committer.
2024-02-22 14:58:29 +01:00
Maria Matejka
44e351d152 RPKI: retry timer doesn't reset connections when more data is pending
With very busy deployments, RPKI may kill cache connection too early.
Instead of that, we want it to keep loading if any data is waiting to
be read and the reason for delay is just our congestion.

Also, when we kill the session because of actually slow cache, we want
to reload from scratch as the data we have is unreliable and nobody
knows whether the state is still valid.
2023-12-20 11:58:07 +01:00
Maria Matejka
ddf698ec99 Renamed nest/rt.h back to nest/route.h
Some [redacted] (yes, myself) had a really bad idea
to rename nest/route.h to nest/rt.h while refactoring
some data structures out of it.

This led to unnecessarily complex problems with
merging updates from v2. Reverting this change
to make my life a bit easier.

At least it needed only one find-sed command:

    find -name '*.[chlY]' -type f -exec sed -i 's#nest/rt.h#nest/route.h#' '{}' +
2023-10-29 16:29:26 +01:00
Maria Matejka
7efa3bac4f Merge commit 'cce48c6c' into thread-next 2023-10-13 14:02:21 +02:00
Maria Matejka
e65a5257b2 Protocols have now assigned startup phases
For now, there are 4 phases: Necessary (device), Connector (kernel, pipe), Generator (static, rpki) and Regular.
Started and reconfigured are from Necessary to Regular, shutdown backwards.

This way, kernel can flush routes before actually being shutdown.
2023-09-24 23:23:08 +02:00
Ondrej Zajicek
116285f2b0 RPKI: Fix conflict in config grammar 2023-08-25 04:32:01 +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
b3f805ce29 Socket closing has its dedicated function 2023-04-22 20:48:42 +02:00
Maria Matejka
836e857b30 Sockets: Unified API for main and other loops
Now sk_open() requires an explicit IO loop to open the socket in. Also
specific functions for socket RX pause / resume are added to allow for
BGP corking.

And last but not least, socket reloop is now synchronous to resolve
weird cases of the target loop stopping before actually picking up the
relooped socket. Now the caller must ensure that both loops are locked
while relooping, and this way all sockets always have their respective
loop.
2023-04-04 17:00:59 +02: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
Maria Matejka
34e803c6c3 Merge commit '54430df9' into thread-next 2022-11-07 10:09:01 +01:00
Maria Matejka
605ff0a0eb RPKI: wait for retry_time if we get error immediately after connected 2022-10-03 17:09:02 +02:00
Maria Matejka
7901c40500 Merge commit '3fd1f461' into thread-next
closes #16
closes #17
closes #18
2022-09-26 12:21:33 +02:00
Maria Matejka
26bfd4cc03 Merge commit 'd2c1036a42881d413ec97203ede92a69f8cd218f' into thread-next 2022-09-09 13:15:50 +02:00
Maria Matejka
dc28c6ed1c Simplified the protocol hookup code in Makefiles 2022-08-18 22:07:30 +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
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
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
5051e3c4af Merge commit '17f91f9e6e70f7e3f29502e854823c0d48571eaa' into haugesund 2022-05-30 16:59:24 +02:00
Maria Matejka
b3649ec77e Merge commit 'ef6a903e6f44b467f9606018446095521ad01ef1' into haugesund 2022-05-30 16:20:35 +02:00
Maria Matejka
45af19dd99 Merge commit '652be92a21f5575e5f74f6abe98eb4200b86776c' into haugesund 2022-05-30 15:36:54 +02:00
Maria Matejka
d7b077f5d6 Merge commit '4a23ede2b056a41456790cc20a0c3d92a7137693' into haugesund 2022-05-30 15:31:19 +02:00
Maria Matejka
652be92a21 Merge remote-tracking branch 'origin/master' into haugesund-to-2.0 2022-05-30 15:20:21 +02:00
Maria Matejka
938742decc Squashing the route attribute structure into one level.
For now, all route attributes are stored as eattrs in ea_list. This
should make route manipulation easier and it also allows for a layered
approach of route attributes where updates from filters will be stored
as an overlay over the previous version.
2022-05-30 14:39:09 +02:00
Maria Matejka
950775f6fa Route destination field merged with nexthop attribute; splitting flowspec validation result out.
As there is either a nexthop or another destination specification
(or othing in case of ROAs and Flowspec), it may be merged together.
This code is somehow quirky and should be replaced in future by better
implementation of nexthop.

Also flowspec validation result has its own attribute now as it doesn't
have anything to do with route nexthop.
2022-05-30 14:39:09 +02:00
Ondrej Zajicek
7bb06b34a1 RPKI: Display cache server port on show protocol
Thanks to Luiz Amaral for the idea.
2022-05-21 16:03:08 +02:00
Luiz Amaral
9a9439d5e1 RPKI: Implement VRF support 2022-05-19 19:43:59 +02:00
Maria Matejka
1c30b689dd Moved route source attribute (RTS_*) to eattrs 2022-05-04 15:39:53 +02:00
Maria Matejka
702c04fbef Removing the route scope attribute. Use custom attributes instead.
The route scope attribute was used for simple user route marking. As
there is a better tool for this (custom attributes), the old and limited
way can be dropped.
2022-05-04 15:39:21 +02:00
Maria Matejka
337c04c45e Moved route preference to eattrs 2022-05-04 15:39:21 +02:00
Maria Matejka
17f91f9e6e Explicit definition structures of route attributes
Changes in internal API:

* Every route attribute must be defined as struct ea_class somewhere.
* Registration of route attributes known at startup must be done by
  ea_register_init() from protocol build functions.
* Every attribute has now its symbol registered in a global symbol table
  defined as SYM_ATTRIBUTE
* All attribute ID's are dynamically allocated.
* Attribute value custom formatting hook is defined in the ea_class.
* Attribute names are the same for display and filters, always prefixed
  by protocol name.

Also added some unit testing code for filters with route attributes.
2022-05-04 15:39:19 +02:00
Maria Matejka
ef6a903e6f Splitting route data structures out to lib 2022-05-04 15:37:41 +02:00
Maria Matejka
4a23ede2b0 Protocols have their own explicit init routines 2022-04-06 18:14:08 +02:00
Maria Matejka
41572e0c1b Merge commit 'f81702b7' into haugesund 2022-03-09 15:03:48 +01:00
Maria Matejka
92b832380d Merge commit '1b9189d5' into haugesund 2022-03-09 13:13:05 +01:00
Maria Matejka
83d9920f90 Merge commit '5cff1d5f' into haugesund
Conflicts:
      proto/bgp/attrs.c
      proto/pipe/pipe.c
2022-03-09 10:56:06 +01:00
Job Snijders
b9f38727a7 RPKI: Add contextual out-of-bound checks in RTR Prefix PDU handler
RFC 6810 and RFC 8210 specify that the "Max Length" value MUST NOT be
less than the Prefix Length element (underflow). On the other side,
overflow of the Max Length element also is possible, it being an 8-bit
unsigned integer allows for values larger than 32 or 128. This also
implicitly ensures there is no overflow of "Length" value.

When a PDU is received where the Max Length field is corrputed, the RTR
client (BIRD) should immediately terminate the session, flush all data
learned from that cache, and log an error for the operator.

Minor changes done by commiter.
2021-12-18 16:35:28 +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
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
Maria Matejka
f81702b7e4 Table import and export are now explicit hooks.
Channels have now included rt_import_req and rt_export_req to hook into
the table instead of just one list node. This will (in future) allow for:

* channel import and export bound to different tables
* more efficient pipe code (dropping most of the channel code)
* conversion of 'show route' to a special kind of export
* temporary static routes from CLI

The import / export states are also updated to the new algorithms.
2021-11-22 18:33:53 +01:00
Maria Matejka
69d1ffde4c Split route data structure to storage (ro) / manipulation (rw) structures.
Routes are now allocated only when they are just to be inserted to the
table. Updating a route needs a locally allocated route structure.
Ownership of the attributes is also now not transfered from protocols to
tables and vice versa but just borrowed which should be easier to handle
in a multithreaded environment.
2021-11-09 19:20:41 +01:00
Maria Matejka
46739f007a RPKI: Do nothing when protocol is stopping 2021-11-09 19:20:41 +01:00