Ondrej Zajicek [Thu, 27 Mar 2025 16:43:56 +0000 (17:43 +0100)]
BFD: Fix crash related to reconfiguration and passwords
Any change in BFD iface configuration should trigger session
reconfiguration, as config is copied into the bfd_session structure
and not just accessed through the bfd_iface structure.
As bfd_session now contains a pointer to the password list allocated
from the configuration, forgetting to update the bfd_session causes
use-after-free.
Ondrej Zajicek [Mon, 24 Mar 2025 16:09:25 +0000 (17:09 +0100)]
BGP: Add option to specify format of link-local next hop
When a BGP session is established using link-local next hop addresses,
there is no global IPv6 address for next hop. Implementations differ on
how to encode such next hop. This leads to interoperability problems.
Add the option 'link local next hop format' to specify which format to
use when encoding such next hops.
Based on a patch from Andrey V. Elsukov and Georgy Kirichenko, submitted
by Aleksandr Stepanov, thanks!
Ondrej Zajicek [Thu, 6 Mar 2025 02:43:15 +0000 (03:43 +0100)]
Nest: Fix locking of tables by channels
Channels that are down keep ptr on routing tables but do not keep them
locked. It is safe because the existence of tables depend on being
configured. But when a table is removed during reconfiguration, the
channel kept a dangling pointer since it fell down until it was removed.
This could be triggered by 'show protocols all' and other similar.
Change locking so that a channel kept a table locked for its whole
existence. The same change is already in BIRD 3.
Note that this is somewhat conceptually problematic as downed channels
do not keep resources. Also, other objects in specialized channels
(igp_table, base_table in bgp_channel, mpls_domain / mpls_range in
mpls_channel) are still locked only when channel is active, but for
them it is easier to keep track that they are not accessed when
they are deconfigured.
Ondrej Zajicek [Thu, 9 Jan 2025 15:44:51 +0000 (16:44 +0100)]
lib: Unify alignment of allocators
Different internal allocators (memory blocks, linpools, and slabs) used
different way to compute alignment. Unify it to use alignment based on
standard max_align_t type.
On x86_64, this does not change alignment of memory blocks and linpools
(both old and new is 16), but it increases alignment of slabs from 8 to
16.
Maria Matejka [Tue, 3 Dec 2024 16:27:09 +0000 (17:27 +0100)]
CI: test building single protocols
Several users build BIRD with excluded support for protocols they don't
need. Testing single-protocol builds; the assumption is that if single
protocols and all protocols are buildable, then possibly any reasonable
combination is buildable as well.
Ondrej Zajicek [Tue, 17 Dec 2024 08:00:42 +0000 (09:00 +0100)]
Nest: Fix handling of 64-bit rte_src.private_id
The commit 21213be523baa7f2cbf0feaa617f265c55e9b17a expanded private_id
in route source to u64, but forgot to modify function arguments, so it
was still cropped at 32-bit, which may cause some collisions for L3VPN.
This patch fixes that.
Ondrej Zajicek [Thu, 12 Dec 2024 03:04:07 +0000 (04:04 +0100)]
Netlink: Handle onlink flag on BSD-Netlink
On BSD, the onlink flag is not tracked or reported by kernel. We are
using an heuristic that assigns the onlink flag to routes scanned from
the kernel. We should use the same heuristic even in BSD-Netlink
case, as the onlink flag is not reported here too.
Fabian Bläse [Tue, 10 Dec 2024 01:14:06 +0000 (02:14 +0100)]
Babel: fix seqno wrapping on seqno request
The Babel seqno wraps around when reaching its maximum value (UINT16_MAX).
When comparing seqnos, this has to be taken into account. Therefore,
plain number comparisons do not work.
Ondrej Zajicek [Fri, 6 Dec 2024 03:06:16 +0000 (04:06 +0100)]
BGP: Graceful restart timer overrides
Implement several options (min/max graceful restart time, min/max long
lived stale time) to override graceful restart and long-lived graceful
restart timer values, as suggested by RFC 9494.
Ondrej Zajicek [Tue, 3 Dec 2024 00:19:44 +0000 (01:19 +0100)]
RPKI: Fix several errors in handling of Error PDU
Fix several errors including:
- Unaligned memory access to 'Length of Error Text' field
- No validation of 'Length of Encapsulated PDU' field
- No validation of 'Error Code' field
- No validation of characters in diagnostic message
Maria Matejka [Thu, 14 Nov 2024 19:43:35 +0000 (20:43 +0100)]
CLI: Dumping internal data structures to files, not to debug output
All the 'dump something' CLI commands now have a new mandatory
argument -- name of the file where to dump the data. This allows
for more flexible dumping even for production deployments where
the debug output is by default off.
Also the dump commands are now restricted (they weren't before)
to assure that only the appropriate users can run these time consuming
commands.
Maria Matejka [Thu, 14 Nov 2024 22:34:28 +0000 (23:34 +0100)]
Printf: impossible buffer overflow fix
When printing near the end of the buffer, there was an overflow in two cases:
(1) %c and size is zero
(2) %1N, %1I, %1I4, %1I6 (auto-fill field_width for Net or IP), size is
more than actual length of the net/ip but less than the auto-filled
field width.
Manual code examination showed that nothing could have ever triggered
this behavior. All older versions of BIRD, including BIRD 3 development
versions, are totally safe. This exact overflow has been found while
implementing a new feature in later commits.
Ondrej Zajicek [Sun, 1 Dec 2024 23:00:36 +0000 (00:00 +0100)]
BMP: Refactor route monitor message serialization
Instead of several levels of functions, just have two functions
(one for routes, the other for end-of-rib), this allows to create
messages in a simple linear fashion.
Also reduce three duplicite functions to construct BGP header for
BMP messages to just one.
Maria Matejka [Tue, 17 Sep 2024 14:27:54 +0000 (16:27 +0200)]
BMP: simplified update queuing and better memory performance
This commit is quite a substantial rework of the underlying layers in
BMP TX:
- several unnecessary layers of indirection dropped, including most of
the original BMP's buffer machinery
- all messages are now written directly into one protocol's buffer
allocated for the whole time big enough to fit every possible message
- output blocks are allocated by pages and immediately returned when
used, improving the overall memory footprint
- no intermediary allocation is done from the heap altogether
- there is a documented and configurable limit on the TX queue size
Maria Matejka [Thu, 28 Nov 2024 13:10:40 +0000 (14:10 +0100)]
RPKI: refactored pdu to host byte order conversion
We shouldn't convert bytes 2 and 3 of the PDU blindly, there are several
cases where these are used by bytes. Instead, the conversion is done
only where needed.
This fixes misinterpretation bug of ASPA PDU flags on little endian
architectures.
Maria Matejka [Wed, 27 Nov 2024 11:01:58 +0000 (12:01 +0100)]
String tests: fixed too strict strcmp checks
The strcmp function is not guaranteed to return -1 or +1
but any negative or positive value if the input strings
are different. Fixed the false assumption which triggered
a build bug on emulated arm64.
Ondrej Zajicek [Wed, 27 Nov 2024 03:15:16 +0000 (04:15 +0100)]
Fixed crash if logging happened in unit tests
The patch initializes logging in unit tests. Previously, unit tests did
not initialize logging and other subsystems, just resources. But
resource_init() could under certain circumstances trigger logging and
cause crash.
The bug was Found by Jakub Ruzicka, dissected by David Petera and Maria
Matejka, disguised as failing build for Debian arm64 in pbuilder
emulation which did not like disabling THP.
Ondrej Zajicek [Tue, 26 Nov 2024 16:46:27 +0000 (17:46 +0100)]
RPKI: Fix PDU length check
The END_OF_DATA PDU was extended in version 1, so it has different length
in different versions. We should do the PDU length check according to its
version.
Piotr Wydrych [Tue, 5 Nov 2024 17:53:22 +0000 (18:53 +0100)]
CLI: Add timeformat command
Adds ability to override time format of show commands for current CLI session
so that it does not depend on configuration and may ease parsing when CLI is
called from tools.
Eric Long [Wed, 16 Oct 2024 19:32:36 +0000 (21:32 +0200)]
Flowspec: Fix IPv6 prefix when offset is not multiple of 8
Current implementation handles flowspec prefix length and offset only
in bytes, but RFC 8956 (Dissemination of Flow Specification Rules for
IPv6) Section 3.1 [1] and example in Section 3.8.2 [2] states the
pattern should begin right after offset *bits*.
For example, pattern "::1:1234:5678:9800:0/60-104" is currently
serialized as "02 68 3c 01 12 34 56 78 98", but it should shift its
pattern 4 more bits to the left: "02 68 3c 11 23 45 67 89 80".
This patch implements shifting left/right for IPv6 type and use it to
correct the behaviour. Test data are replaced with the correct ones.
Ondrej Zajicek [Tue, 8 Oct 2024 17:34:51 +0000 (19:34 +0200)]
Filter: Fixes and improvements related to case/sets
Unify grammar for set_atom and switch_atom to avoid inconsistencies
between them. Fix errors in documentation related to case statement
and set type. Change 'vpnrd' to 'rd' to be consistent with the filter
language.