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

242 Commits

Author SHA1 Message Date
Maria Matejka
63e7620462 Conf/Filters: Moved argument count to conf scope 2019-06-25 16:18:06 +02:00
Maria Matejka
a84b8b6ebb Revert "Filter: Dropped the setter instructions in favor of direct result storage."
This reverts commit bd91338246.
2019-06-19 14:09:57 +02:00
Maria Matejka
bd91338246 Filter: Dropped the setter instructions in favor of direct result storage.
This should help filter performance a bit.
2019-06-03 10:41:35 +02:00
Jan Maria Matejka
23e3b1e665 Filter: Some people can't pronounce "postfixify" correctly. Let's try "linearize" instead.
This is just a naming change.
2019-05-22 15:20:02 +00:00
Jan Maria Matejka
96d757c13f Filter: Store variables and function arguments on stack 2019-05-21 16:33:37 +00:00
Maria Matejka
9eef9c648c Lexer now returns known sym / unknown sym / keyword 2019-05-17 22:26:21 +02:00
Maria Matejka
f249d0b84c Filters: comparison of functions and filters caching 2019-02-26 16:44:24 +01:00
Maria Matejka
32793ab685 Filter: Fixed bugs in FI_CALL and FI_SWITCH 2019-02-20 22:30:55 +01:00
Maria Matejka
ea4f55e3dc Filter: More cleanup -- customized structures also in struct f_line_item 2019-02-20 22:30:55 +01:00
Maria Matejka
0b39b1cbb7 Conf: Symbol implementation converted from void pointers to union
... and consted some declarations.
2019-02-20 22:30:55 +01:00
Maria Matejka
132529ce89 Filter: merged filter compare functions into common M4 file 2019-02-20 22:30:55 +01:00
Maria Matejka
4f082dfa89 Filter: merged filter instruction constructors, counting line size on instruction construct 2019-02-20 22:30:54 +01:00
Maria Matejka
8bdb05edb2 Filters: split the large filter.h file to smaller files.
This should be revised, there are still ugly things in the filter API.
2019-02-20 22:30:54 +01:00
Maria Matejka
c0e958e022 Filter + Config: Fix bugs, tests and split symbols by type 2019-02-20 22:30:54 +01:00
Maria Matejka
9b46748d5b Filter: refactoring of instruction constructors 2019-02-20 22:30:54 +01:00
Maria Matejka
4c553c5a5b Filter refactoring: dropped the recursion from the interpreter
This is a major change of how the filters are interpreted. If everything
works how it should, it should not affect you unless you are hacking the
filters themselves.

Anyway, this change should make a huge improvement in the filter performance
as previous benchmarks showed that our major problem lies in the
recursion itself.

There are also some changes in nest and protocols, related mostly to
spreading const declarations throughout the whole BIRD and also to
refactored dynamic attribute definitions. The need of these came up
during the whole work and it is too difficult to split out these
not-so-related changes.
2019-02-20 22:30:54 +01:00
Maria Matejka
ca2ee91a80 Filter refactoring: The constant f_val is simply included inside the instruction
With 32 bits, size of the args is 12 bytes, the f_val is 20 bytes.
With 64 bits, size of the args is 24 bytes, the f_val the same.

This is not so nice on 32 bits, anyway the f_inst itself is
24 vs. 32 bytes and the overall size of filters must be 32k of
instructions to get to one megabyte of RAM eaten by f_inst.

Therefore it seems to be improbable for common user to get into
problems with this change.
2019-02-20 22:30:54 +01:00
Maria Matejka
7f0ac73724 Filter refactoring: Changed arguments from separate unions to an array 2019-02-20 22:30:54 +01:00
Maria Matejka
224b77d4f7 Filter refactoring: Converted condition to three-args instruction 2019-02-20 22:30:54 +01:00
Jan Maria Matejka
7afa143886 Filter refactoring: Passing the resulting struct f_val as a pointer.
This also drops the multiplexing of errors with the f_val itself
together with the T_RETURN f_val type flag.
2019-02-20 22:30:54 +01:00
Maria Matejka
265419a369 Custom route attributes
For local route marking purposes, local custom route attributes may be
defined. These attributes are seamlessly stripped after export filter to
every real protocol like Kernel, BGP or OSPF, they however pass through
pipes. We currently allow at most 256 custom attributes.

