aboutsummaryrefslogtreecommitdiffstats
path: root/filter
Commit message (Collapse)AuthorAgeFilesLines
...
* Filter: Allow setting the 'onlink' route attribute in filtersRadu Carpa2023-01-173-3/+15
| | | | | | | | | 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;
* Minor cleanupsOndrej Zajicek2023-01-131-1/+1
|
* Filter: Change linearization of branches in switch instructionOndrej Zajicek2023-01-074-7/+46
| | | | | | | | | | | | | 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.
* Add compile-time option to enable 4-way tries instead of 16-way onesOndrej Zajicek2023-01-021-0/+7
| | | | | In some cases 16-way tries are too memory-heavy, while 4-way are almost as efficient as the original 2-way ones.
* Moved config-related allocations to config_pool and showing its size in ↵Maria Matejka2022-11-011-4/+4
| | | | memory usage
* Filter: Fix handling of variables in anonymous filtersOndrej Zajicek2022-10-181-7/+9
| | | | | | | | | | | 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.
* Filter: Add some minor functions for f_tree and ECOndrej Zajicek2022-10-033-3/+16
| | | | | Add some supportive functions for f_tree and EC. These functions are used by L3VPN code.
* Revert "Reducing filter stack size to allow for lesser thread stack size"Maria Matejka2022-09-164-46/+29
| | | | This reverts commit 2c13759136951ef0e70a3e3c2b2d3c9a387f7ed9.
* Merge remote-tracking branch 'origin/master' into backportMaria Matejka2022-07-119-109/+592
|\
| * Filter: Implement for loopsOndrej Zajicek (work)2022-06-274-2/+153
| | | | | | | | | | | | | | 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>
| * Filter: Implement mixed declarations of local variablesOndrej Zajicek (work)2022-06-273-27/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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"; }
| * Filter: Improve handling of stack frames in filter bytecodeOndrej Zajicek (work)2022-06-276-19/+21
| | | | | | | | | | | | | | | | | | | | 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.
| * Filter: Simplify handling of command sequencesOndrej Zajicek (work)2022-06-271-12/+6
| | | | | | | | | | Command sequences in curly braces used a separate nonterminal in grammar. Handle them as a regular command.
| * Filter: Fix bug in variable shadowingOndrej Zajicek (work)2022-06-271-3/+3
| | | | | | | | | | | | | | When a new variable used the same name as an existing symbol in an outer scope, then offset number was defined based on a scope of the existing symbol ($3) instead of a scope of the new symbol (sym_). That can lead to two variables sharing the same memory slot.
| * Filter: Implement direct recursionOndrej Zajicek (work)2022-06-275-13/+86
| | | | | | | | | | | | | | | | | | 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.
| * Filter: Apply constant promotion for FI_EQ / FI_NEQOndrej Zajicek (work)2022-06-274-5/+13
| | | | | | | | | | Equality comparison is defined on all values, even of different types, but we still want to do constant promotion if possible.
| * Filter: Add literal for empty setAlexander Zubkov2022-06-276-5/+90
| | | | | | | | | | | | | | 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.
| * Nest: Cleanups in as_path_filter()Ondrej Zajicek (work)2022-06-272-15/+8
| | | | | | | | | | 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.
| * Filter: Ensure that all expressions declared return typeOndrej Zajicek (work)2022-06-272-3/+12
| | | | | | | | | | | | | | | | | | | | | | | | 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.
| * Filter: Improve description of type systemOndrej Zajicek (work)2022-06-271-0/+52
| |
| * Filter: Implement type checks for function callsOndrej Zajicek (work)2022-06-273-10/+45
| | | | | | | | | | | | Keep list of function parameters in f_line and use it to verify types of arguments for function calls. Only static type checks are implemented.
| * Filter: Clean up function call instructionOndrej Zajicek (work)2022-06-272-21/+26
| | | | | | | | | | | | Pass instructions of function call arguments as vararg arguments to FI_CALL instruction constructor and move necessary magic from parser code to interpreter / instruction code.
* | Fixed spurious undef of route attributesAlexander Zubkov2022-05-041-0/+1
| |
* | Unsetting route attributes without messing with type systemMaria Matejka2022-04-061-20/+2
| |
* | Eattr flags (originated and fresh) get their own struct fieldsMaria Matejka2022-04-061-2/+6
| |
* | Merge commit 'e42eedb9' into haugesundMaria Matejka2022-03-091-1/+0
|\ \
| * | Dropping the RTS_DUMMY temporary route storage.Maria Matejka2021-10-131-1/+0
| | | | | | | | | | | | | | | Kernel route sync is done by other ways now and this code is not used currently.
* | | Merge commit '5cff1d5f' into haugesundMaria Matejka2022-03-093-26/+9
|\| | | | | | | | | | | | | | | | | Conflicts: proto/bgp/attrs.c proto/pipe/pipe.c
| * | Route: moved rte_src pointer from rta to rteMaria Matejka2021-10-131-2/+2
| | | | | | | | | | | | It is an auxiliary key in the routing table, not a route attribute.
| * | Preference moved to RTA and set explicitly in protocolsMaria Matejka2021-10-133-24/+7
| | |
* | | Replaced custom linpools in tests for the common tmp_linpoolMaria Matejka2022-03-023-51/+35
| | |
* | | Merge commit '2c13759136951ef0e70a3e3c2b2d3c9a387f7ed9' into haugesundMaria Matejka2022-03-024-35/+61
|\| | | |/ |/|
| * Reducing filter stack size to allow for lesser thread stack sizeMaria Matejka2021-09-104-29/+46
| |
| * Filter: Additional consistency checksMaria Matejka2021-09-101-6/+15
| |
* | Merge branch 'oz-trie-table'Ondrej Zajicek (work)2022-02-064-215/+1716
|\ \
| * | Trie: Fix trie formatOndrej Zajicek (work)2022-02-062-21/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After switching to 16-way tries, trie format ignored unaligned / internal prefixes and only reported the primary prefix of a trie node. Fix trie format by showing internal prefixes based on the 'local' bitmask of a node. Also do basic (intra-node) reconstruction of prefix patterns by finding common subtrees in 'local' bitmask. In future, we could improve that by doing inter-node reconstruction, so prefixes entered as one pattern for a subtree (e.g. 192.168.0.0/18+) would be reported as such, like with aligned prefixes.
| * | Trie: Add prefix counterOndrej Zajicek (work)2022-02-063-0/+12
| | | | | | | | | | | | | | | Add counter of prefixes stored in trie. Works only for 'restricted' tries composed of explicit prefixes (pxlen == l == h), like ones used in rtables.
| * | Trie: Clarify handling of less-common net typesOndrej Zajicek (work)2021-12-021-21/+41
| | | | | | | | | | | | | | | | | | For convenience, Trie functions generally accept as input values not only NET_IPx types of nets, but also NET_VPNx and NET_ROAx types. But returned values are always NET_IPx types.
| * | Trie: Implement longest-prefix-match queries and walksOndrej Zajicek (work)2021-11-263-1/+355
| | | | | | | | | | | | | | | | | | | | | The prefix trie now supports longest-prefix-match query by function trie_match_longest_ipX() and it can be extended to iteration over all covering prefixes for a given prefix (from longest to shortest) using TRIE_WALK_TO_ROOT_IPx() macro.
| * | Trie: Implement trie walking codeOndrej Zajicek (work)2021-11-193-13/+413
| | | | | | | | | | | | | | | | | | Trie walking allows enumeration of prefixes in a trie in the usual lexicographic order. Optionally, trie enumeration can be restricted to a chosen subnet (and its descendants).
| * | Trie: Simplify network matching codeOndrej Zajicek (work)2021-11-131-16/+6
| | | | | | | | | | | | Introduce ipX_prefix_equal() and use it to simplify network matching code.
| * | Filter: Add prefix trie benchmarksOndrej Zajicek (work)2021-09-251-0/+235
| | | | | | | | | | | | | | | | | | Add trie tests intended as benchmarks that use external datasets instead of generated prefixes. As datasets are not included, they are commented out by default.
| * | Filter: Improve prefix trie testsOndrej Zajicek (work)2021-09-251-74/+302
| | | | | | | | | | | | | | | Add tests explicitly matching insides and outsides of trie and update tests to do testing of both IPv4 and IPv6 tries.
| * | Filter: Update trie documentationOndrej Zajicek (work)2021-09-251-44/+69
| | |
| * | Filter: Fix trie testOndrej Zajicek (work)2021-09-251-2/+3
| | | | | | | | | | | | Generated prefixes must be valid.
| * | Filter: Faster prefix setsOndrej Zajicek (work)2021-09-253-71/+218
| |/ | | | | | | | | | | | | | | | | Use 16-way (4bit) branching in prefix trie instead of basic binary branching. The change makes IPv4 prefix sets almost 3x faster, but with more memory consumption and much more complicated algorithm. Together with a previous filter change, it makes IPv4 prefix sets about ~4.3x faster and slightly smaller (on my test data).
* | Conf: Fix parsing full-length IPv6 addressesOndrej Zajicek (work)2022-01-051-0/+20
| | | | | | | | | | | | | | | | | | | | Lexer expression for bytestring was too loose, accepting also full-length IPv6 addresses. It should be restricted such that colon is used between every byte or never. Fix the regex and also add some test cases for it. Thanks to Alexander Zubkov for the bugreport
* | Filter: Add operators to find minimum and maximum element of setsAlexander Zubkov2021-12-285-0/+102
| | | | | | | | | | | | | | | | | | | | | | Add operators .min and .max to find minumum or maximum element in sets of types: clist, eclist, lclist. Example usage: bgp_community.min bgp_ext_community.max filter(bgp_large_community, [(as1, as2, *)]).min Signed-off-by: Alexander Zubkov <green@qrator.net>
* | Filter: Add operators to pick community componentsAlexander Zubkov2021-12-283-8/+53
|/ | | | | | | | | | | | | | | Add operators that can be used to pick components from pair (standard community) or lc (large community) types. For example: (10, 20).asn --> 10 (10, 20).data --> 20 (10, 20, 30).asn --> 10 (10, 20, 30).data1 --> 20 (10, 20, 30).data2 --> 30 Signed-off-by: Alexander Zubkov <green@qrator.net>
* Flowspec: Label field should use numeric operator and not bitmask operatorOndrej Zajicek (work)2021-05-181-0/+1
|