]> git.ipfire.org Git - thirdparty/bird.git/log
thirdparty/bird.git
2 years agoAdditional CLI and TCP control sockets mq-tcp-control-socket
Maria Matejka [Mon, 5 Jun 2023 15:57:53 +0000 (17:57 +0200)] 
Additional CLI and TCP control sockets

2 years agoUndeffing unix.
Maria Matejka [Mon, 5 Jun 2023 15:24:49 +0000 (17:24 +0200)] 
Undeffing unix.

GCC defines, for historic reasons, unix as a numeric constant.
https://gcc.gnu.org/onlinedocs/cpp/System-specific-Predefined-Macros.html

2 years agoTyped lists: shortcut for simple nodes
Maria Matejka [Tue, 31 Jan 2023 13:30:35 +0000 (14:30 +0100)] 
Typed lists: shortcut for simple nodes

2 years agoBabel: Minor changes to RTT formatting
Ondrej Zajicek [Fri, 2 Jun 2023 00:34:05 +0000 (02:34 +0200)] 
Babel: Minor changes to RTT formatting

Use existing %t printf code and move 'ms' in CLI output to table header.

2 years agoBabel: Add support for the RTT extension
Toke Høiland-Jørgensen [Thu, 1 Jun 2023 22:31:53 +0000 (00:31 +0200)] 
Babel: Add support for the RTT extension

This adds support to the Babel protocol for the RTT extension specified
in draft-ietf-babel-rtt-extension. While this extension is not yet at the
RFC stage, it is one of the more useful extensions to Babel[0], so it
seems worth having in Bird as well.

The extension adds timestamps to Hello and IHU TLVs and uses these to
compute an RTT to each neighbour. An extra per-neighbour cost is then
computed from the RTT based on a minimum and maximum interval and cost
value specified in the configuration. The primary use case for this is
improving routing in a geographically distributed tunnel-based overlay
network.

The implementation follows the babeld implementation when picking
constants and default configuration values. It also uses the same RTT
smoothing algorithm as babeld, and follows it in adding a new 'tunnel'
interface type which enables RTT by default.

[0] https://alioth-lists.debian.net/pipermail/babel-users/2022-April/003932.html

2 years agoIO: Add current_time_now() function for immediate timestamp
Toke Høiland-Jørgensen [Thu, 1 Jun 2023 22:26:41 +0000 (00:26 +0200)] 
IO: Add current_time_now() function for immediate timestamp

Add a current_time_now() function which gets an immediate monotonic
timestamp instead of using the cached value from the event loop. This is
useful for callers that need precise times, such as the Babel RTT
measurement code.

Minor changes by committer.

2 years agoBGP: Fix role check when no capability option is present
Ondrej Zajicek [Thu, 18 May 2023 23:02:57 +0000 (01:02 +0200)] 
BGP: Fix role check when no capability option is present

When an OPEN message without capability options was parsed, the remote
role field was not initialized with the proper (non-zero) default value,
so it was interpreted as if 'provider' was announced.

Thanks to Mikhail Grishin for the bugreport.

2 years agoLib: Improve IP/net hashing
Ondrej Zajicek [Thu, 18 May 2023 13:55:45 +0000 (15:55 +0200)] 
Lib: Improve IP/net hashing

Backport some changes from branch oz-parametric-hashes. Replace naive
hash function for IPv6 addresses, fix hashing of VPNx (where upper half
of RD was ignored), fix hashing of MPLS labels (where identity was used).

2 years agoNest: Add tests and benchmark for FIB
Ondrej Zajicek [Tue, 16 May 2023 11:25:48 +0000 (13:25 +0200)] 
Nest: Add tests and benchmark for FIB

Basic fib_get() / fib_find() test for random prefixes, FIB_WALK() test,
and benchmark for fib_find(). Also generalize and reuse some code from
trie tests.

2 years agoConf: Improve handling of keywords
Ondrej Zajicek [Thu, 27 Apr 2023 16:20:49 +0000 (18:20 +0200)] 
Conf: Improve handling of keywords