This should be much faster than currently used bgp communities
for marking routes.
2018-12-06 09:55:21 +01:00
Ondrej Zajicek (work)
f2d8e6801e Filter: Make ifname attribute modifiable
Allow to change an interface associated with a route by setting
ifname attribute. It will also change the route to a direct one.
2018-11-05 22:03:21 +01:00
Ondrej Zajicek (work)
83715aa829 Filter: Add support for VPN_RD sets 2018-10-25 11:26:58 +02:00
Jan Maria Matejka
f851f0d7e3 Config: Dropping CF_ADDTO. 2018-06-26 14:29:03 +02:00
Jan Maria Matejka
478f9babed Filter: Removing the third argument hack
Just to make the code a bit more clean and easier to maintain.
2018-05-29 11:53:51 +02:00
Ondrej Zajicek (work)
b24b781117 Filter: Add support for src filter op to access SADR source prefix
The patch allows to use 'net.src' to access SADR source prefix
from filters.

Thanks to Toke Hoiland-Jorgensen for the original patch for srclen.
2018-05-16 11:19:29 +02:00
Jan Maria Matejka
8a871e890a Merge branch 'master' into int-new 2018-03-14 12:57:16 +01:00
Jan Maria Matejka
e8bc64e308 Filter: make bgpmask literals real constructors
The bgpmask literals can include expressions. This is OK but they have
to be interpreted as soon as the code is run, not in the time the code
is used as value.

This led to strange behavior like rewriting bgpmasks when they shan't
be rewritten:

	function mask_generator(int as)
	{
		return [= * as * =];
	}

	function another()
	bgpmask m1;
	bgpmask m2;
	{
		m1 = mask_generator(10);
		m2 = mask_generator(20);
		if (m1 == m2) {
			print("strange"); # this would happen
		}
	}

Moreover, sending this to CLI would cause stack overflow and knock down the
whole BIRD, as soon as there is at least one route to execute the given
filter on.

	show route filter bgpmask mmm; bgppath ppp; { ppp = +empty+; mmm = [= (ppp ~ mmm) =]; print(mmm); accept; }

The magic match operator (~) inside the bgpmask literal would try to
resolve mmm, which points to the same bgpmask so it would resolve
itself, call the magic match operator and vice versa.

After this patch, the bgpmask literal will get resolved as soon as it's
assigned to mmm and it also will return a type error as bool is not
convertible to ASN in BIRD.
2018-03-14 11:34:29 +01:00
Jan Maria Matejka
d1ba927b36 Merge branch 'master' into int-new 2018-03-13 16:51:04 +01:00
Maria Jan Matejka
5a14df3950 Filter: Instruction codes named as enum
The two-letter instructions were quite messy but they could be easily
read from memory dumps. Now GDB (since 2012) supports pretty printing
enum values and GCC checks the switch construction for missing enum
values so we are converting the nice two-byte values to enums.

Anyway, the enum still keeps the old two-byte values to be able to read
the instruction codes even without GDB from plain memory dump.
2018-03-13 16:29:33 +01:00
Jan Maria Matejka
3e52d112d7 Docs: Update to v2.0 2017-12-08 16:27:19 +01:00
Ondrej Zajicek (work)
69f7399247 Merge branch 'master' into int-new 2017-08-09 12:46:27 +02:00
Ondrej Zajicek (work)
e46128fb50 Filters: Do not clamp EC set values to 16 bit for EC_GENERICs
Thanks to Lennert Buytenhek <buytenh@wantstofly.org> for the patch.
2017-06-19 12:46:40 +02:00
Ondrej Zajicek (work)
6aaaa63519 Change parser to handle numbers as unsigned
Lexer always parsed numbers as unsigned, but parser handled them as
signed and grammar contained many unnecessary checks for negativity.
2017-05-23 17:40:19 +02:00
Jan Moskyto Matejka
61e501da89 Filter: Check whether IP is 4 or 6 2017-03-22 14:53:37 +01:00
Jan Moskyto Matejka
8c9986d310 Filters: VPN Route Distinguishers, Prefix Type, Docs Update 2017-03-13 13:51:20 +01:00
Jan Moskyto Matejka
5b208e296f Removing (struct rta)->cast. Never used. 2016-12-22 13:09:59 +01:00
Jan Moskyto Matejka
ad88b94bca Merge branch 'int-new-rpki-squashed' (early part) into int-new 2016-12-07 15:30:46 +01:00
Pavel Tvrdik
e58f8c28d2 Add `.maxlen' operator to all ROA prefixes in filters
Example:
  bird> eval (1.2.0.0/16 max 20 as 1234).maxlen
  20

Todo: Should be described in user docs
2016-12-07 09:35:24 +01:00
Pavel Tvrdik
69ae578450 Add `.asn' operator to all ROA prefixes in filters
Example:
  bird> eval (1.2.0.0/16 max 20 as 1234).asn
  1234

