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

590 Commits

Author SHA1 Message Date
Ondrej Zajicek
a5b4c21d81 Filter: Silence some warnings in clang 2024-05-30 02:40:55 +02:00
Maria Matejka
bc10975adb ASPA: checks done in filters; no autoreload yet 2024-03-25 14:15:30 +01:00
Ondrej Zajicek
114be2af28 Filter: Add route attribute gw_mpls_stack
Add route attribute gw_mpls_stack to make MPLS stack of route nexthop
accessible from filters. Its type is T_CLIST, which is really not correct
(as it is a list, while T_CLIST is a set). Therefore, we keep this
attribute *undocumented* and it will be *changed* without further notice.

Based on a patch from Trisha Biswas <tbiswas@fastly.com>, thanks!
2024-03-05 16:47:08 +01:00
Ondrej Zajicek
224a152c53 Filter: Add support for string route attribute 2024-02-14 14:29:19 +01:00
Katerina Kubecova
472be46f7a Filter: Tests for net_addr
Minor changes by committer.
2024-01-22 07:08:11 +01:00
Ondrej Zajicek
57aa077227 BGP: Improve custom BGP attributes
- Implement EA_GET for custom BGP attributes
 - Forbid EA_SET on existing opaque attributes
 - Forbid redefining existing attributes
 - Document possible compatibility problems
2023-10-05 21:54:25 +02:00
Ondrej Zajicek
de09fda5dc Filter: Fix scope handling in for loops
Changes in scope implementation broke scope handling in for loops.
The term in for loops is supposed to be parsed in the parent scope.
2023-10-05 14:26:22 +02:00
Maria Matejka
d41b06238d Filter: explicitly forbidden for-loop with pre-defined variable 2023-10-04 19:57:55 +02:00
Ondrej Zajicek
bcff3ae79a L3VPN: BGP/MPLS VPNs using MPLS backbone
The L3VPN protocol implements RFC 4364 BGP/MPLS VPNs using MPLS backbone.
It works similarly to pipe. It connects IP table (one per VRF) with (global)
VPN table. Routes passed from VPN table to IP table are stripped of RD and
filtered by import targets, routes passed in the other direction are extended
with RD, MPLS labels and export targets in extended communities. A separate
MPLS channel is used to announce MPLS routes for the labels.
2023-10-04 13:07:28 +02:00
Ondrej Zajicek
333ddd4f98 MPLS subsystem
The MPLS subsystem manages MPLS labels and handles their allocation to
MPLS-aware routing protocols. These labels are then attached to IP or VPN
routes representing label switched paths -- LSPs.

There was already a preliminary MPLS support consisting of MPLS label
net_addr, MPLS routing tables with static MPLS routes, remote labels in
next hops, and kernel protocol support.

This patch adds the MPLS domain as a basic structure representing local
label space with dynamic label allocator and configurable label ranges.
To represent LSPs, allocated local labels can be attached as route
attributes to IP or VPN routes with local labels as attributes.

There are several steps for handling LSP routes in routing protocols --
deciding to which forwarding equivalence class (FEC) the LSP route
belongs, allocating labels for new FECs, announcing MPLS routes for new
FECs, attaching labels to LSP routes. The FEC map structure implements
basic code for managing FECs in routing protocols, therefore existing
protocols can be made MPLS-aware by adding FEC map and delegating
most work related to local label management to it.
2023-10-04 13:01:21 +02:00
Igor Putovny
977b82fba4 Basic route aggregation
Add a new protocol offering route aggregation.

User can specify list of route attributes in the configuration file and
run route aggregation on the export side of the pipe protocol. Routes are
sorted and for every group of equivalent routes new route is created and
exported to the routing table. It is also possible to specify filter
which will run for every route before aggregation.

Furthermore, it will be possible to set attributes of new routes
according to attributes of the aggregated routes.

This is a work in progress.