For whatever reason, parser allocated a symbol for every parsed keyword
in each scope. That wasted time and memory. The effect is worsened with
recent changes allowing local scopes, so keywords often promote soft
scopes (with no symbols) to real scopes.

Do not allocate a symbol for a keyword. Take care of keywords that could
be promoted to symbols (kw_sym) and do it explicitly.

2 years agoConf: Fix symbol lookup
Ondrej Zajicek [Thu, 27 Apr 2023 15:09:00 +0000 (17:09 +0200)] 
Conf: Fix symbol lookup

The symbol table used just symbol name as a key, and used a trick with
active flag to find symbols in active scopes with one hash table lookup.

The disadvantage is that it can degenerate to O(n) for negative queries
in situations where are many symbols with the same name in different
scopes.

Thanks to Yanko Kaneti for the bugreport.

2 years agoNEWS and version update v2.13
Ondrej Zajicek [Fri, 21 Apr 2023 18:24:43 +0000 (20:24 +0200)] 
NEWS and version update

2 years agoFilter: Disable some trie formatting tests
Ondrej Zajicek [Fri, 21 Apr 2023 17:29:17 +0000 (19:29 +0200)] 
Filter: Disable some trie formatting tests

Trie formatting works slightly different with 4-way tries than with
16-way ones, so these tests generated false error. Block them for now.

2 years agoMerge branch 'bmp'
Ondrej Zajicek [Fri, 21 Apr 2023 02:47:55 +0000 (04:47 +0200)] 
Merge branch 'bmp'

2 years agoBMP: Add some basic documentation
Ondrej Zajicek [Fri, 21 Apr 2023 02:42:13 +0000 (04:42 +0200)] 
BMP: Add some basic documentation

2 years agoBSD: IPv4 over IPv6 nexthop support on FreeBSD
Luiz Amaral [Thu, 20 Apr 2023 23:37:30 +0000 (01:37 +0200)] 
BSD: IPv4 over IPv6 nexthop support on FreeBSD

The support for IPv4 routes with IPv6 nexthops was implemented in FreeBSD
13.1, this patch allows to import and export such routes from/to kernel.

Minor change from committer.

2 years agoLinpool: Fix lp_restore()
Maria Matejka [Thu, 20 Apr 2023 17:33:00 +0000 (19:33 +0200)] 
Linpool: Fix lp_restore()

When lp_save() is called on an empty linpool, then some allocation is
done, then lp_restore() is called, the linpool is restored but the used
chunks are inaccessible. Fix it.

2 years agoBMP: Silence some log messages
Ondrej Zajicek [Thu, 20 Apr 2023 15:14:45 +0000 (17:14 +0200)] 
BMP: Silence some log messages

Hooks called from BGP to BMP should not log warning when BMP is not
connected, that is not an error (and we do not want to flood logs with
a ton of messages).

Blocked sk_send() should not log warning, that is expected situation.
Error during sk_send() is handled in error hook anyway.

2 years agoBMP: Fix connection management
Ondrej Zajicek [Thu, 20 Apr 2023 14:13:58 +0000 (16:13 +0200)] 
BMP: Fix connection management

Replace broken TCP connection management with a simple state machine.
Handle failed attempts properly with a timeout, detect and handle TCP
connection close and try to reconnect after that. Remove useless
'station_connected' flag.

Keep open messages saved even after the BMP session establishment,
so they can be used after BMP session flaps.

Use proper log messages for session events.

2 years agoBMP: Fix reconfiguration
Ondrej Zajicek [Tue, 18 Apr 2023 16:57:54 +0000 (18:57 +0200)] 
BMP: Fix reconfiguration

It is not supported, but at least it must update internal config
pointer to not keep old one.

2 years agoBMP: Allow build without BMP and disable BMP build by default
Ondrej Zajicek [Tue, 18 Apr 2023 15:21:13 +0000 (17:21 +0200)] 
BMP: Allow build without BMP and disable BMP build by default

It has still several important issues to be enabled by default.

