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

159 Commits

Author SHA1 Message Date
Maria Matejka
d18a68cef7 Merge commit 'f0187d713c36e841fe8bab350e84f5257a74981a' into thread-next 2023-10-31 10:20:22 +01:00
Maria Matejka
b0797c2dcd Merge commit 'de70474fed139f9acb4ed3f8e925d12de4edcdd0' into thread-next 2023-10-31 09:58:42 +01:00
Maria Matejka
f0187d713c Filter: adding explicit route-block type
This is a split-commit of the neighboring aggregator branch
with a bit improved lvalue handling, to have easier merge into v3.
2023-10-30 13:10:36 +01:00
Maria Matejka
de70474fed Filter: adding explicit route type
This is a split-commit of the neighboring aggregator branch
with a bit improved lvalue handling, to have easier merge into v3.
2023-10-30 13:10:36 +01:00
Maria Matejka
c5f6dc8142 Merge commit '0a729b50' into thread-next
This merge was particularly difficult. I finally resorted to delete the
symbol scope active flag altogether and replace its usage by other
means.

Also I had to update custom route attribute registration to fit
both the scope updates in v2 and the data model in v3.
2023-10-29 15:42:46 +01:00
Maria Matejka
737807c118 Merge commit 'bb8e2824' into thread-next 2023-10-29 00:56:06 +02:00
Maria Matejka
de8288c679 Merge commit 'a3dc2645' into thread-next 2023-10-29 00:50:38 +02:00
Maria Matejka
a725e3e580 Merge commit 'cc1099a0' into thread-next
Updated f_implicit_roa_check() to use type methods and moved to filter/f-util.c
2023-10-29 00:14:52 +02:00
Maria Matejka
ef02744998 Merge commit 'fdd39c81' into thread-next 2023-10-29 00:00:07 +02:00
Maria Matejka
1a49a4aea8 Merge commit 'fc9d471b' into thread-next
Conflicts:
	conf/cf-lex.l
	conf/conf.h
	filter/config.Y
	filter/data.c
	filter/data.h
2023-10-28 23:42:21 +02:00
Maria Matejka
c4bcded8b9 Merge commit 'a5a6de58' into thread-next
Conflicts:
      filter/config.Y
      filter/data.h
      filter/data.c
2023-10-24 10:39:52 +02:00
Maria Matejka
7efa3bac4f Merge commit 'cce48c6c' into thread-next 2023-10-13 14:02:21 +02:00
Maria Matejka
e7acdf6428 Merge commit 'fc354788' into thread-next 2023-10-13 11:32:53 +02:00
Maria Matejka
767b7b22a0 Merge commit '5121101136cb80151a9361c63dc4822afeb44eef' into thread-next 2023-10-12 14:12:33 +02:00
Maria Matejka
32009cb6eb Logging: Abolished stdio in favor of write() to make the logging faster. 2023-09-24 20:40:06 +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
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
132f1edaf4 Filter: Split clist add/delete operations to multiple methods 2023-09-12 16:33:59 +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
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
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
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
062ff65683 Filter: functions can and should have typed return values 2023-09-12 15:58:07 +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
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
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
Maria Matejka
758aabd96c Merge commit '7fb23041a52d01754c53ba963e2282e524813364' into thread-next 2023-01-23 19:46:26 +01:00
Radu Carpa
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
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
Maria Matejka
f51837ace6 Caching eattrs in filters is not needed anymore.
After flattening the route attribute structure, the ea_list ** is derivable
from rte * by arithmetics. Caching the derived value doesn't help performance
and therefore is removed as unnecessary.
2022-09-21 17:48:31 +02:00
Maria Matejka
c73343de67 Revert "Reducing filter stack size to allow for lesser thread stack size"
This reverts commit 2c13759136.
2022-09-16 10:11:51 +02:00
Maria Matejka
fb7fb67445 Table access is now locked. 2022-09-08 15:24:02 +02:00
Maria Matejka
71b434a987 Merge commit 'f0507f05ce57398e135651896dace4cb68eeed54' into thread-next 2022-08-02 22:08:59 +02:00
Maria Matejka
68a2c9d4c9 Merge commit '2e5bfeb73ac25e236a24b6c1a88d0f2221ca303f' into thread-next 2022-07-13 14:14:37 +02:00
Maria Matejka
2e5bfeb73a Merge remote-tracking branch 'origin/master' into backport 2022-07-11 11:08:10 +02:00
Ondrej Zajicek (work)
cb339a3067 Filter: Implement for loops
For loops allow to iterate over elements in compound data like BGP paths
or community lists. The syntax is:

  for [ <type> ] <variable> in <expr> do <command-body>
2022-06-27 21:13:32 +02:00
Ondrej Zajicek (work)
1ac8e11bba Filter: Implement mixed declarations of local variables
Allow variable declarations mixed with code, also in nested blocks with
proper scoping, and with variable initializers. E.g:

function fn(int a)
{
  int b;
  int c = 10;

  if a > 20 then
  {
    b = 30;
    int d = c * 2;
    print a, b, c, d;
  }

  string s = "Hello";
}
2022-06-27 21:13:32 +02:00
Ondrej Zajicek (work)
a2527ee53d Filter: Improve handling of stack frames in filter bytecode
When f_line is done, we have to pop the stack frame. The old code just
removed nominal number of args/vars. Change it to use stored ventry value
modified by number of returned values. This allows to allocate variables
on a stack frame during execution of f_lines instead of just at start.

But we need to know the number of returned values for a f_line. It is 1
for term, 0 for cmd. Store that to f_line during linearization.
2022-06-27 21:13:32 +02:00
Ondrej Zajicek (work)
26bc4f9904 Filter: Implement direct recursion
Direct recursion almost worked, just crashed on function signature check.
Split function parsing such that function signature is saved before
function body is processed. Recursive calls are marked so they can be
avoided during f_same() and similar code walking.

Also, include tower of hanoi solver as a test case.
2022-06-27 21:13:31 +02:00
Ondrej Zajicek (work)
fb1d8f6513 Filter: Apply constant promotion for FI_EQ / FI_NEQ
Equality comparison is defined on all values, even of different
types, but we still want to do constant promotion if possible.
2022-06-27 21:13:31 +02:00
Alexander Zubkov
b2d6d2948a Filter: Add literal for empty set
Add literal for empty set [], which works both for tree-based sets
and prefix sets by using existing constant promotion mechanism.

Minor changes by committer.
2022-06-27 21:13:31 +02:00
Ondrej Zajicek (work)
8f3c6151b4 Nest: Cleanups in as_path_filter()
Use struct f_val as a common argument for as_path_filter(), as suggested
by Alexander Zubkov. That allows to use NULL sets as valid arguments.
2022-06-27 21:13:31 +02:00
Ondrej Zajicek (work)
9b302c133f Filter: Ensure that all expressions declared return type
All instructions with a return value (i.e. expressions, ones with
non-zero outval, third argument in INST()) should declare their return
type. Check that automatically by M4 macros.

Set outval of FI_RETURN to 0. The instruction adds one value to stack,
but syntactically it is a statement, not an expression.

Add fake return type declaration to FI_CALL, otherwise the automatic
check would fail builds.
2022-06-27 21:13:31 +02:00
Ondrej Zajicek (work)
cde8094c1f Filter: Improve description of type system 2022-06-27 21:13:31 +02:00