]> git.ipfire.org Git - thirdparty/bird.git/log
thirdparty/bird.git
2 years agoNest: Fix leaking internal attributes in RIP and Babel
Ondrej Zajicek [Tue, 3 Jan 2023 16:01:54 +0000 (17:01 +0100)] 
Nest: Fix leaking internal attributes in RIP and Babel

During backporting attribute changes from 3.0-branch, some internal
attributes (RIP iface and Babel seqno) leaked to 'show route all' output.
Allow protocols to hide specific attributes with GA_HIDDEN value.

Thanks to Nigel Kukard for the bugreport.

2 years agoAdd compile-time option to enable 4-way tries instead of 16-way ones
Ondrej Zajicek [Mon, 2 Jan 2023 14:55:55 +0000 (15:55 +0100)] 
Add compile-time option to enable 4-way tries instead of 16-way ones

In some cases 16-way tries are too memory-heavy, while 4-way are
almost as efficient as the original 2-way ones.

2 years agoNest: Fix several issues with pflags
Ondrej Zajicek [Sun, 1 Jan 2023 19:10:23 +0000 (20:10 +0100)] 
Nest: Fix several issues with pflags

There were some confusion about validity and usage of pflags, which
caused incorrect usage after some flags from (now removed) protocol-
specific area were moved to pflags.

We state that pflags:

 - Are secondary data used by protocol-specific hooks
 - Can be changed on an existing route (in contrast to copy-on-write
   for primary data)
 - Are irrelevant for propagation (not propagated when changed)
 - Are specific to a routing table (not propagated by pipe)

The patch did these fixes:

 - Do not compare pflags in rte_same(), as they may keep cached values
   like BGP_REF_STALE, causing spurious propagation.

 - Initialize pflags to zero in rte_get_temp(), avoid initialization in
   protocol code, fixing at least two forgotten initializations (krt
   and one case in babel).

 - Improve documentation about pflags

2 years agoBabel: Rework seqno request handling
Toke Høiland-Jørgensen [Sat, 24 Dec 2022 14:47:11 +0000 (15:47 +0100)] 
Babel: Rework seqno request handling

The seqno request retransmission handling was tracking the destination
that a forwarded request was being sent to and always retransmitting to
that same destination. This is unnecessary because we only need to
retransmit requests we originate ourselves, not those we forward on
behalf of others; in fact retransmitting on behalf of others can lead to
exponential multiplication of requests, which would be bad.

So rework the seqno request tracking so that instead of storing the
destination of a request, we just track whether it was a request that we
forwarded on behalf of another node, or if it was a request we originated
ourselves. Forwarded requests are not retransmitted, they are only used
for duplicate suppression, and for triggering an update when satisfied.
If we end up originating a request that we previously forwarded, we
"upgrade" the old request and restart the retransmit counter.

One complication with this is that requests sent in response to unfeasible
updates (section 3.8.2.2 of the RFC) have to be sent as unicast to a
particular peer. However, we don't really need to retransmit those as
there's no starvation when sending such a request; so we just change
such requests to be one-off unicast requests that are not subject to
retransmission or duplicate suppression. This is the same behaviour as
babeld has for such requests.

Minor changes from committer.

2 years agoBSD: Use ip_mreqn on FreeBSD 12.1+ and OpenBSD 6.9+
Ondrej Zajicek [Sun, 18 Dec 2022 19:10:14 +0000 (20:10 +0100)] 
BSD: Use ip_mreqn on FreeBSD 12.1+ and OpenBSD 6.9+

2 years agoFreeBSD: use interface index instead of IP address when specifying multicast interface
Alexander Chernikov [Fri, 16 Dec 2022 18:35:02 +0000 (19:35 +0100)] 
FreeBSD: use interface index instead of IP address when specifying multicast interface

Minor changes from committer.

2 years agoNetlink: move OS-specific headers and defines to sysdep
Alexander Chernikov [Fri, 16 Dec 2022 18:20:05 +0000 (19:20 +0100)] 
Netlink: move OS-specific headers and defines to sysdep

Minor changes from committer.

2 years agoBSD: Add missing makefile for bsd-netlink target
Ondrej Zajicek [Fri, 16 Dec 2022 18:03:41 +0000 (19:03 +0100)] 
BSD: Add missing makefile for bsd-netlink target

Use symlinks to linux/netlink* to avoid limitations of our buildsystem.

2 years agoNEWS and version update v2.0.11
Ondrej Zajicek [Sun, 11 Dec 2022 16:28:14 +0000 (17:28 +0100)] 
NEWS and version update