Todo: Should be described in user docs
2016-12-07 09:35:24 +01:00
Pavel Tvrdik
4b135d0958 Birdtest: Add function format in grammar for stringify expression 2016-11-16 12:22:01 +01:00
Pavel Tvrdik
3ec0bedc60 Birdtest: Remove bt_assert command from term
The bt_assert function does not return any value, so it was useless to
have a option in term definition.
2016-11-16 12:22:01 +01:00
Ondrej Zajicek (work)
9b0a0ba9e6 Unit Testing for BIRD
- Unit Testing Framework (BirdTest)
 - Integration of BirdTest into the BIRD build system
 - Tests for several BIRD modules

 Based on squashed Pavel Tvrdik's int-test branch, updated for
 current int-new branch.
2016-11-09 16:36:34 +01:00
Ondrej Zajicek (work)
8860e991f6 Merge branch 'master' into int-new 2016-11-08 19:27:58 +01:00
Ondrej Zajicek (work)
c8cafc8ebb Minor code cleanups 2016-11-08 17:46:29 +01:00
Ondrej Zajicek (work)
cc5b93f72d Merge tag 'v1.6.2' into int-new 2016-11-08 17:04:29 +01:00
Ondrej Zajicek (work)
60566c5c80 Filter: large community sets
Add support for lc sets to filter code. Grammar of (small) community sets
has to be updated to avoid parser collisions.
2016-10-03 13:47:37 +02:00
Ondrej Zajicek (work)
66dbdbd993 BGP: Support for large communities
Add support for large communities (draft-ietf-idr-large-community),
96bit alternative to RFC 1997 communities.

Thanks to Matt Griswold for the original patch.
2016-10-03 12:48:56 +02:00
Pavel Tvrdik
768d5e1058 Add !~ operator to filter grammar 2016-09-21 13:35:52 +02:00
Ondrej Zajicek (work)
122deb6d5b Filters: Fixes pm_same() w.r.t. ASN ranges and ASN expressions
This is necessary for proper detection of filter changes during
reconfigurations.
2016-06-09 00:30:41 +02:00
Ondrej Filip
a0fe1944d1 Add AS# ranges to bgpmask. 2016-06-08 16:22:44 +02:00
Jan Moskyto Matejka
7a7ac65682 Merge branch 'master' into int-new-channels 2016-04-08 12:28:33 +02:00
Ondrej Zajicek (work)
9c9cc35c02 Filter: Implement last_nonaggregated operator on bgp_path 2016-02-16 17:33:58 +01:00
Pavel Tvrdík
0264ccf6f4 Rewrite roa_check() for integrated BIRD
Thanks to Ondrej Zajicek for his support with writing this code.
2016-01-20 16:46:58 +01:00
Ondrej Zajicek (work)
04632fd77f Follow-up work on integration 2015-12-24 15:56:04 +01:00
Ondrej Zajicek (work)
23c212e7f1 Follow-up work on integration 2015-12-21 03:33:18 +01:00
Jan Moskyto Matejka
9656dce72e ROA code switchoff 2015-12-20 13:04:07 +01:00
Jan Moskyto Matejka
5e173e9f63 Stop perusing f_prefix for non-prefix-set uses
Multiple changes by Ondrej Santiago Zajicek
2015-12-19 23:49:47 +01:00
Jan Moskyto Matejka
d7661fbe9d Removed BITS_PER_IP_ADDRESS, MAX_PREFIX_LENGTH, BIRD_AF
Explicit setting of AF_INET(6|) in IP socket creation. BFD set to listen
on v6, without setting the V6ONLY flag to catch both v4 and v6 traffic.