2 years agoBMP: Move initialization to bmp_start()
Ondrej Zajicek [Tue, 18 Apr 2023 13:13:24 +0000 (15:13 +0200)] 
BMP: Move initialization to bmp_start()

That fixes BMP socket allocation from an invalid pool.

2 years agoBMP: Fix missing template
Ondrej Zajicek [Tue, 18 Apr 2023 13:09:21 +0000 (15:09 +0200)] 
BMP: Fix missing template

It is mandatory for protocol.

2 years agoBMP: Add some missing bmp_buffer_free() calls
Ondrej Zajicek (work) [Thu, 15 Apr 2021 16:32:47 +0000 (18:32 +0200)] 
BMP: Add some missing bmp_buffer_free() calls

They were inadvertently removed during recent code refactoring.

Thanks to Dawid Macek for the bugreport and patch.

2 years agoBMP: Remove duplicate functions for update encoding
Ondrej Zajicek (work) [Mon, 29 Mar 2021 02:43:04 +0000 (04:43 +0200)] 
BMP: Remove duplicate functions for update encoding

Use existing BGP functions also for BMP update encoding.

2 years agoBMP: Integrate bmp_conn to bmp_proto
Ondrej Zajicek (work) [Sun, 28 Mar 2021 14:41:53 +0000 (16:41 +0200)] 
BMP: Integrate bmp_conn to bmp_proto

There is only one socket per BMP instance, no need to have separate
struct (like in BGP).

2 years agoBMP: Minor cleanups
Ondrej Zajicek (work) [Sun, 28 Mar 2021 13:36:59 +0000 (15:36 +0200)] 
BMP: Minor cleanups

Remove redundant 'disable' option, simplify IP address serialization,
and remove useless macros.

2 years agoBMP: Do not use global instance ptr internally
Ondrej Zajicek (work) [Sun, 28 Mar 2021 13:13:23 +0000 (15:13 +0200)] 
BMP: Do not use global instance ptr internally

Use local variable to refence relevant instance instead of using global
instance ptr. Also, use 'p' variable instead of 'bmp' so we can use
common macros like TRACE().

2 years agoBMP: Remove superfluous error handling
Ondrej Zajicek (work) [Sun, 28 Mar 2021 02:30:11 +0000 (04:30 +0200)] 
BMP: Remove superfluous error handling

Most error handling code was was for cases that cannot happen,
or they would be code bugs (and should use ASSERT()). Keep error
handling for just for I/O errors, like in rest of BIRD.

2 years agoBMP protocol support
Pawel Maslanka [Mon, 29 Mar 2021 20:45:21 +0000 (22:45 +0200)] 
BMP protocol support

Initial implementation of a basic subset of the BMP (BGP Monitoring
Protocol, RFC 7854) from Akamai team. Submitted for further review
and improvement.

2 years agoBGP: Add 'allow bgp_med' option for EBGP sessions
Trisha Biswas [Fri, 14 Apr 2023 02:28:37 +0000 (04:28 +0200)] 
BGP: Add 'allow bgp_med' option for EBGP sessions

This option allows to treat bgp_med as regular transitive attribute
on EBGP sessions (without hacks in filters).

Minor changes from committer.

2 years agoIncrease tests timeout
Jakub Ružička [Thu, 13 Apr 2023 18:06:55 +0000 (20:06 +0200)] 
Increase tests timeout

Tests may take longer than 5 s to complete on slow/virtual machines.

2 years 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.

2 years 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.

2 years 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.

2 years 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()

2 years 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.

2 years 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

2 years 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.

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

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

2 years 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).

2 years 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.

2 years 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.

2 years 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

2 years 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.

2 years 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

2 years 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

2 years 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.

2 years 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.

2 years 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.

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

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

2 years 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.

2 years 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.

2 years 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

2 years 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

2 years 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

2 years 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

2 years 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.

2 years 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;

2 years 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.

2 years 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

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

2 years 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.

2 years 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.

2 years 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.

2 years 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'.

2 years 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

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.