0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 09:41:54 +00:00
Commit Graph

470 Commits

Author SHA1 Message Date
Ondrej Zajicek
161aef353a Lib: Ensure that all net_addr structures have the same alignment
Also weaken the explicit alignment of net_addr to be u32, as VPN
is already u32-aligned.
2024-12-16 18:56:30 +01:00
Ondrej Zajicek
34b7d77e06 Lib: Data type for VPN route distinguishers
Use a distinct data structure for VPN route distinguishers instead
of just u64.
2024-12-16 18:27:42 +01:00
Ondrej Zajicek
6a55359b1e 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.
2024-12-06 04:06:16 +01:00
Ondrej Zajicek
ef45611850 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
2024-12-03 01:19:44 +01:00
Maria Matejka
d85fa48e3a Slab: Write out all block pointers when asked for dump 2024-12-02 06:54:54 +01:00
Maria Matejka
ceab028326 Linpool: Write out all block pointers when asked for dump 2024-12-02 06:54:54 +01:00
Maria Matejka
da8a23277e 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.
2024-12-02 06:54:54 +01:00
Maria Matejka
4dd5b3d90e Logging: exposing vlog() to log va_lists 2024-12-02 04:27:30 +01:00
Maria Matejka
7ee27418a7 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.
2024-12-02 04:27:30 +01:00
Maria Matejka
460321cfe9 Formatting numbers with order prefixes
Unit tests by Ondrej Zajicek.
2024-11-29 16:06:07 +01:00
Maria Matejka
54499f8850 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.
2024-11-27 12:01:58 +01:00
Ondrej Zajicek
49be4a0329 Lib: Optimized printing of numbers
One simple trick makes printing of numbers ~4x faster.
2024-11-08 18:54:13 +01:00
Ondrej Zajicek
5c6572c422 Lib: Optimized printing of IP addresses
Makes printing network prefixes ~15x faster.
2024-11-08 18:51:54 +01:00
Maria Matejka
38195ac628 ASPA: fixed the check algorithm to actually do what is in the RFC
The original algorithm assumed principles not consistent with the RFC
and could have lead to false invalids.

Also added filter tests showing also how the ASPA literals are used in
the static protocol.
2024-11-07 15:08:14 +01:00
Eric Long
072821e55e 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.

Minor changes and test vectors done by committer.

[1]: https://www.rfc-editor.org/rfc/rfc8956.html#section-3.1
[2]: https://www.rfc-editor.org/rfc/rfc8956.html#section-3.8.2
2024-10-16 21:32:36 +02:00
Ondrej Zajicek
6f9ccfae9e Flowspec: Test improvements
Simplify Flowspec initialization macros.

Add examples from RFC 8955 4.3 and RFC 8956 3.8 to format tests.
2024-10-16 04:04:46 +02:00
Ondrej Zajicek
acbdc29d57 Lib: Expand timer recurrence to 64b
The period of recurent timers was stored in 32b field, despite it was
btime-compatible value in us. Therefore, it was limited to ~72 min,
which mas okay for most purposes, except configurable MRT dump periods.

Thanks to Felix Friedlander for the bugreport.
2024-08-27 14:28:41 +02:00
Maria Matejka
09f50f3766 Typed lists: added forgotten #undef 2024-06-27 04:14:38 +02:00
Maria Matejka
f27004fb4d Backported typed list updates from v3
Source: dda37842dc
2024-06-27 04:14:38 +02:00
Alexander Zubkov
8a40bccffe BFD: Add option to accept zero checksum for IPv6 UDP packets
Some vendors do not fill the checksum for IPv6 UDP packets.
For interoperability with such implementations one can set
UDP_NO_CHECK6_RX socket option on Linux.

Thanks to Ville O for the suggestion.

Minor changes by committer.
2024-06-26 16:29:57 +02:00
Ondrej Zajicek
3327d61298 Lib: Fix BSD build 2024-05-30 02:11:06 +02:00
Ondrej Zajicek
c130b4e1ae Lib: Use access() function attribute 2024-05-29 13:03:10 +02:00
Ondrej Zajicek
2d6fb31cd1 Lib: Use alloc_size() function attribute 2024-05-28 16:41:24 +02:00
Maria Matejka
08571b2059 ASPA: basic data structures and Static protocol support 2024-03-25 14:15:30 +01:00
Ondrej Zajicek
114be2af28 Filter: Add route attribute gw_mpls_stack
Add route attribute gw_mpls_stack to make MPLS stack of route nexthop
accessible from filters. Its type is T_CLIST, which is really not correct
(as it is a list, while T_CLIST is a set). Therefore, we keep this
attribute *undocumented* and it will be *changed* without further notice.

