]> git.ipfire.org Git - thirdparty/bird.git/log
thirdparty/bird.git
13 months agoBGP: Fix bgp_med handling
Ondrej Zajicek [Tue, 4 Apr 2023 03:20:49 +0000 (05:20 +0200)] 
BGP: Fix bgp_med handling

Missing translation from BGP attribute ID to eattr ID in bgp_unset_attr()
broke automatic removal of bgp_med during export to EBGP peers.

Thanks to Edward Sun for the bugreport.

14 months agoAdd missing references to "show route in" in the cli-help and doc.
Johannes Moos [Sat, 18 Mar 2023 14:33:48 +0000 (15:33 +0100)] 
Add missing references to "show route in" in the cli-help and doc.

The feature of showing all prefixes inside the given one has been added
in v2.0.9 but not well documented. Fixing it by this update.

Text in doc and commit message added by commiter.

14 months agoBGP: Free bind applies also to outbound connections
Maria Matejka [Thu, 16 Mar 2023 18:23:19 +0000 (19:23 +0100)] 
BGP: Free bind applies also to outbound connections

Even though the free bind option is primarily meant to alleviate problems
with addresses assigned too late, it's also possible to use BIRD with AnyIP
configuration, assigning whole ranges to the machine. Therefore free bind
allows also to create an outbound connection from specific address even though
such address is not assigned.

14 months agoNet: Replace runtime checks with STATIC_ASSERT()
Ondrej Zajicek [Mon, 6 Mar 2023 10:57:40 +0000 (11:57 +0100)] 
Net: Replace runtime checks with STATIC_ASSERT()

14 months agoPrintf test suite fails on systems with musl libc because tests for "%m"
Petr Vaněk [Mon, 6 Mar 2023 10:19:30 +0000 (11:19 +0100)] 
Printf test suite fails on systems with musl libc because tests for "%m"
and "%M" formats expect "Input/output error" message but musl returns
"I/O error". Proposed change compares the printf output with string
returned from strerror function for EIO constant.

See-also: https://bugs.gentoo.org/836713

Minor change from committer.

14 months agoConfig: Dropping filter instruction trees after linearization
Maria Matejka [Thu, 16 Feb 2023 13:22:23 +0000 (14:22 +0100)] 
Config: Dropping filter instruction trees after linearization

14 months agoLinpool flush drops all the allocated pages but one
Maria Matejka [Wed, 22 Feb 2023 13:45:20 +0000 (14:45 +0100)] 
Linpool flush drops all the allocated pages but one

When a linpool is used to allocate a one-off big load of memory, it
makes no sense to keep that amount of memory for future use inside the
linpool. Contrary to previous implementations where the memory was
directly free()d, we now use the page allocator which has an internal
cache which keeps the released pages for us and subsequent allocations
simply get these released pages back.

And even if the page cleanup routine kicks in inbetween, the pages get
only madvise()d, not munmap()ed so performance aspects are negligible.

This may fix some memory usage peaks in extreme cases.

14 months agoBGP: Update RFC references
Ondrej Zajicek [Sun, 19 Feb 2023 14:35:07 +0000 (15:35 +0100)] 
BGP: Update RFC references

14 months agoBabel: Update RFC references
Ondrej Zajicek [Sun, 19 Feb 2023 14:34:43 +0000 (15:34 +0100)] 
Babel: Update RFC references

14 months agoConf: Fix too early free of old configuration
Ondrej Zajicek [Sun, 19 Feb 2023 02:59:10 +0000 (03:59 +0100)] 
Conf: Fix too early free of old configuration

The change 371eb49043d225d2bab8149187b813a14b4b86d2 introduced early free
of old_config. Unfortunately, it did not properly check whether it is not
still in use (blocked by obstacle during reconfiguration). Fix that.

It also means that we still could have a short peak when three configs
are in use (when a new reconfig is requeste while the previous one is
still active).

15 months agoBabel: Keep separate auth PC counters for unicast and multicast
Toke Høiland-Jørgensen [Tue, 14 Feb 2023 17:18:32 +0000 (18:18 +0100)] 
Babel: Keep separate auth PC counters for unicast and multicast

