0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 12:18:42 +00:00
Commit Graph

4052 Commits

Author SHA1 Message Date
Maria Matejka
8ac15bf7a4 Filter: Methods rework
Methods can now be called as x.m(y), as long as x can have its type
inferred in config time. If used as a command, it modifies the object,
if used as a value, it keeps the original object intact.

Also functions add(x,y), delete(x,y), filter(x,y) and prepend(x,y) now
spit a warning and are considered deprecated.

It's also possible to call a method on a constant, see filter/test.conf
for examples like bgp_path = +empty+.prepend(1).

Inside instruction definitions (filter/f-inst.c), a METHOD_CONSTRUCTOR()
call is added, which registers the instruction as a method for the type
of its first argument. Each type has its own method symbol table and
filter parser switches between them based on the inferred type of the
object calling the method.

Also FI_CLIST_(ADD|DELETE|FILTER) instructions have been split to allow
for this method dispatch. With type inference, it's now possible.
2024-05-30 12:30:00 +02:00
Maria Matejka
44bac39361 Uninitialized filter variables of path/[el]?clist types are now explicitly empty 2024-05-30 12:30:00 +02:00
Maria Matejka
9bdc769851 Conf: config warnings show the file position 2024-05-30 12:30:00 +02:00
Maria Matejka
79468e7c19 Filter: functions can and should have typed return values 2024-05-30 12:30:00 +02:00
Maria Matejka
ee4fbcf5dc GitLab: Disabling build for CentOS 7 and Ubuntu 14.04 as our build machines don't like C11 2024-05-30 12:30:00 +02:00
Maria Matejka
c0c695c761 Filter/Conf: Method names have their own keyword hash
To allow for future dynamic method definition, parsing method names is
done via a dedicated keyword hash/scope.
2024-05-30 12:30:00 +02:00
Maria Matejka
ab785d1ec4 Conf: Allowing conf scope to be explicitly read only 2024-05-30 12:30:00 +02:00
Maria Matejka
0323471062 Conf: Symbol manipulation gets its context explicitly 2024-05-30 12:30:00 +02:00
Maria Matejka
f88583b903 Filter: any lvalue can get its methods called 2024-05-30 12:30:00 +02:00
Maria Matejka
7b65343937 Filter: split out dot-notation methods to separate targets
This is just a preparationary refactoring to allow type-based method
tables.
2024-05-30 12:30:00 +02:00
Maria Matejka
7e6a8392ce Conf: Keywords have their default symbols
This avoids unnecessary collapsed soft scopes caused by keyword symbol multiallocation.
2024-05-30 12:30:00 +02:00
Maria Matejka
51e8996fff 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.

The redefinable keywords must be specified in any .Y file as follows:

  toksym: THE_KEYWORD ;
2024-05-30 12:30:00 +02:00
Maria Matejka
4938c122dc Dropping empty-type const f_vals, they were copied anyway 2024-05-30 12:30:00 +02:00
Maria Matejka
4167635b79 Conf: Adding dummy thread-number setting for easier sharing of configuration between v2 and v3 2024-05-30 12:30:00 +02:00
Ondrej Zajicek
7b3b8a8949 Babel: Minor changes to RTT formatting
Use existing %t printf code and move 'ms' in CLI output to table header.
2024-05-30 12:30:00 +02:00
Toke Høiland-Jørgensen
ed3b730ac3 Babel: Add support for the RTT extension
This adds support to the Babel protocol for the RTT extension specified
in draft-ietf-babel-rtt-extension. While this extension is not yet at the
RFC stage, it is one of the more useful extensions to Babel[0], so it
seems worth having in Bird as well.

The extension adds timestamps to Hello and IHU TLVs and uses these to
compute an RTT to each neighbour. An extra per-neighbour cost is then
computed from the RTT based on a minimum and maximum interval and cost
value specified in the configuration. The primary use case for this is
improving routing in a geographically distributed tunnel-based overlay
network.

The implementation follows the babeld implementation when picking
constants and default configuration values. It also uses the same RTT
smoothing algorithm as babeld, and follows it in adding a new 'tunnel'
interface type which enables RTT by default.

[0] https://alioth-lists.debian.net/pipermail/babel-users/2022-April/003932.html
2024-05-30 12:30:00 +02:00
Toke Høiland-Jørgensen
7176f62788 IO: Add current_time_now() function for immediate timestamp
Add a current_time_now() function which gets an immediate monotonic
timestamp instead of using the cached value from the event loop. This is
useful for callers that need precise times, such as the Babel RTT
measurement code.

Minor changes by committer.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
d7163f6427 BGP: Fix role check when no capability option is present
When an OPEN message without capability options was parsed, the remote
role field was not initialized with the proper (non-zero) default value,
so it was interpreted as if 'provider' was announced.

Thanks to Mikhail Grishin for the bugreport.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
104fc34f94 Lib: Improve IP/net hashing
Backport some changes from branch oz-parametric-hashes. Replace naive
hash function for IPv6 addresses, fix hashing of VPNx (where upper half
of RD was ignored), fix hashing of MPLS labels (where identity was used).
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
6c2979f4d0 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
d44409f0c0 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
3aef1bc7fc Conf: Fix symbol lookup
The symbol table used just symbol name as a key, and used a trick with
active flag to find symbols in active scopes with one hash table lookup.

The disadvantage is that it can degenerate to O(n) for negative queries
in situations where are many symbols with the same name in different
scopes.

