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

4111 Commits

Author SHA1 Message Date
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
Jakub Ružička
5fe00df693 Debian: Use {{ now }} in changelog 2023-08-22 14:59:22 +02:00
Jakub Ružička
2b4ab79de1 Debian: Bump compat level to 11
Current is 13, remaining blockers:

- Debian 9 @ 11 (EOL)
- Ubuntu 18.04 @ 12 (EOL 2023-04-02)
2023-08-22 14:59:22 +02:00
Jakub Ružička
b983b59165 Debian: Sync packaging with Debian 2023-08-22 14:59:22 +02:00
Jakub Ružička
b0c3c286a5 Debian: Add birdcl manpage
Mirrors Debian package change.
2023-08-22 14:59:22 +02:00
Jakub Ružička
ad514e6033 RPM: Add missing BuildRequires: autoconf 2023-08-22 14:59:22 +02:00
Alexander Zubkov
fea04d7c34 Use more proper pointers to constant bytestrings 2023-08-22 14:44:18 +02:00
Ondrej Zajicek
9bf2048476 BGP: Update RFC reference
RFC 5549 was obsoleted by RFC 8950.
2023-08-22 14:20:59 +02:00
Ondrej Zajicek
4558adabfb BMP: Improve peer_down handling
Move all bmp_peer_down() calls to one place and make it synchronous with
BGP session down, ensuring that BMP receives peer_down before route
withdraws from flushing.

Also refactor bmp_peer_down_() message generating code.
2023-08-22 01:26:06 +02:00
Ondrej Zajicek
52641e0866 BMP: Use generic channel feed instead of direct walk over rtable
Now we use rt_notify() and channels for both feed and notifications,
in both import tables (pre-policy) and regular tables (post-policy).

Remove direct walk in bmp_route_monitor_snapshot().
2023-08-21 04:24:15 +02:00
Ondrej Zajicek
ef6ab5ce86 Nest: Use generic rte_announce() also for import tables
Remove special rte_announce_in(), so we can use generic rte_announce()
for bot feed and notifications.
2023-08-21 04:17:21 +02:00
Ondrej Zajicek
c40f29a790 BMP: Fix route timestamps 2023-08-18 15:39:08 +02:00