The babel protocol normally sends all its messages as multicast packets,
but the protocol specification allows most messages to be sent as either
unicast or multicast, and the two can be mixed freely. In particular, the
babeld implementation can be configured to unicast updates to all peers
instead of sending them as unicast.

Daniel discovered that this can cause problems with the packet counter
checks in the MAC extension due to packet reordering. This happens on WiFi
networks where clients have power save enabled (which is quite common in
infrastructure networks): in this case, the access point will buffer all
multicast traffic and only send it out along with its beacons, leading to a
maximum buffering in default Linux-based access point configuration of up
to 200 ms.

This means that a Babel sender that mixes unicast and multicast messages
can have the unicast messages overtake the multicast messages because of
this buffering; when authentication is enabled, this causes the receiver to
discard the multicast message when it does arrive because it now has a
packet counter value less than the unicast message that arrived before it.
Daniel observed that this happens frequently enough that Babel ceases to
work entirely when runner over a WiFi network.

The issue has been described in draft-ietf-babel-mac-relaxed, which is
currently pending RFC publication. That also describes two mitigation
mechanisms: Keeping separate PC counters for unicast and multicast, and
using a reorder window for PC values. This patch implements the former as
that is the simplest, and resolves the particular issue seen on WiFi.

Thanks to Daniel Gröber for the bugreport.

Minor changes from committer.

15 months agoBabel: Implement IPv4 via IPv6 extension (RFC 9229)
Andreas Rammhold [Tue, 14 Feb 2023 15:17:03 +0000 (16:17 +0100)] 
Babel: Implement IPv4 via IPv6 extension (RFC 9229)

The patch implements an IPv4 via IPv6 extension (RFC 9229) to the Babel
routing protocol (RFC 8966) that allows annoncing routes to an IPv4
prefix with an IPv6 next hop, which makes it possible for IPv4 traffic
to flow through interfaces that have not been assigned an IPv4 address.

The implementation is compatible with the current Babeld version.

Thanks to Toke Høiland-Jørgensen for early review on this work.

Minor changes from committer.

15 months agoDocumentation: Adding roadmap as decided in January 2023
Maria Matejka [Fri, 3 Feb 2023 08:12:34 +0000 (09:12 +0100)] 
Documentation: Adding roadmap as decided in January 2023

15 months agoBuild: Partial revert of one of previous changes
Ondrej Zajicek [Wed, 1 Feb 2023 18:30:21 +0000 (19:30 +0100)] 
Build: Partial revert of one of previous changes

There are many compatibility issues with echo -e, scratch that.

15 months agoBuild: Minor improvement to build output
Ondrej Zajicek [Wed, 1 Feb 2023 16:46:48 +0000 (17:46 +0100)] 
Build: Minor improvement to build output

15 months agoNest: Minor cleanup in buildsystem
Ondrej Zajicek [Wed, 1 Feb 2023 15:15:13 +0000 (16:15 +0100)] 
Nest: Minor cleanup in buildsystem

There ware missing dependencies for proto-build.c generation, which
sometimes lead to failed builds, and ignores changes in the set of
built protocols. Fix that, and also improve formatting of proto-build.c

15 months agoBabel: Initialise source seqno from incoming message
Toke Høiland-Jørgensen [Tue, 31 Jan 2023 14:52:14 +0000 (15:52 +0100)] 
Babel: Initialise source seqno from incoming message

When creating a new babel_source object we initialise the seqno to 0. The
caller will update the source object with the right metric and seqno value,
for both newly created and old source objects. However if we initialise the
source object seqno to 0 that may actually turn out to be a valid (higher)
seqno than the one in the routing table, because of seqno wrapping. In this
case the source metric will not be set properly, which breaks feasibility
tracking for subsequent updates.

To fix this, add a new initial_seqno argument to babel_get_source() which
is used when allocating a new object, and set that to the seqno value of
the update we're sending.

Thanks to Juliusz Chroboczek for the bugreport.

