0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-11-08 20:28:43 +00:00
Commit Graph

4122 Commits

Author SHA1 Message Date
katerina.kubecova
42212ea6e9 Attributes declared in config can be bytestrings 2023-09-20 13:52:22 +02:00
katerina.kubecova
e63f46b1ac Function unset() accepts attributes declared in config 2023-09-20 13:50:58 +02:00
katerina.kubecova
07eddaba75 Structures bytestring and adata merged into adata. 2023-09-20 13:49:53 +02:00
Ondrej Zajicek
9ffea830b6 Conf: Move definition of struct keyword to conf.h 2023-09-14 17:24:09 +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
Ondrej Zajicek
c0231b0929 Conf: Remove toksym from symbol_known
No need to have toksym in symbol_known, as defined symbols are preferred
(by scope) to keywords anyway. Adding it just creates grammar conflicts.
2023-09-12 16:31:45 +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
6f798683a3 Conf: config warnings show the file position 2023-09-12 15:58:07 +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
6b95353ebd Conf: Allowing conf scope to be explicitly read only 2023-09-12 15:36:53 +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
58efa94460 Conf: Keywords have their default symbols
This avoids unnecessary collapsed soft scopes caused by keyword symbol multiallocation.
2023-09-12 15:21:14 +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
Maria Matejka
8659818391 Conf: Adding dummy thread-number setting for easier sharing of configuration between v2 and v3 2023-09-12 14:53:55 +02:00
Ondrej Zajicek
aa70e14c9e BFD: Improve handling of AdminDown
According to RFC 5882, system should not interpret the local or remote
session state transition to AdminDown as failure. We followed that for
the local session state but not for the remote session state (which
just triggered a transition of the local state to Down). The patch
fixes that.

We do not properly generate AdminDown on our side, so the patch is
relevant just for interoperability with other systems.

Thanks to Sunnat Samadov for the bugreport.
2023-08-29 18:23:29 +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
Ondrej Zajicek
116285f2b0 RPKI: Fix conflict in config grammar 2023-08-25 04:32:01 +02:00
Ondrej Zajicek
32427c9ce1 Nest: Fix missing bar in kw_sym
Thanks to Alexander Zubkov for the notice.
2023-08-25 04:29:32 +02:00
Alexander Zubkov
9d8e4b01bc Doc: Document bytestring type 2023-08-24 18:04:33 +02:00
Alexander Zubkov
cbb43d6ff3 Doc: Document RAdv "custom option" configuration definition 2023-08-24 17:41:51 +02:00
Ondrej Zajicek
f411a19bb0 Conf: Use nonterminal bytestring instead of BYTETEXT
Nonterminal bytestring allows to provide expressions to be evaluated in
places where BYTETEXT is used now: passwords, radv custom option.

Based on the patch from Alexander Zubkov <green@qrator.net>, thanks!
2023-08-24 16:59:23 +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
Ondrej Zajicek
eddc0ffdab Lib: Add functions for reading and writing of bytestrings
Based on patch from Alexander Zubkov, thanks!
2023-08-24 04:19:07 +02:00
Ondrej Zajicek
e3c0eca956 Nest: Treat VRF interfaces as inside respective VRFs
Despite not having defined 'master interface', VRF interfaces should be
treated as being inside respective VRFs. They behave as a loopback for
respective VRFs. Treating the VRF interface as inside the VRF allows
e.g. OSPF to pick up IP addresses defined on the VRF interface.

For this, we also need to tell apart VRF interfaces and regular interfaces.
Extend Netlink code to parse interface type and mark VRF interfaces with
IF_VRF flag.

Based on the patch from Erin Shepherd, thanks!
2023-08-23 16:08:40 +02:00
Ondrej Zajicek
5121101136 Merge branch 'bmp' 2023-08-22 15:28:05 +02:00
Jakub Ružička
d2dbe85463 RPM: Sync bird.spec from Fedora dist-git
It seems all Fedora packages are built from epel7 branch.
2023-08-22 14:59:22 +02:00
Jakub Ružička
31ef5645e9 Distro: Add apkg packaging test
The test was written by Maria Matejka, thanks!

Run this using

    apkg test
2023-08-22 14:59:22 +02:00
Jakub Ružička
215f7161c4 Distro: Add apkg compat level
This will allow compatibility on future apkg config updates.
2023-08-22 14:59:22 +02:00
Jakub Ružička
5fb871def4 Debian: Fix for arm64 cross build
Mirrors debian patch.
2023-08-22 14:59:22 +02:00