Squashing and minor changes by Ondrej Santiago Zajicek
2015-12-19 15:57:09 +01:00
Ondrej Zajicek (work)
fe9f1a6ded Initial commit on integrated BIRD
New data types net_addr and variants (in lib/net.h) describing
network addresses (prefix/pxlen). Modifications of FIB structures
to handle these data types and changing everything to use these
data types instead of prefix/pxlen pairs where possible.

The commit is WiP, some protocols are not yet updated (BGP, Kernel),
and the code contains some temporary scaffolding.

Comments are welcome.
2015-11-05 12:48:52 +01:00
Ondrej Zajicek
51762a45b3 Allows user data attached to f_trie_node structure.
Thanks to Alexander Chernikov for the patch.
2015-02-21 14:05:20 +01:00
Ondrej Zajicek
b2f008378a Allows more constants in set literals.
Thanks to Michael Fincham for the bugreport.
2014-10-02 12:52:50 +02:00
Ondrej Zajicek
a5fc59587f Rewrites static attribute filter code and adds ifname/ifindex attributes.
Thanks to Sergey Popovich for the original ifname/ifindex patch.
2013-09-26 22:08:21 +02:00
Ondrej Zajicek
00192d5ab8 Implements proper setting of 'gw' route attribute.
Thanks to Sergey Popovich for the bugreport.
2013-08-13 20:32:02 +02:00
Ondrej Zajicek
4ee39ff2ff Fixes initial random values for function arguments.
Thanks to Javor Kliachev for the bugreport.
2013-07-26 11:08:59 +02:00
Ondrej Zajicek
1103b32e83 Allows to define constants of all filter types. 2013-07-25 22:33:57 +02:00
Ondrej Zajicek
182a78957d Allows some modifications of dest attribute in filters. 2012-04-29 01:35:52 +02:00
Ondrej Zajicek
af582c4811 Route Origin Authorization basics.
- ROA tables, which are used as a basic part for RPKI.
 - Commands for examining and modifying ROA tables.
 - Filter operators based on ROA tables consistent with RFC 6483.
2012-03-18 17:32:30 +01:00
Ondrej Zajicek
117e3c4bbf Fixes a bug in pair set intervals.
Pair intervals in form (a,b)..(c,d) were mishanded.

Thanks to Alexander Shikoff for the bugreport.
2012-03-15 12:18:26 +01:00
Ondrej Zajicek
78e33c29bb Some minor fixes in parser. 2011-10-26 20:06:36 +02:00
Ondrej Zajicek
736fd7303c Fixes a bug with multiple function arguments. 2011-09-27 13:49:32 +02:00
Ondrej Zajicek
42a0c05408 BGP Extended communities. 2011-08-14 13:55:02 +02:00
Ondrej Zajicek
e08d2ff08e Adds filter clist operation. 2011-06-26 17:09:24 +02:00
Ondrej Zajicek
b8cc390e7e Fixes several problems in filter syntax.
- Fixes several conflicts in the grammar.
 - Fixes a bug in (a..b, c) pair patterns.
 - Makes pair patterns orthogonal.
 - Allows term expressions in pair patterns without additional ( ).
 - Allows several comma separated values in switch cases.
2011-05-06 22:00:54 +02:00
Ondrej Filip
c454872f4e Avoid using stack. 2011-03-27 23:27:37 +02:00
Ondrej Filip
4fc36f394e This adds (*,x) functionality. 2011-03-26 14:18:56 +01:00
Ondrej Zajicek
26d92bb892 A hack to distinguish if..else from else: in case.
The old BIRD grammar needs two lookaheads to distinguish if..else from
else: in case, which caused the parser to fail on some combinations of
both expressions.