2 years agoBSD: Workaround for direct routes on FreeBSD 13.0
Ondrej Zajicek [Sun, 11 Dec 2022 15:28:28 +0000 (16:28 +0100)] 
BSD: Workaround for direct routes on FreeBSD 13.0

FreeBSD 13.0 added some safechecks for syscalls, rejecting sockaddrs that
are too small, later versions loosen up the check.

2 years agoBGP: Log unacceptable hold time as decimal number
Ondrej Zajicek [Sat, 10 Dec 2022 17:03:41 +0000 (18:03 +0100)] 
BGP: Log unacceptable hold time as decimal number

Thanks Johannes Moos for the suggestion.

2 years agoCLI: Fix for long-lived sessions during high loads
Ondrej Zajicek [Sat, 10 Dec 2022 16:32:42 +0000 (17:32 +0100)] 
CLI: Fix for long-lived sessions during high loads

When there is a continuos stream of CLI commands, cli_get_command()
always returns 1 (there is a new command). Anyway, the socket receive
buffer was reset only when there was no command at all, leading to a
strange behavior: after a while, the CLI receive buffer came to its end,
then read() was called with zero size buffer, it returned 0 which was
interpreted as EOF.

The patch fixes that by resetting the buffer position after each command
and moving remaining data at the beginning of buffer.

Thanks to Maria Matejka for examining the bug and for the original bugfix.

2 years agoClient: Unknown command should return nonzero errorcode
Ondrej Zajicek [Sat, 10 Dec 2022 02:02:26 +0000 (03:02 +0100)] 
Client: Unknown command should return nonzero errorcode

2 years agoDoc: Document issue with import tables
Ondrej Zajicek [Fri, 9 Dec 2022 21:43:27 +0000 (22:43 +0100)] 
Doc: Document issue with import tables

The import table does not work reliably together with re-evaluation of
routes due to recursive next hops or flowspec validation. We will at
least document that here, as import tables are completely redesigned and
this issue is fixed in BIRD 3.x branch.

2 years agoNetlink on FreeBSD support
Alexander V. Chernikov [Fri, 9 Dec 2022 14:59:06 +0000 (15:59 +0100)] 
Netlink on FreeBSD support

Netlink support was added to FreeBSD recently. It is not as full-featured
as its Linux counterpart yet, however the added subset is enough to make
a routing daemon work. Specifically, it supports multiple tables,
multipath, nexthops and nexthops groups. No MPLS support yet.

The attached change adds 'bsd-netlink’ sysconf target, allowing to build
both netlink & rtsock versions on FreeBSD.

2 years agoBGP: Improve handling of hold and keepalive timers
Ondrej Zajicek [Fri, 9 Dec 2022 04:51:30 +0000 (05:51 +0100)] 
BGP: Improve handling of hold and keepalive timers

The effective keepalive time now scales relative to the negotiated
hold time, to maintain proportion between the keepalive time and the
hold time. This avoids issues when both keepalive and hold times
were configured, the hold time was negotiated to a smaller value,
but the keepalive time stayed the same.

Add new options 'min hold time' and 'min keepalive time', which reject
session attempts with too small hold time.

Improve validation of config options an their documentation.

Thanks to Alexander Zubkov and Sergei Goriunov for suggestions.

2 years agoNest: Avoid spurious announcements triggered by filtered routes
Ondrej Zajicek [Tue, 6 Dec 2022 18:40:02 +0000 (19:40 +0100)] 
Nest: Avoid spurious announcements triggered by filtered routes

When filtered routes (enabled by 'import keep filtered' option) are
updated, they trigger announcements by rte_announce(). For regular
channels (e.g. type RA_OPTIMAL or RA_ANY) such announcement is just
ignored, but in case of RA_ACCEPTED (BGP peer with 'secondary' option)
it just reannounces the old (and still valid) best route.

The patch ensures that such no-change is ignored even for these channels.

2 years agoCI: Remove docker rebuild phase
Ondrej Zajicek [Wed, 30 Nov 2022 01:45:07 +0000 (02:45 +0100)] 
CI: Remove docker rebuild phase

It is unnnecessary and takes too much time

2 years agoCI: Try new workers
Ondrej Zajicek [Tue, 29 Nov 2022 17:30:16 +0000 (18:30 +0100)] 
CI: Try new workers

2 years agoBSD: Fix krt socket code w.r.t. rte/rta changes
Ondrej Zajicek [Tue, 29 Nov 2022 18:43:38 +0000 (19:43 +0100)] 
BSD: Fix krt socket code w.r.t. rte/rta changes

