0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00
bird/nest
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
..
bfd.h BFD: Allow per-request session options 2020-11-08 15:33:22 +01:00
bird.h Enforcing certain data structure explicit paddings. 2022-05-04 15:37:41 +02:00
cli.c The show-route CLI command now uses the route export API 2022-06-27 12:32:47 +02:00
cli.h The show-route CLI command now uses the route export API 2022-06-27 12:32:47 +02:00
cmds.c Conf: Symbols are properly scoped 2022-05-04 15:38:42 +02:00
cmds.h Filter refactoring: dropped the recursion from the interpreter 2019-02-20 22:30:54 +01:00
config.Y Export tables merged with BGP prefix hash 2022-07-11 16:07:09 +02:00
Doc Doc: Rename code documentation files back to Doc 2018-12-14 02:03:42 +01:00
iface.c Nest: Do not ignore secondary flag changes in ifa updates 2021-12-18 01:09:52 +01:00
iface.h Nest: Fix neighbor handling for colliding ranges 2020-05-11 04:29:36 +02:00
limit.h Limit containment 2021-11-09 19:20:41 +01:00
locks.c Lib: Add and use ev_new_init() 2018-10-01 15:55:23 +02:00
locks.h Nest: VRF support for neighbor cache and olock code 2017-09-12 15:49:36 +02:00
Makefile Enforcing certain data structure explicit paddings. 2022-05-04 15:37:41 +02:00
neighbor.c Slab allocator can free the blocks without knowing the parent structure 2022-04-06 18:14:08 +02:00
password.c Nest: Allow MAC algorithms to specify min/max key length 2021-06-06 16:28:18 +02:00
password.h Nest: Allow MAC algorithms to specify min/max key length 2021-06-06 16:28:18 +02:00
proto-hooks.c Dropping rte-local dumper entries 2021-10-13 19:09:05 +02:00
proto.c Export tables merged with BGP prefix hash 2022-07-11 16:07:09 +02:00
proto.sgml Channels - explicit links between protocols and tables 2016-02-01 10:28:50 +01:00
protocol.h Export tables merged with BGP prefix hash 2022-07-11 16:07:09 +02:00
rt-attr.c Export tables merged with BGP prefix hash 2022-07-11 16:07:09 +02:00
rt-dev.c Merge commit '938742decc6e1d6d3a0375dd012b75172e747bbc' into haugesund 2022-06-08 15:31:28 +02:00
rt-dev.h Nest: SADR support for Direct 2018-03-18 02:56:51 +01:00
rt-fib.c Splitting route data structures out to lib 2022-05-04 15:37:41 +02:00
rt-show.c Route refresh in tables uses a stale counter. 2022-07-12 12:22:41 +02:00
rt-table.c Route refresh in tables uses a stale counter. 2022-07-12 12:22:41 +02:00
rt.h Route refresh in tables uses a stale counter. 2022-07-12 12:22:41 +02:00