Based on a patch from Trisha Biswas <tbiswas@fastly.com>, thanks!
2024-03-05 16:47:08 +01:00
Alexander Zubkov
574d7eb241 BGP: Allow multiple EBGP neighbors with the same peer.
We can distinguish BGP sessions if at least one side uses a different IP
address. Extend olock mechanism to handle local IP as a part of key, with
optional wildcard, so BGP sessions could local IP in the olock and not
block themselves.
2024-02-07 19:11:10 +01:00
Ondrej Zajicek
2c7555cf2a Log: Add support for UDP logging
Add support for UDP logging, using RFC 3164 syslog protocol.

Based on the patch from Alexander Zubkov <green@qrator.net>, thanks!
2023-12-13 04:01:09 +01:00
Ondrej Zajicek
c5c3a22bcc Conf: Bytestrings with hex: should use the same general format as ones without.
Either hex:01234567, or hex:01:23:45:67. No confusing formats like
hex:0123:4567🆎cdef, which looks like there is an implicit zero byte.
2023-10-06 04:59:47 +02:00
Ondrej Zajicek
e338c4b63c Lib: Extend MPLS label allocator bitmap
Add function lmap_last_one_in_range() for finding the last active label
in a label range.
2023-10-04 13:07:33 +02:00
Ondrej Zajicek
333ddd4f98 MPLS subsystem
The MPLS subsystem manages MPLS labels and handles their allocation to
MPLS-aware routing protocols. These labels are then attached to IP or VPN
routes representing label switched paths -- LSPs.

There was already a preliminary MPLS support consisting of MPLS label
net_addr, MPLS routing tables with static MPLS routes, remote labels in
next hops, and kernel protocol support.

This patch adds the MPLS domain as a basic structure representing local
label space with dynamic label allocator and configurable label ranges.
To represent LSPs, allocated local labels can be attached as route
attributes to IP or VPN routes with local labels as attributes.

There are several steps for handling LSP routes in routing protocols --
deciding to which forwarding equivalence class (FEC) the LSP route
belongs, allocating labels for new FECs, announcing MPLS routes for new
FECs, attaching labels to LSP routes. The FEC map structure implements
basic code for managing FECs in routing protocols, therefore existing
protocols can be made MPLS-aware by adding FEC map and delegating
most work related to local label management to it.
2023-10-04 13:01:21 +02:00
Ondrej Zajicek (work)
e55696a4f8 Lib: Indirect bitmap for MPLS label allocator 2023-10-04 13:01:21 +02:00
Maria Matejka
8674d7ab4b Aggregator: Fixed hashing of adata 2023-09-26 15:46:24 +02:00
Ondrej Zajicek
eddc0ffdab Lib: Add functions for reading and writing of bytestrings
Based on patch from Alexander Zubkov, thanks!
2023-08-24 04:19:07 +02:00
Toke Høiland-Jørgensen
d8cf3cad51 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.
2023-06-02 00:26:41 +02:00
Ondrej Zajicek
b0e97617d9 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).
2023-05-18 16:02:02 +02:00
Ondrej Zajicek
9b471e72d7 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.
2023-04-27 17:09:00 +02:00
Maria Matejka
335409248e 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.
2023-04-20 19:33:00 +02:00
Ondrej Zajicek
6b38285f58 Net: Replace runtime checks with STATIC_ASSERT() 2023-03-06 11:57:40 +01:00
Petr Vaněk
0f679438f3 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.
2023-03-06 11:33:27 +01:00
Maria Matejka
6c058ae40c 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.
2023-02-22 14:54:09 +01:00
Mike Crute
64a2b7aaa3 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.
2023-01-12 17:40:53 +01:00
Maria Matejka
097f157182 Merge commit '692055e3df6cc9f0d428d3b0dd8cdd8e825eb6f4' into haugesund-to-2.0 2022-05-30 15:17:52 +02:00
Maria Matejka
7e86ff2076 All linpools use pages to allocate regular blocks 2022-04-06 18:14:08 +02:00
Maria Matejka
170b20701c Converted Slab allocator to typed lists 2022-04-06 18:14:08 +02:00
Maria Matejka
ebd807c0b8 Slab allocator can free the blocks without knowing the parent structure 2022-04-06 18:14:08 +02:00
Maria Matejka
3a6eda995e Typed lists for easier walking and stronger type checking 2022-04-06 18:14:08 +02:00
Ondrej Zajicek (work)
269bfff9bf Lib: Allow use of 240.0.0.0/4 as a private range
There were several requests to allow use of 240.0.0.0/4 as a private
range, and Linux kernel already allows such routes, so perhaps we can
allow that too.

Thanks to Vincent Bernat and others for suggestion and patches.
2022-03-16 20:01:18 +01:00
Maria Matejka
c53f547a0b Printf variant with a result allocated inside a pool / linpool 2022-03-15 11:21:46 +01:00
Maria Matejka
3c42f7af6a Slab memory allocator unit test 2022-03-14 17:37:56 +01:00
Maria Matejka
83d9920f90 Merge commit '5cff1d5f' into haugesund
Conflicts:
      proto/bgp/attrs.c
      proto/pipe/pipe.c
2022-03-09 10:56:06 +01:00