2 years agoFix build variables for OpenBSD
Ondrej Zajicek [Tue, 29 Nov 2022 02:50:33 +0000 (03:50 +0100)] 
Fix build variables for OpenBSD

2 years agoConf: Make 'configure check' command restricted
Ondrej Zajicek [Wed, 9 Nov 2022 21:02:46 +0000 (22:02 +0100)] 
Conf: Make 'configure check' command restricted

While it does not directly change BIRD state, it can trigger reading
arbitrary files and eating significant memory.

2 years agoConf: Free stored old config before parsing new one
Ondrej Zajicek [Wed, 9 Nov 2022 20:09:16 +0000 (21:09 +0100)] 
Conf: Free stored old config before parsing new one

BIRD keeps a previous (old) configuration for the purpose of undo. The
existing code frees it after a new configuration is successfully parsed
during reconfiguration. That causes memory usage spikes as there are
temporarily three configurations (old, current, and new). The patch
changes it to free the old one before parsing the new one (as user
already requested a new config). The disadvantage is that undo is
not available after failed reconfiguration.

2 years agoAdded more netlab tests for automatic run.
Maria Matejka [Tue, 8 Nov 2022 09:20:55 +0000 (10:20 +0100)] 
Added more netlab tests for automatic run.

This commit uses bird-tools in version
f35e8bce829f4bff61ec7eb07ec9c67aa867bc9a

2 years agoPage allocator: Fixed minor bugs and added commentary
Maria Matejka [Thu, 3 Nov 2022 11:38:57 +0000 (12:38 +0100)] 
Page allocator: Fixed minor bugs and added commentary

2 years agoMemory pages are not munmapped, instead we just madvise()
Maria Matejka [Tue, 1 Nov 2022 17:40:56 +0000 (18:40 +0100)] 
Memory pages are not munmapped, instead we just madvise()

Memory unmapping causes slow address space fragmentation, leading in
extreme cases to failing to allocate pages at all. Removing this problem
by keeping all the pages allocated to us, yet calling madvise() to let
kernel dispose of them.

This adds a little complexity and overhead as we have to keep the
pointers to the free pages, therefore to hold e.g. 1 GB of 4K pages with
8B pointers, we have to store 2 MB of data.

2 years agoMoved config-related allocations to config_pool and showing its size in memory usage
Maria Matejka [Tue, 1 Nov 2022 07:56:26 +0000 (08:56 +0100)] 
Moved config-related allocations to config_pool and showing its size in memory usage

2 years agoDoc: Add documentation for "show route (import|export) table"
Alexander Zubkov [Tue, 18 Oct 2022 02:25:29 +0000 (04:25 +0200)] 
Doc: Add documentation for "show route (import|export) table"

2 years agoFilter: Fix handling of variables in anonymous filters
Ondrej Zajicek [Tue, 18 Oct 2022 01:58:19 +0000 (03:58 +0200)] 
Filter: Fix handling of variables in anonymous filters

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.

2 years agoNetlink: Parse onlink flag even on direct routes
Ondrej Zajicek [Wed, 12 Oct 2022 15:57:26 +0000 (17:57 +0200)] 
Netlink: Parse onlink flag even on direct routes

While onlink flag is meaningful only with explicit next hops, it can be
defined also on direct routes. Parse it also in this case to avoid
periodic updates of the same route.

Thanks to Marcin Saklak for the bugreport.

2 years agoBGP: Add option 'next hop prefer global'
Ondrej Zajicek [Mon, 10 Oct 2022 03:06:19 +0000 (05:06 +0200)] 
BGP: Add option 'next hop prefer global'

Add BGP channel option 'next hop prefer global' that modifies BGP
recursive next hop resolution to use global next hop IPv6 address instead
of link-local next hop IPv6 address for immediate next hop of received
routes.

2 years agoNest: Add channel config flag to distinguish new or copy
Ondrej Zajicek [Mon, 3 Oct 2022 16:53:21 +0000 (18:53 +0200)] 
Nest: Add channel config flag to distinguish new or copy

It is useful to distinguish whehter channel config returned from
channel_config_get() was allocated new, or existing from template.
Caller may want to initialize new ones.

2 years agoFilter: Add some minor functions for f_tree and EC
Ondrej Zajicek [Tue, 27 Sep 2022 14:47:52 +0000 (16:47 +0200)] 
Filter: Add some minor functions for f_tree and EC