15 months agoBabel: Improve clarity of unfeasible update handling.
Ondrej Zajicek [Mon, 30 Jan 2023 22:49:20 +0000 (23:49 +0100)] 
Babel: Improve clarity of unfeasible update handling.

Add a comment and (unnecessary) check to make correctness obvious.

15 months agoBabel: Fix missing modulo comparison of seqnos
Toke Høiland-Jørgensen [Mon, 30 Jan 2023 22:36:39 +0000 (23:36 +0100)] 
Babel: Fix missing modulo comparison of seqnos

Juliusz noticed there were a couple of places we were doing straight
inequality comparisons of seqnos in Babel. This is wrong because seqnos can
wrap: so we need to use the modulo-64k comparison function for these cases
as well.

Introduce a strict-inequality version of the modulo-comparison for this
purpose.

15 months agoSmall fix of indenting
Alexander Zubkov [Mon, 23 Jan 2023 13:23:00 +0000 (14:23 +0100)] 
Small fix of indenting

15 months agoNEWS and version update v2.0.12
Ondrej Zajicek [Mon, 23 Jan 2023 01:23:19 +0000 (02:23 +0100)] 
NEWS and version update

15 months agoBFD: Improve incoming packet matching
Ondrej Zajicek [Sun, 22 Jan 2023 22:42:08 +0000 (23:42 +0100)] 
BFD: Improve incoming packet matching

For active sessions, ignore received packets with zero local id and
mismatched remote id. That forces a session timeout instead of an
immediate session restart. It makes BFD sessions more resilient to
packet spoofing.

Thanks to André Grüneberg for the suggestion.

15 months agoVRF: Fix issues with reconfiguration
Ondrej Zajicek [Sun, 22 Jan 2023 17:12:04 +0000 (18:12 +0100)] 
VRF: Fix issues with reconfiguration

Protocols receive if_notify() announcements that are filtered according
to their VRF setting, but during reconfiguration, they access iface_list
directly and forgot to check VRF setting here, which leads to all
interfaces be addedd.

Fix this issue for Babel, OSPF, RAdv and RIP protocols.

Thanks to Marcel Menzel for the bugreport.

15 months agoAdded test case for switch bug fixed in e20bef69ccc4a85ef62359ee539c9db2dbe09127
Maria Matejka [Sun, 22 Jan 2023 11:55:31 +0000 (12:55 +0100)] 
Added test case for switch bug fixed in e20bef69ccc4a85ef62359ee539c9db2dbe09127

15 months agoBGP: Add received role value to role mismatch log message
Ondrej Zajicek [Fri, 20 Jan 2023 14:55:47 +0000 (15:55 +0100)] 
BGP: Add received role value to role mismatch log message

15 months agoAlloc: Minor cleanups
Ondrej Zajicek [Wed, 18 Jan 2023 12:40:21 +0000 (13:40 +0100)] 
Alloc: Minor cleanups

 - Fix THP disable on old systems
 - Failed syscalls should use die() instead of bug()
 - Our printf uses %ld for s64 instead of long

15 months agoMerge branch 'master' of https://gitlab.nic.cz/labs/bird
Maria Matejka [Wed, 18 Jan 2023 11:33:06 +0000 (12:33 +0100)] 
Merge branch 'master' of https://gitlab.nic.cz/labs/bird

15 months agoFix memory pre-allocation
Maria Matejka [Wed, 18 Jan 2023 08:39:45 +0000 (09:39 +0100)] 
Fix memory pre-allocation

When BIRD has no free memory mapped, it allocates several pages in
advance just to be sure that there is some memory available if needed.
This hysteresis tactics works quite well to reduce memory ping-ping with
kernel.

Yet it had a subtle bug: this pre-allocation didn't take a memory
coldlist into account, therefore requesting new pages from kernel even
in cases when there were other pages available. This led to slow memory
bloating.

To demonstrate this behavior fast enough to be seen well, you may:
  * temporarily set the values in sysdep/unix/alloc.c as follows to
    exacerbate the issue:
      #define KEEP_PAGES_MAIN_MAX    4096
      #define KEEP_PAGES_MAIN_MIN    1000
      #define CLEANUP_PAGES_BULK     4096
  * create a config file with several millions of static routes
  * periodically disable all static protocols and then reload config
  * log memory consumption

