584 Commits
Author SHA1 Message Date
Ondrej ZajicekandSimon Marsh 631662d76b 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-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 77cba3aa13 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-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh 049ec6a3d8 Filter: explicitly forbidden for-loop with pre-defined variable 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 6ea4c0268c 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-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh a3e488589f 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-07 13:56:38 +01:00
Igor PutovnyandSimon Marsh 40946b2240 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-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh f2b84cb65d Simple testing of reconfiguration to a slightly different one 2023-10-07 13:56:38 +01:00
katerina.kubecovaandSimon Marsh 0c30da2306 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-10-07 13:56:38 +01:00
katerina.kubecovaandSimon Marsh 6622003461 Attributes declared in config can be bytestrings 2023-10-07 13:56:38 +01:00
katerina.kubecovaandSimon Marsh 32a185caca Filter: Function unset() accepts attributes declared in config 2023-10-07 13:56:38 +01:00
katerina.kubecovaandSimon Marsh 529525c230 Structures bytestring and adata merged into adata. 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 24e8987564 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-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 04f41c9e34 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-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 052e666121 Filter: Split clist add/delete operations to multiple methods 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 3ada694582 Filter: Implement constant promotion for multiple dispatch methods 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 753bfc7e28 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-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 87279d2835 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-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh f1ddc397fe Filter: Better syntax for function return types
The C-style syntax does not really fit into rest of our syntax.
2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh a95a61209b 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-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 59b03085be Filter: Make f_method_call_*() usage symmetric 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh ed72f1d04d Filter: Convert more methods to use METHOD_R() 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh 6296974eeb 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-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh b10bd2ea06 Filter: Print instructions take only one value (simplification) 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh b03936dc5d Filter: Shortened method declarations 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh 1718c8bff2 Filter: The for loop uses the method system for type dispatch 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh f09394cbfd Removing unused terminals from filter config 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh 6496363eb4 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-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh ec5f278796 Uninitialized filter variables of path/[el]?clist types are now explicitly empty 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh 5e1f20a9a8 Filter: functions can and should have typed return values 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh c5436001ad 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-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh 2fcbda63a2 Conf: Symbol manipulation gets its context explicitly 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh bc72fcb13a Filter: any lvalue can get its methods called 2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh e6508d4a95 Filter: split out dot-notation methods to separate targets
This is just a preparationary refactoring to allow type-based method
tables.
2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh 0452c130fb Conf: Symbol hashes for all scopes
This is a backport cherry-pick of commits
  165156beeb2926472bbceca3c103aacc3f81a8cc
  cce974e8ea992d0e6d2f649eca7880b436d91d71

from the v3.0 branch as we need symbol hashes directly inside their
scopes for more general usage than before.
2023-10-07 13:56:38 +01:00
Maria MatejkaandSimon Marsh a3198981fa Dropping empty-type const f_vals, they were copied anyway 2023-10-07 13:56:38 +01:00
Ondrej ZajicekandSimon Marsh f5ba301224 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-10-07 13:56:37 +01:00
Ondrej ZajicekandSimon Marsh b751f8a13c 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 <[email protected]> for the bugreport.
2023-10-07 13:56:37 +01:00
Alexander ZubkovandSimon Marsh eb11f46abd 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-10-07 13:56:37 +01:00
Alexander ZubkovandSimon Marsh 4a96162c2e 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-10-07 13:56:37 +01:00
Maria MatejkaandSimon Marsh e5a5e9f5c8 Filter: Fixed segfault when a case option had an empty block
Thanks to Kobayashi_Bairuo <[email protected]> for reporting.
2023-10-07 13:56:37 +01: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
Radu CarpaandOndrej Zajicek 7144c9ca46 Filter: Allow setting the 'onlink' route attribute in filters
Add static route attribute to set onlink flag for route next hop. Can be
used to build a dynamically routed IP-in-IP overlay network. Usage:

     ifname = "tunl0";
     onlink = true;
     gw = bgp_next_hop;
2023-01-17 18:13:37 +01:00
Ondrej Zajicek f8276812e6 Minor cleanups 2023-01-13 13:32:29 +01:00
Ondrej Zajicek e20bef69cc Filter: Change linearization of branches in switch instruction
Most branching instructions (FI_CONDITION, FI_AND, FI_OR) linearize its
branches in a recursive way, while FI_SWITCH branches are linearized
from parser even before the switch instruction is allocated.

Change linearization of FI_SWITCH branches to make it similar to other
branching instructions. This also fixes an issue with constant
switch evaluation, where linearized branch is mistaken for
non-linearized during switch construction.

Thanks to Jiten Kumar Pathy for the bugreport.
2023-01-07 20:18:44 +01:00
Ondrej Zajicek d3f50ede12 Add compile-time option to enable 4-way tries instead of 16-way ones
In some cases 16-way tries are too memory-heavy, while 4-way are
almost as efficient as the original 2-way ones.
2023-01-02 15:55:55 +01:00
Maria Matejka 37b6444137 Moved config-related allocations to config_pool and showing its size in memory usage 2022-11-01 16:38:24 +01:00
Ondrej Zajicek e471f9e0fb Filter: Fix handling of variables in anonymous filters
Define scope for anonymous filters, and also explicitly distinguish block
scopes and function/filter scopes instead of using anonymous / named
distinction.

Anonymous filters forgot to push scope, so variables for them were in
fact defined in the top scope and therefore they shared a frame. This got
broken after rework of variables, which assumed that there is a named
scope for every function/filter.
2022-10-18 03:58:19 +02:00