Add some supportive functions for f_tree and EC. These functions are used
by L3VPN code.

2 years agoBGP: Some fixes related to VRF and MPLS interactions
Ondrej Zajicek [Tue, 27 Sep 2022 14:13:27 +0000 (16:13 +0200)] 
BGP: Some fixes related to VRF and MPLS interactions

 - When next hop is reset to local IP, we should remove BGP label stack,
   as it is related to original next hop

 - BGP next hop or immediate next hop from one VRF should not be passed
   to another VRF, as they are different IP namespaces

2 years agoBGP: Do not assume that all channels are struct bgp_channel
Ondrej Zajicek [Thu, 8 Sep 2022 17:41:02 +0000 (19:41 +0200)] 
BGP: Do not assume that all channels are struct bgp_channel

In principle, the channel list is a list of parent struct proto and can
contain general structures of type struct channel, That is useful e.g.
for adding MPLS channels to BGP.

2 years agoRPKI: wait for retry_time if we get error immediately after connected
Maria Matejka [Mon, 3 Oct 2022 15:09:02 +0000 (17:09 +0200)] 
RPKI: wait for retry_time if we get error immediately after connected

2 years agoKRT: Fix setting default preference
Alexander Zubkov [Wed, 21 Sep 2022 15:07:11 +0000 (17:07 +0200)] 
KRT: Fix setting default preference

Changes in commit eb937358 broke setting of channel preference for alien
routes learned during scan. The preference was set only for async routes.
Move common attribute processing part of functions krt_learn_async() and
krt_learn_async() to a separate function to have only one place for such
changes.

2 years agoRevert "Reducing filter stack size to allow for lesser thread stack size"
Maria Matejka [Fri, 16 Sep 2022 08:11:51 +0000 (10:11 +0200)] 
Revert "Reducing filter stack size to allow for lesser thread stack size"

This reverts commit 2c13759136951ef0e70a3e3c2b2d3c9a387f7ed9.

2 years agoBetter profylaction recursive route loops
Maria Matejka [Fri, 22 Oct 2021 17:43:55 +0000 (19:43 +0200)] 
Better profylaction recursive route loops

In some specific configurations, it was possible to send BIRD into an
infinite loop of recursive next hop resolution. This was caused by route
priority inversion.

To prevent priority inversions affecting other next hops, we simply
refuse to resolve any next hop if the best route for the matching prefix
is recursive or any other route with the same preference is recursive.

Next hop resolution doesn't change route priority, therefore it is
perfectly OK to resolve BGP next hops e.g. by an OSPF route, yet if the
same (or covering) prefix is also announced by iBGP, by retraction of
the OSPF route we would get a possible priority inversion.

2 years agoMerge branch 'mq-fix-eattr-setting' into backport
Maria Matejka [Thu, 18 Aug 2022 20:07:50 +0000 (22:07 +0200)] 
Merge branch 'mq-fix-eattr-setting' into backport

2 years agoSimplified the protocol hookup code in Makefiles
Maria Matejka [Thu, 18 Aug 2022 16:32:33 +0000 (18:32 +0200)] 
Simplified the protocol hookup code in Makefiles

2 years agoFixed initialization of Linux kernel route attributes
Maria Matejka [Thu, 18 Aug 2022 15:44:00 +0000 (17:44 +0200)] 
Fixed initialization of Linux kernel route attributes

2 years agoMerge commit '082905a8' into HEAD
Maria Matejka [Wed, 3 Aug 2022 13:04:42 +0000 (15:04 +0200)] 
Merge commit '082905a8' into HEAD

2 years agorip_rte_better() uses the IGP_METRIC_UNKNOWN instead of protocol-specific infinity
Maria Matejka [Fri, 22 Jul 2022 14:09:37 +0000 (16:09 +0200)] 
rip_rte_better() uses the IGP_METRIC_UNKNOWN instead of protocol-specific infinity

3 years agoMerge branch 'master' into backport
Ondrej Zajicek [Tue, 26 Jul 2022 22:47:24 +0000 (00:47 +0200)] 
Merge branch 'master' into backport

3 years agoNetlink: Restrict route replace for IPv6
Ondrej Zajicek [Tue, 26 Jul 2022 16:45:20 +0000 (18:45 +0200)] 
Netlink: Restrict route replace for IPv6

Seems like the previous patch was too optimistic, as route replace is
still broken even in Linux 4.19 LTS (but fixed in Linux 5.10 LTS) for:

  ip route add 2001:db8::/32 via fe80::1 dev eth0
  ip route replace 2001:db8::/32 dev eth0