This should give you a steady growth rate of about 16kB per cycle. If
you don't set the values this high, the issue happens much more slowly,
yet after 14 days of running, you are going to see an OOM kill.

After this fix, pre-allocation uses the memory coldlist to get some hot
pages and the same test as described here gets you a perfectly stable
constant memory consumption (after some initial wobbling).

Thanks to NIX-CZ for reporting and helping to investigate this issue.
Thanks to Santiago for finding the cause in the code.

16 months agoFilter: Allow setting the 'onlink' route attribute in filters
Radu Carpa [Tue, 17 Jan 2023 17:13:37 +0000 (18:13 +0100)] 
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;

16 months agoAlloc: Disable transparent huge pages
Ondrej Zajicek [Tue, 17 Jan 2023 16:13:50 +0000 (17:13 +0100)] 
Alloc: Disable transparent huge pages

The usage pattern implemented in allocator seems to be incompatible with
transparent huge pages, as memory released using madvise(MADV_DONTNEED)
with regular page size and alignment does not seem to trigger demotion
of huge pages back to regular pages, even when significant number of
pages is released. Even if demotion is triggered when system memory
is low, it still breaks memory accounting.

16 months agoBuild: Fix cleanup of nest/proto-build.c
Ondrej Zajicek [Fri, 13 Jan 2023 15:44:42 +0000 (16:44 +0100)] 
Build: Fix cleanup of nest/proto-build.c

16 months agoMinor cleanups
Ondrej Zajicek [Fri, 13 Jan 2023 12:32:29 +0000 (13:32 +0100)] 
Minor cleanups

16 months agoBSD: Add support for kernel route metric
Ondrej Zajicek [Fri, 13 Jan 2023 12:17:46 +0000 (13:17 +0100)] 
BSD: Add support for kernel route metric

Add support for kernel route metric/priority, exported as krt_metric
attribute, like in Linux. This should also fix issues with overwriting
or removing system routes.

16 months agoLog message before aborting
Mike Crute [Thu, 12 Jan 2023 16:40:53 +0000 (17:40 +0100)] 
Log message before aborting

Log message before aborting due to watchdog timeout. We have to use
async-safe write to debug log, as it is done in signal handler.

Minor changes from committer.

16 months agoFilter: Change linearization of branches in switch instruction
Ondrej Zajicek [Sat, 7 Jan 2023 19:18:44 +0000 (20:18 +0100)] 
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.

16 months agoBGP: Allow role specific keywords to be used as symbols
Ondrej Zajicek [Tue, 3 Jan 2023 18:09:51 +0000 (19:09 +0100)] 
BGP: Allow role specific keywords to be used as symbols

Some of these new BGP role keywords use generic names that collides with
user-defined symbols. Allow them to be redefined. Also remove duplicit
keyword definition for 'prefer'.

16 months agoConfigure: Expensive check option was broken, never worked
Ondrej Zajicek [Tue, 3 Jan 2023 16:14:48 +0000 (17:14 +0100)] 
Configure: Expensive check option was broken, never worked

16 months 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.

16 months 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.

16 months 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

16 months 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.

16 months 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+

17 months 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.

17 months 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.

17 months 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.

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

17 months 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.

17 months 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.

17 months 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.

17 months 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

17 months 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.

17 months 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.

17 months 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.

17 months 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.

17 months 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

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

17 months 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

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

18 months 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.

18 months 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.

18 months 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

18 months 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

18 months 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.

18 months 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

19 months 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"

19 months 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.

19 months 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.

19 months 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.

19 months 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.

19 months 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.

19 months 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

19 months 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.

19 months 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

19 months 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.

20 months 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.

20 months 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.

20 months 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

20 months 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

21 months 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

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

21 months 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

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

21 months 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).

21 months 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.

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

21 months 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.

21 months 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

21 months 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.

22 months 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.

22 months 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.

22 months 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

22 months 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

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

22 months 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

22 months 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>

22 months 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";
}

22 months 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.

22 months 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.

22 months 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.

22 months 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.