Original work by Igor Putovny, subsequent cleanups and finalization by
Maria Matejka.
2023-09-26 15:46:24 +02:00
Maria Matejka
0a729b509c Simple testing of reconfiguration to a slightly different one 2023-09-24 15:40:18 +02:00
katerina.kubecova
a0fb0eaa67 BGP: Setting and unsetting unknown attributes
All these must be declared as bytestring. Allows operators to delete
unwanted attributes breaking the Internet:

    https://blog.benjojo.co.uk/post/bgp-path-attributes-grave-error-handling
2023-09-20 14:15:18 +02:00
katerina.kubecova
cc122bf0c2 Attributes declared in config can be bytestrings 2023-09-20 14:03:41 +02:00
katerina.kubecova
8cc9d198c7 Filter: Function unset() accepts attributes declared in config 2023-09-20 14:03:18 +02:00
katerina.kubecova
bb8e28248b Structures bytestring and adata merged into adata. 2023-09-20 14:03:05 +02:00
Ondrej Zajicek
a3dc26455d Filter: Use common initializer for undefined variables and eattrs.
Undefined paths and clists should use typed f_val with empty adata
instead of just void f_val. Use common initializer to handle both
variables and eattrs.
2023-09-13 06:21:26 +02:00
Ondrej Zajicek
7395b97daf Filter: Minor updates to methods
Remove warning when function-like syntax is used for calling
add/remove/... methods.

Fix argument offset in error messages for function-like syntax.
2023-09-12 18:44:20 +02:00
Ondrej Zajicek
132f1edaf4 Filter: Split clist add/delete operations to multiple methods 2023-09-12 16:33:59 +02:00
Ondrej Zajicek
f0d1396073 Filter: Implement constant promotion for multiple dispatch methods 2023-09-12 16:33:59 +02:00
Ondrej Zajicek
e886959131 Filter: Print proper error response in multiple method dispatch
When no matching method is found, print an error response containing
position and type of infringing argument and a set of expected types.
2023-09-12 16:33:59 +02:00
Ondrej Zajicek
e4ce88cc50 Filter: Move argument list reversal from function_call to var_list
List of arguments for function calls is constructed in reverse and then
reverted. This was done in function_call grammar rule. Do the reverse
directly in var_list grammar rule. This fixes reverse order of arguments
in method calls.
2023-09-12 16:33:54 +02:00
Ondrej Zajicek
fc4398b4e1 Filter: Better syntax for function return types
The C-style syntax does not really fit into rest of our syntax.
2023-09-12 16:31:52 +02:00
Ondrej Zajicek
cc1099a041 Filter: Implement multiple dispatch for methods
- Extend method descriptors with type signature
 - Daisy chain method descriptors for the same symbol
 - Dispatch methods for same symbol based on type signature
 - Split add/delete/filter operations to multiple methods
 - Replace ad-hoc dispatch of old-style syntax with scope-based dispatch
 - Also change method->arg_num to count initial arg

It still needs some improvements, like better handling of untyped
expressions and better error reporting when no dispatch can be done.