It ends with two routes instead of just the second.

The issue is limited to direct and special type (e.g. unreachable)
routes, the patch restricts route replace for cases when the new route
is a regular route (with a next hop address).

3 years agoNetlink: Simplify handling of IPv6 ECMP routes
Ondrej Zajicek [Sun, 24 Jul 2022 22:11:40 +0000 (00:11 +0200)] 
Netlink: Simplify handling of IPv6 ECMP routes

When IPv6 ECMP support first appeared in Linux kernel, it used different
API than IPv4 ECMP. Individual next hops were updated and announced
separately, instead of using RTA_MULTIPATH as in IPv4. This has several
drawbacks and requires complex code to merge received notifications to
one multipath route.

When Linux came with IPv6 RTA_MULTIPATH support, the initial versions
were somewhat buggy, so we kept using the old API for updates (splitting
multipath routes to sequences of route updates), while accepting both
old-style routes and RTA_MULTIPATH routes in scans / notifications.

As IPv6 RTA_MULTIPATH support is here for a long time, this patch fully
switches Netlink to the IPv6 RTA_MULTIPATH API and removes old complex
code for handling individual next hop announces.

The required Linux version is at least 4.11 for reliable operation.

Thanks to Daniel Gröber for the original patch.

3 years agoMerge branch 'master' into backport
Ondrej Zajicek [Sun, 24 Jul 2022 18:08:02 +0000 (20:08 +0200)] 
Merge branch 'master' into backport

3 years agoKRT: Scan routing tables separetely on linux to avoid congestion
Ondrej Zajicek [Sun, 24 Jul 2022 00:15:20 +0000 (02:15 +0200)] 
KRT: Scan routing tables separetely on linux to avoid congestion

Remove compile-time sysdep option CONFIG_ALL_TABLES_AT_ONCE, replace it
with runtime ability to run either separate table scans or shared scan.

On Linux, use separate table scans by default when the netlink socket
option NETLINK_GET_STRICT_CHK is available, but retreat to shared scan
when it fails.

Running separate table scans has advantages where some routing tables are
managed independently, e.g. when multiple routing daemons are running on
the same machine, as kernel routing table modification performance is
significantly reduced when the table is modified while it is being
scanned.

Thanks Daniel Gröber for the original patch and Toke Høiland-Jørgensen
for suggestions.

3 years agoFixed a rarely used part of Babel: comparing two routes in table by their metric
Maria Matejka [Fri, 22 Jul 2022 13:48:20 +0000 (15:48 +0200)] 
Fixed a rarely used part of Babel: comparing two routes in table by their metric

3 years agoRevert "Export table: Delay freeing of old stored route."
Maria Matejka [Fri, 22 Jul 2022 13:37:21 +0000 (15:37 +0200)] 
Revert "Export table: Delay freeing of old stored route."

This reverts commit cee0cd148c9b71bf47d007c850193b5fbf9486c1.
This change is not needed in version 2 and the surrounding code has
disappeared mostly in version 3.

3 years agoBGP: Minor improvements to BGP roles
Ondrej Zajicek [Tue, 12 Jul 2022 13:03:17 +0000 (15:03 +0200)] 
BGP: Minor improvements to BGP roles

Add support for bgp_otc in filters and warning for configuration
inside confederations.

3 years agoBGP: Implement BGP roles
Eugene Bogomazov [Mon, 11 Jul 2022 15:19:34 +0000 (17:19 +0200)] 
BGP: Implement BGP roles

Implement BGP roles as described in RFC 9234. It is  a mechanism for
route leak prevention and automatic route filtering based on common BGP
topology relationships. It defines role capability (controlled by 'local
role' option) and OTC route attribute, which is used for automatic route
filtering and leak detection.

Minor changes done by commiter.

3 years agoAdded forgotten route source locking in flowspec validation
Maria Matejka [Mon, 11 Jul 2022 11:04:01 +0000 (13:04 +0200)] 
Added forgotten route source locking in flowspec validation

3 years agoMerge remote-tracking branch 'origin/master' into backport
Maria Matejka [Mon, 11 Jul 2022 09:08:10 +0000 (11:08 +0200)] 
Merge remote-tracking branch 'origin/master' into backport

3 years agoMerge commit 'beb5f78a' into backport
Maria Matejka [Mon, 11 Jul 2022 08:41:17 +0000 (10:41 +0200)] 
Merge commit 'beb5f78a' into backport

3 years agoMerge version 2.0.10 into backport
Maria Matejka [Sun, 10 Jul 2022 12:19:24 +0000 (14:19 +0200)] 
Merge version 2.0.10 into backport

3 years agoFilter: Implement for loops
Ondrej Zajicek (work) [Mon, 14 Mar 2022 19:36:20 +0000 (20:36 +0100)] 
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>

3 years agoFilter: Implement mixed declarations of local variables
Ondrej Zajicek (work) [Thu, 10 Mar 2022 00:02:45 +0000 (01:02 +0100)] 
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";
}