This patch replaces two tokens 'else' ':' by one token 'else:' to fix
that.
2011-03-23 12:49:53 +01:00
Ondrej Zajicek
b2b7bbfc69 Fixes scope of filter symbols. 2010-10-04 19:55:11 +02:00
Ondrej Filip
edaec901e1 Even set of number can be made by expressions. 2010-08-03 15:22:29 +02:00
Ondrej Filip
4733b49ed6 Syntax of sets improved. 2010-08-03 15:16:25 +02:00
Ondrej Zajicek
7f0d245a5e Minor changes in prefix trie. 2010-07-27 17:17:11 +02:00
Ondrej Zajicek
ba5c0057ed Extends pair set syntax, matching and deleting against clist.
Expressions like (123,*) can be used in pair set literals, clists can be
matched against pair sets (community ~ pairset) and pair sets can be
used to specify items to delete from clists (community.delete(pairset)).
2010-05-22 22:47:24 +02:00
Ondrej Zajicek
126683feed Filter language updates; new route attributes and datatype.
- Adds bgp_originator_id and bgp_cluster_list route attributes.
 - Adds dotted quad filter datatype (for router IDs, used by
   bgp_originator_id and ospf_router_id route attributes).
 - Fixes pair ~ pair set matching.
 - Documentation updates.
2010-03-29 19:29:03 +02:00
Ondrej Zajicek
aa46124804 Clear local variables in filters and functions.
Fixes crash when used uninitialized variables.
This problem was surprisingly tricky to fix.
2010-03-19 09:41:18 +01:00
Ondrej Zajicek
14f6aca480 Changes right recursion to left in the grammar of the case expression. 2010-02-17 11:29:48 +01:00
Ondrej Zajicek
5f47c4c11e Changes right-recursion to left-recursion in a filter grammar.
Because we don't want to have a limit on a function/filter length.
2010-02-02 00:03:46 +01:00
Ondrej Zajicek
7ea5b00f42 First and last accessors to as_paths. 2009-10-08 15:23:24 +01:00
Ondrej Zajicek
5004d02cb9 Merge branch 'master' into dev 2009-06-26 01:06:12 +02:00
Ondrej Zajicek
92a72a4cbd Adds support for dynamic pair and bgp mask expressions. 2009-06-01 19:32:41 +02:00
Ondrej Zajicek
f429d43482 Removes some remnant of '|' bgp path separator. 2009-06-01 16:20:48 +02:00
Ondrej Filip
9be1086d29 New type variable 'V' defined in filters. This type is checked
only for name, never for value in function filter_same()
2009-05-29 23:08:28 +02:00
Ondrej Zajicek
c8a6b9a3d1 Rewrite of buggy AS path matching.
Old AS path maching supposes thath AS number appears
only once in AS path, but that is not true. It also
contains some bugs related to AS path sets.

New code does not use any assumptions about semantic
structure of AS path. It is asymptotically slower than
the old code, but on real paths it is not significant.

It also allows '?' for matching one arbitrary AS number.
2009-04-17 01:48:36 +02:00
Ondrej Zajicek
b1a597e0c3 Reimplementation of prefix sets.
Prefix sets were broken beyond any repair and have to be reimplemented.
They are reimplemented using a trie with bitmasks in nodes.
There is also change in the interpretation of minus prefix pattern,
but the old interpretation was already inconsistent with
the documentation and broken.

There is also some bugfixes in filter code related to set variables.
2009-03-31 12:55:57 +02:00
Ondrej Zajicek
cf18603491 New syntax for bgp_path 2009-03-14 12:43:10 +01:00
Ondrej Zajicek
f949163039 New syntax for bgp_path 2009-01-27 17:35:00 +01:00
Ondrej Zajicek
083c43e22e fixes some 64-bit related bugs.
Filter code used 'aux' integer field of 'symbol' struct to store ptr
to next symbol and both 'aux2' and 'def' fields for value.
Changed to just 'def' for value and 'aux2' for ptr to next symbol.
Also another minor bugfix.
2008-12-25 11:55:27 +01:00
Ondrej Zajicek
e29fa06ece New read-only route attribute 'proto' added. It returns a string
representing a name of the protocol that originated the route.
Strings can be compared using = or matched using ~. Routes can
be filtered, for example:

show route where proto ~ "bgp1*"
2008-11-14 14:50:37 +01:00
Ondrej Zajicek
11cb620266 Implementation of 4B ASN support for BGP 2008-10-26 22:36:08 +01:00
Martin Mares
03e3d184b2 Fix bison input for current build tools, otherwise bison or the compiler
will abort the build.

(by Andreas)
2004-05-31 17:44:39 +00:00
Martin Mares
de10a974f2 Added missing semicolons. 2002-11-13 08:46:12 +00:00