Thanks to Yanko Kaneti for the bugreport.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
220c0e548a NEWS and version update 2024-05-30 12:30:00 +02:00
Ondrej Zajicek
7e901192ed Filter: Disable some trie formatting tests
Trie formatting works slightly different with 4-way tries than with
16-way ones, so these tests generated false error. Block them for now.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
14135e6aba BMP: Add some basic documentation 2024-05-30 12:30:00 +02:00
Ondrej Zajicek
57da33172c BMP: Silence some log messages
Hooks called from BGP to BMP should not log warning when BMP is not
connected, that is not an error (and we do not want to flood logs with
a ton of messages).

Blocked sk_send() should not log warning, that is expected situation.
Error during sk_send() is handled in error hook anyway.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
8f78c232f6 BMP: Fix connection management
Replace broken TCP connection management with a simple state machine.
Handle failed attempts properly with a timeout, detect and handle TCP
connection close and try to reconnect after that. Remove useless
'station_connected' flag.

Keep open messages saved even after the BMP session establishment,
so they can be used after BMP session flaps.

Use proper log messages for session events.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
62aa714175 BMP: Fix reconfiguration
It is not supported, but at least it must update internal config
pointer to not keep old one.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
2f62d91b61 BMP: Allow build without BMP and disable BMP build by default
It has still several important issues to be enabled by default.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
f965e12d07 BMP: Move initialization to bmp_start()
That fixes BMP socket allocation from an invalid pool.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
549d8a991d BMP: Fix missing template
It is mandatory for protocol.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
106d206728 BMP: Add some missing bmp_buffer_free() calls
They were inadvertently removed during recent code refactoring.

Thanks to Dawid Macek for the bugreport and patch.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
9a9752bfbe BMP: Remove duplicate functions for update encoding
Use existing BGP functions also for BMP update encoding.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
e7789317b2 BMP: Integrate bmp_conn to bmp_proto
There is only one socket per BMP instance, no need to have separate
struct (like in BGP).
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
767c820e57 BMP: Minor cleanups
Remove redundant 'disable' option, simplify IP address serialization,
and remove useless macros.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
3ab2dd3fd3 BMP: Do not use global instance ptr internally
Use local variable to refence relevant instance instead of using global
instance ptr. Also, use 'p' variable instead of 'bmp' so we can use
common macros like TRACE().
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
43b3ea8c64 BMP: Remove superfluous error handling
Most error handling code was was for cases that cannot happen,
or they would be code bugs (and should use ASSERT()). Keep error
handling for just for I/O errors, like in rest of BIRD.
2024-05-30 12:30:00 +02:00
Pawel Maslanka
25598fdf11 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.
2024-05-30 12:30:00 +02:00
Luiz Amaral
655f761d9c BSD: IPv4 over IPv6 nexthop support on FreeBSD
The support for IPv4 routes with IPv6 nexthops was implemented in FreeBSD
13.1, this patch allows to import and export such routes from/to kernel.

Minor change from committer.
2024-05-30 12:30:00 +02:00
Maria Matejka
842c841c76 Linpool: Fix lp_restore()
When lp_save() is called on an empty linpool, then some allocation is
done, then lp_restore() is called, the linpool is restored but the used
chunks are inaccessible. Fix it.
2024-05-30 12:30:00 +02:00
Trisha Biswas
67d412fe1a BGP: Add 'allow bgp_med' option for EBGP sessions
This option allows to treat bgp_med as regular transitive attribute
on EBGP sessions (without hacks in filters).

Minor changes from committer.
2024-05-30 12:30:00 +02:00
Jakub Ružička
cfb65742a4 Increase tests timeout
Tests may take longer than 5 s to complete on slow/virtual machines.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
f6e421a2d3 BGP: Fix bgp_med handling
Missing translation from BGP attribute ID to eattr ID in bgp_unset_attr()
broke automatic removal of bgp_med during export to EBGP peers.

Thanks to Edward Sun for the bugreport.
2024-05-30 12:30:00 +02:00
Johannes Moos
06b713c273 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.
2024-05-30 12:30:00 +02:00
Maria Matejka
d14fd36d76 BGP: Free bind applies also to outbound connections
Even though the free bind option is primarily meant to alleviate problems
with addresses assigned too late, it's also possible to use BIRD with AnyIP
configuration, assigning whole ranges to the machine. Therefore free bind
allows also to create an outbound connection from specific address even though
such address is not assigned.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
c6d16e2ccc Net: Replace runtime checks with STATIC_ASSERT() 2024-05-30 12:30:00 +02:00
Petr Vaněk
64819e8618 Printf test suite fails on systems with musl libc because tests for "%m"
and "%M" formats expect "Input/output error" message but musl returns
"I/O error". Proposed change compares the printf output with string
returned from strerror function for EIO constant.

See-also: https://bugs.gentoo.org/836713

Minor change from committer.
2024-05-30 12:30:00 +02:00
Maria Matejka
2458eed36c Config: Dropping filter instruction trees after linearization 2024-05-30 12:30:00 +02:00
Maria Matejka
80474b62d7 Linpool flush drops all the allocated pages but one
When a linpool is used to allocate a one-off big load of memory, it
makes no sense to keep that amount of memory for future use inside the
linpool. Contrary to previous implementations where the memory was
directly free()d, we now use the page allocator which has an internal
cache which keeps the released pages for us and subsequent allocations
simply get these released pages back.

And even if the page cleanup routine kicks in inbetween, the pages get
only madvise()d, not munmap()ed so performance aspects are negligible.

This may fix some memory usage peaks in extreme cases.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
0cd944f119 BGP: Update RFC references 2024-05-30 12:30:00 +02:00