The multiple dispatch could also be extended to dispatch regular
function-like expressions in a uniform way.
2023-09-12 16:31:52 +02:00
Ondrej Zajicek
c696e3cb8e Filter: Make f_method_call_*() usage symmetric 2023-09-12 16:31:52 +02:00
Ondrej Zajicek
ab61476ebf Filter: Convert more methods to use METHOD_R() 2023-09-12 16:31:52 +02:00
Ondrej Zajicek
4cdd6f2ea0 Filter: Remove number of args from METHOD_R()
Macro METHOD_R() is used for simplest methods, there is no place to
define argument types, so let's force it to be 0.
2023-09-12 16:31:52 +02:00
Maria Matejka
fdd39c81bd Filter: Print instructions take only one value (simplification) 2023-09-12 16:30:08 +02:00
Maria Matejka
6d411fc7bd Filter: Shortened method declarations 2023-09-12 16:20:25 +02:00
Maria Matejka
21faa54ec3 Filter: The for loop uses the method system for type dispatch 2023-09-12 16:20:25 +02:00
Maria Matejka
1d38726c64 Removing unused terminals from filter config 2023-09-12 16:20:25 +02:00
Maria Matejka
fc9d471b36 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.
2023-09-12 16:19:33 +02:00
Maria Matejka
39f8f46d81 Uninitialized filter variables of path/[el]?clist types are now explicitly empty 2023-09-12 16:10:42 +02:00
Maria Matejka
062ff65683 Filter: functions can and should have typed return values 2023-09-12 15:58:07 +02:00
Maria Matejka
f86c86b791 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.
2023-09-12 15:47:24 +02:00
Maria Matejka
51f2e7afaf Conf: Symbol manipulation gets its context explicitly 2023-09-12 15:36:46 +02:00
Maria Matejka
5951dfbd5e Filter: any lvalue can get its methods called 2023-09-12 15:27:46 +02:00
Maria Matejka
ae8ecafda9 Filter: split out dot-notation methods to separate targets
This is just a preparationary refactoring to allow type-based method
tables.
2023-09-12 15:27:43 +02:00
Maria Matejka
8e177cf35b 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.
2023-09-12 15:20:50 +02:00
Maria Matejka
a5a6de581b Dropping empty-type const f_vals, they were copied anyway 2023-09-12 14:53:55 +02:00
Ondrej Zajicek
f5140d1027 Conf: Allow keywords to be redefined by user symbols
Most syntactic constructs in BIRD configuration (e.g. protocol options)
are defined as keywords, which are distinct from symbols (user-defined
names for protocols, variables, ...). That may cause backwards
compatibility issue when a new feature is added, as it may collide with
existing user names.

We can allow keywords to be shadowed by symbols in almost all cases to
avoid this issue.

This replaces the previous mechanism, where shadowable symbols have to be
explictly added to kw_syms.
2023-08-25 23:50:44 +02:00
Ondrej Zajicek
cce48c6cdd Filter: Add separate instruction for uninitialized variable declaration
The previous approach (use VOID constant for variable initialization)
failed due to dynamic type check failure.

Thanks to Alexander Zubkov <green@qrator.net> for the bugreport.
2023-08-25 23:14:36 +02:00
Alexander Zubkov
0dbcc92726 Filter: Use more generic approach for intra-config expressions
Replace f_eval_int() function with a type-generic variant: cf_eval().
Implement similar fuction: cf_eval_int() via inline call to cf_eval().
2023-08-24 04:45:55 +02:00
Alexander Zubkov
fc3547880a Filter: Add bytestring type
- Rename BYTESTRING lexem to BYTETEXT, not to collide with 'bytestring' type name
 - Add bytestring type with id T_BYTESTRING (0x2c)
 - Add from_hex() filter function to create bytestring from hex string
 - Add filter test cases for bytestring type

Minor changes by committer.
2023-08-24 04:33:33 +02:00
Maria Matejka
5f2ecb2298 Merge tag 'v2.13.1' 2023-06-22 17:25:18 +02:00
Maria Matejka
1499a335f6 Filter: Fixed segfault when a case option had an empty block
Thanks to Kobayashi_Bairuo <noc@tohunet.com> for reporting.
2023-06-22 16:12:17 +02:00
Ondrej Zajicek
3cf91fb9eb 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.
2023-05-16 13:25:48 +02:00
Ondrej Zajicek
1a1e13cc2f 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.
2023-04-21 19:31:16 +02:00
Maria Matejka
2f080b5432 Config: Dropping filter instruction trees after linearization 2023-02-22 14:54:09 +01:00
Maria Matejka
3186ffe797 Added test case for switch bug fixed in e20bef69cc 2023-01-22 12:55:31 +01:00