3 years agoFilter: Improve handling of stack frames in filter bytecode
Ondrej Zajicek (work) [Wed, 9 Mar 2022 01:32:29 +0000 (02:32 +0100)] 
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.

3 years agoFilter: Simplify handling of command sequences
Ondrej Zajicek (work) [Tue, 8 Mar 2022 23:31:39 +0000 (00:31 +0100)] 
Filter: Simplify handling of command sequences

Command sequences in curly braces used a separate nonterminal in grammar.
Handle them as a regular command.

3 years agoFilter: Fix bug in variable shadowing
Ondrej Zajicek (work) [Sun, 6 Mar 2022 21:57:33 +0000 (22:57 +0100)] 
Filter: Fix bug in variable shadowing

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.

3 years agoFilter: Implement soft scopes
Ondrej Zajicek (work) [Sun, 6 Mar 2022 15:37:30 +0000 (16:37 +0100)] 
Filter: Implement soft scopes

Soft scopes are anonymous scopes that most likely do not contain any
symbol, so allocating regular scope is postponed when it is really
needed.

3 years agoFilter: Implement direct recursion
Ondrej Zajicek (work) [Sun, 6 Mar 2022 01:18:01 +0000 (02:18 +0100)] 
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.

3 years agoFilter: Apply constant promotion for FI_EQ / FI_NEQ
Ondrej Zajicek (work) [Fri, 4 Mar 2022 16:51:50 +0000 (17:51 +0100)] 
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.

3 years agoFilter: Add literal for empty set
Alexander Zubkov [Fri, 4 Mar 2022 13:07:58 +0000 (14:07 +0100)] 
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.

3 years agoNest: Cleanups in as_path_filter()
Ondrej Zajicek (work) [Fri, 4 Mar 2022 01:01:34 +0000 (02:01 +0100)] 
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.

3 years agoFilter: Ensure that all expressions declared return type
Ondrej Zajicek (work) [Thu, 3 Mar 2022 19:34:44 +0000 (20:34 +0100)] 
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.

3 years agoFilter: Improve description of type system
Ondrej Zajicek (work) [Thu, 3 Mar 2022 14:11:05 +0000 (15:11 +0100)] 
Filter: Improve description of type system

3 years agoFilter: Implement type checks for function calls
Ondrej Zajicek (work) [Thu, 3 Mar 2022 02:38:12 +0000 (03:38 +0100)] 
Filter: Implement type checks for function calls

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.

3 years agoFilter: Clean up function call instruction
Ondrej Zajicek (work) [Tue, 1 Mar 2022 01:04:35 +0000 (02:04 +0100)] 
Filter: Clean up function call instruction

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.

3 years agoPreexport callback now takes the channel instead of protocol as argument next-preexport
Maria Matejka [Mon, 27 Jun 2022 17:04:22 +0000 (19:04 +0200)] 
Preexport callback now takes the channel instead of protocol as argument

Passing protocol to preexport was in fact a historical relic from the
old times when channels weren't a thing. Refactoring that to match
current extensibility needs.

3 years agoNEWS and version update v2.0.10
Ondrej Zajicek [Thu, 16 Jun 2022 00:58:37 +0000 (02:58 +0200)] 
NEWS and version update

3 years agoIPv4 flowspec literals should reject IPv6 prefices in a well-behaved way
Maria Matejka [Tue, 7 Jun 2022 08:35:48 +0000 (10:35 +0200)] 
IPv4 flowspec literals should reject IPv6 prefices in a well-behaved way

When writing flow4 { dst 2001:db8::dead:beef/128; }, BIRD crashed on an
not-well-debuggable segfault as it tried to copy the whole 128-bit
prefix into an IPv4-sized memory.

3 years agoBabel: Do not try to remove multicast seqno request objects from neighbour list
Ondrej Zajicek [Sun, 5 Jun 2022 02:03:43 +0000 (04:03 +0200)] 
Babel: Do not try to remove multicast seqno request objects from neighbour list

The Babel seqno request code keeps track of which seqno requests are
outstanding for a neighbour by putting them onto a per-neighbour list. When
reusing a seqno request, it will try to remove this node, but if the seqno
request in question was a multicast request with no neighbour attached this
will result in a crash because it tries to remove a list node that wasn't
added to any list.

Fix this by making the list remove conditional. Also fix neighbor removal
which were changing seqno requests to multicast ones instead of removing
them.

Fixes: ebd5751cdeb4 ("Babel: Seqno requests are properly decoupled from
neighbors when the underlying interface disappears").

Based on the patch from Toke Høiland-Jørgensen <toke@toke.dk>,
bug reported by Stefan Haller <stefan.haller@stha.de>, thanks.

3 years agoIO: Improve resolution of latency debugging messages
Ondrej Zajicek [Sat, 4 Jun 2022 15:54:08 +0000 (17:54 +0200)] 
IO: Improve resolution of latency debugging messages

3 years agoNest: Improve GC strategy for rtables
Ondrej Zajicek [Sat, 4 Jun 2022 15:34:57 +0000 (17:34 +0200)] 
Nest: Improve GC strategy for rtables

Use timer (configurable as 'gc period') to schedule routing table
GC/pruning to ensure that prune is done on time but not too often.

Randomize GC timers to avoid concentration of GC events from different
tables in one loop cycle.

Fix a bug that caused minimum inter-GC interval be 5 us instead of 5 s.

Make default 'gc period' adaptive based on number of routing tables,
from 10 s for small setups to 600 s for large ones.

In marge multi-table RS setup, the patch improved time of flushing
a downed peer from 20-30 min to <2 min and removed 40s latencies.

3 years agoMerge remote-tracking branch 'origin/master' into haugesund-to-2.0
Maria Matejka [Mon, 30 May 2022 13:20:21 +0000 (15:20 +0200)] 
Merge remote-tracking branch 'origin/master' into haugesund-to-2.0

3 years agoMerge commit '9eec503b251c3388579032b300d32640403d8612' into haugesund-to-2.0
Maria Matejka [Mon, 30 May 2022 13:20:05 +0000 (15:20 +0200)] 
Merge commit '9eec503b251c3388579032b300d32640403d8612' into haugesund-to-2.0

3 years agoMerge commit '692055e3df6cc9f0d428d3b0dd8cdd8e825eb6f4' into haugesund-to-2.0
Maria Matejka [Mon, 30 May 2022 13:17:52 +0000 (15:17 +0200)] 
Merge commit '692055e3df6cc9f0d428d3b0dd8cdd8e825eb6f4' into haugesund-to-2.0

3 years agoCI: Remove broken FreeBSD builds
Ondrej Zajicek [Fri, 27 May 2022 14:07:24 +0000 (16:07 +0200)] 
CI: Remove broken FreeBSD builds

We currently do not have FreeBSD CI workers.

3 years agoBGP: Display neighbor port on show protocol
Ondrej Zajicek [Sat, 21 May 2022 14:21:34 +0000 (16:21 +0200)] 
BGP: Display neighbor port on show protocol

3 years agoRPKI: Display cache server port on show protocol
Ondrej Zajicek [Sat, 21 May 2022 14:03:08 +0000 (16:03 +0200)] 
RPKI: Display cache server port on show protocol

Thanks to Luiz Amaral for the idea.

3 years agoRPKI: Implement VRF support
Luiz Amaral [Thu, 19 May 2022 17:43:59 +0000 (19:43 +0200)] 
RPKI: Implement VRF support

3 years agoBGP: Improve tx performance during feed/flush
Ondrej Zajicek [Sun, 15 May 2022 13:05:13 +0000 (15:05 +0200)] 
BGP: Improve tx performance during feed/flush

The prefix hash table in BGP used the same hash function as the rtable.
When a batch of routes are exported during feed/flush to the BGP, they
all have similar hash values, so they are all crowded in a few slots in
the BGP prefix table (which is much smaller - around the size of the
batch - and uses higher bits from hash values), making it much slower due
to excessive collisions. Use a different hash function to avoid this.

Also, increase the batch size to fill 4k BGP packets and increase minimum
BGP bucket and prefix hash sizes to avoid back and forth resizing during
flushes.

This leads to order of magnitude faster flushes (on my test data).

3 years agoFixed spurious undef of route attributes
Alexander Zubkov [Wed, 4 May 2022 13:37:23 +0000 (15:37 +0200)] 
Fixed spurious undef of route attributes

3 years agoDoc: fix mating -> matching in flowspec section
Vincent Bernat [Fri, 22 Apr 2022 15:06:27 +0000 (17:06 +0200)] 
Doc: fix mating -> matching in flowspec section

3 years agoBabel: Fix compilation when LOCAL_DEBUG is set in packets.c
Toke Høiland-Jørgensen [Fri, 22 Apr 2022 15:04:56 +0000 (17:04 +0200)] 
Babel: Fix compilation when LOCAL_DEBUG is set in packets.c

The debug output was not updated with the rest of the code, so packets.c
fails to compile if LOCAL_DEBUG is set.

3 years agoBabel: Send out low-interval hello on shutdown
Toke Høiland-Jørgensen [Fri, 22 Apr 2022 14:41:52 +0000 (16:41 +0200)] 
Babel: Send out low-interval hello on shutdown

When shutting down a Babel instance we send a wildcard retraction to make
sure all peers can quickly switch to other route origins. Add another small
optimisation borrowed from babeld: sending a Hello message (along with the
retraction) with a very low interval.

This will cause neighbours to modify their expiry timers for the node's
state to quickly time it out, thus conserving resources in the network.

3 years agoRIP: fixed the EA_RIP_FROM attribute
Maria Matejka [Wed, 13 Apr 2022 15:05:12 +0000 (17:05 +0200)] 
RIP: fixed the EA_RIP_FROM attribute

The interface pointer was improperly converted to u32 and back. Fixing
this by explicitly allocating an adata structure for it. It's not so
memory efficient, we'll optimize this later.

3 years agoFixed a munmap abort bug
Maria Matejka [Wed, 13 Apr 2022 09:28:15 +0000 (11:28 +0200)] 
Fixed a munmap abort bug

When BIRD was munmapping too many pages, it sometimes aborted, saying
that munmap failed with "Not enough memory" as the address space was
getting more and more fragmented.

There is a workaround in place, simply keeping that page for future use,
yet it has never been compiled in because I somehow forgot to include
errno.h. And because I also thought that somebody may have ENOMEM not
defined (why?!), there was a check which quietly omitted that
workaround.

Anyway, ENOMEM is POSIX. It's an utter nonsense to check for its
existence. If it doesn't exist, something is broken.

3 years agoBFD: Add 'strict bind' option
Ondrej Zajicek (work) [Thu, 7 Apr 2022 17:33:40 +0000 (19:33 +0200)] 
BFD: Add 'strict bind' option

Add BFD protocol option 'strict bind' to use separate listening socket
for each BFD interface bound to its address instead of using shared
listening sockets.

3 years agoBGP uses lp_save / lp_restore instead of linpool flushing
Maria Matejka [Tue, 5 Apr 2022 13:09:56 +0000 (15:09 +0200)] 
BGP uses lp_save / lp_restore instead of linpool flushing

It is too cryptic to flush tmp_linpool in these cases and we don't want
anybody in the future to break this code by adding an allocation
somewhere which should persist over that flush.

Saving and restoring linpool state is safer.

3 years agoAll linpools use pages to allocate regular blocks
Maria Matejka [Mon, 4 Apr 2022 20:34:14 +0000 (22:34 +0200)] 
All linpools use pages to allocate regular blocks

3 years agoBGP: Fixed LLGR depreferencing in bgp_rte_mergable
Maria Matejka [Tue, 22 Mar 2022 13:39:32 +0000 (14:39 +0100)] 
BGP: Fixed LLGR depreferencing in bgp_rte_mergable

3 years agoProtocols have their own explicit init routines
Maria Matejka [Fri, 18 Mar 2022 21:05:50 +0000 (22:05 +0100)] 
Protocols have their own explicit init routines

3 years agoUnsetting route attributes without messing with type system
Maria Matejka [Mon, 14 Mar 2022 10:13:48 +0000 (11:13 +0100)] 
Unsetting route attributes without messing with type system

3 years agoEattr flags (originated and fresh) get their own struct fields
Maria Matejka [Mon, 14 Mar 2022 09:06:44 +0000 (10:06 +0100)] 
Eattr flags (originated and fresh) get their own struct fields

3 years agoMinor fix: f_val literals should always have named struct fields
Maria Matejka [Wed, 16 Mar 2022 09:22:49 +0000 (10:22 +0100)] 
Minor fix: f_val literals should always have named struct fields

3 years agoConverted Slab allocator to typed lists
Maria Matejka [Mon, 4 Apr 2022 18:31:25 +0000 (20:31 +0200)] 
Converted Slab allocator to typed lists