0
0
mirror of https://gitlab.nic.cz/labs/bird.git synced 2024-12-22 17:51:53 +00:00
Commit Graph

1751 Commits

Author SHA1 Message Date
Igor Putovny
470facb69b Use refactored first pass function 2024-05-30 12:30:00 +02:00
Igor Putovny
07d3f682ad Remove debugging logs 2024-05-30 12:30:00 +02:00
Igor Putovny
24a450a817 Add more assertions 2024-05-30 12:30:00 +02:00
Igor Putovny
d5930c4f76 Add modified implementation of the first pass 2024-05-30 12:30:00 +02:00
Igor Putovny
c1f7d66a47 Remove debugging logs 2024-05-30 12:30:00 +02:00
Igor Putovny
7dd30de09d Add variable to track node depth in the trie 2024-05-30 12:30:00 +02:00
Igor Putovny
09a013fbad Add small check to the first pass of ORTC algorithm 2024-05-30 12:30:00 +02:00
Igor Putovny
24cf9cbf43 Remove code duplication 2024-05-30 12:30:00 +02:00
Igor Putovny
347b322dd9 Check correct address types during aggregation configuration 2024-05-30 12:30:00 +02:00
Igor Putovny
21f689752a Collect and print prefixes according to address type 2024-05-30 12:30:00 +02:00
Igor Putovny
5cb2e20f4d Create default net based on adress type 2024-05-30 12:30:00 +02:00
Igor Putovny
e468296355 Create separate functions for inserting IP4 and IPv6 prefixes into trie 2024-05-30 12:30:00 +02:00
Igor Putovny
2247e45694 Use %N for printing net addresses 2024-05-30 12:30:00 +02:00
Igor Putovny
89c55c241e Use idiomatic functions for manipulating net_addr, remove unnecessary use of alloca 2024-05-30 12:30:00 +02:00
Igor Putovny
7644f7594b Bugfix
Program crashed when disabling aggregation protocol or shutting the daemon down.
Shutdown procedure attempted to remove the first route (which is the last that
was inserted) by different key than one by which it was inserted into the table.
They key is computed from net and src of each route. It turned out that src of
the last route was inadvertently changed.
2024-05-30 12:30:00 +02:00
Igor Putovny
9619284d20 Clear bit after setting it when collecting prefixes from trie 2024-05-30 12:30:00 +02:00
Igor Putovny
da65a073c5 Add debugging logs 2024-05-30 12:30:00 +02:00
Igor Putovny
ade731e02a Rename variables of type protocol in order to be consistent with the rest of the codebase 2024-05-30 12:30:00 +02:00
Igor Putovny
4621925ff4 Create and assign net to default route 2024-05-30 12:30:00 +02:00
Igor Putovny
0c1ac9674a Change a few logs 2024-05-30 12:30:00 +02:00
Igor Putovny
9d6d8b1adb Refactor functions for comparing buckets and computing union and intersection of buckets 2024-05-30 12:30:00 +02:00
Igor Putovny
dcf0038fd0 Run correct aggregation (by nets or by attributes) according to configuration 2024-05-30 12:30:00 +02:00
Igor Putovny
ecfb73332a Collect prefixes in trie after aggregation and export new routes 2024-05-30 12:30:00 +02:00
Igor Putovny
14d82bc053 Remove const from aggregator_bucket pointers in trie nodes 2024-05-30 12:30:00 +02:00
Igor Putovny
b265df526c Refactor printing prefixes in trie 2024-05-30 12:30:00 +02:00
Igor Putovny
518f3969e5 Remove configuration rule enforcing aggregation on NET 2024-05-30 12:30:00 +02:00
Igor Putovny
79981d2ad2 Bugfix
Due to wrong cast of void pointer, pointers to potential buckets
were compared and eventually sorted in wrong order, thus assigning
wrong buckets to trie nodes.
This caused some trie nodes to stay in trie even though they should
have been removed. Consequently, trie contained superfluos prefixes
after the algorithm finished.

Since pointers were never dereferenced, only compared by their numeric
values in the comparator function, program did not crash (even though
pointers could be NULL because of the incorrect cast to double pointer
and single dereference).
2024-05-30 12:30:00 +02:00
Igor Putovny
22060fe09f Add small changes to test script 2024-05-30 12:30:00 +02:00
Igor Putovny
03d71cb98c Remove unused code 2024-05-30 12:30:00 +02:00
Igor Putovny
24d9004d4d Add script to prepare test case run 2024-05-30 12:30:00 +02:00
Igor Putovny
e40ea2b98e Create default empty route for aggregation 2024-05-30 12:30:00 +02:00
Igor Putovny
f85e3a6ae5 Add more assertions 2024-05-30 12:30:00 +02:00
Igor Putovny
80f2d6e0c5 Make pointer to aggregator bucket const 2024-05-30 12:30:00 +02:00
Igor Putovny
fccb5140e2 Do not discard bucket from internal nodes 2024-05-30 12:30:00 +02:00
Igor Putovny
4a1f4e837d Do not assign bucket of any prefix to the root node 2024-05-30 12:30:00 +02:00
Igor Putovny
299f9e80f7 Create event to run ORTC algorithm exactly once 2024-05-30 12:30:00 +02:00
Igor Putovny
2b6cfd2065 Run ORTC algorithm 2024-05-30 12:30:00 +02:00
Igor Putovny
e68363df0f Add assertions and general code improvements 2024-05-30 12:30:00 +02:00
Igor Putovny
f1d280981e Remove unused code 2024-05-30 12:30:00 +02:00
Igor Putovny
5bde9a161a Rename constant 2024-05-30 12:30:00 +02:00
Igor Putovny
2b18dea7c2 Fix how bucket for new leaf nodes is chosen 2024-05-30 12:30:00 +02:00
Igor Putovny
98621a741a Use net_addr_ip4 instead of ip4_addr for printing prefixes 2024-05-30 12:30:00 +02:00
Igor Putovny
6522bc04e4 Remove unused code 2024-05-30 12:30:00 +02:00
Igor Putovny
ef6a526588 Add comments 2024-05-30 12:30:00 +02:00
Igor Putovny
4352095801 Change order of parameters in a few functions 2024-05-30 12:30:00 +02:00
Igor Putovny
dca392e7c6 Simplify delete_trie() function 2024-05-30 12:30:00 +02:00
Igor Putovny
1cf73f74ac Assign bucket of ancestor node to leaf node 2024-05-30 12:30:00 +02:00
Igor Putovny
7213cc08f3 Fix incorrect implementation of the third pass 2024-05-30 12:30:00 +02:00
Igor Putovny
2d2354f54e Assign route bucket only to the last inserted node 2024-05-30 12:30:00 +02:00
Igor Putovny
1712d83c01 Fix argument order in several functions 2024-05-30 12:30:00 +02:00
Igor Putovny
ec1eb83bf0 Add a few comments, print prefixes after aggregation 2024-05-30 12:30:00 +02:00
Igor Putovny
7657d05592 Extend remove_node() with deleting root node 2024-05-30 12:30:00 +02:00
Igor Putovny
26ac6dca5c Fix aggregator_bucket_unionize()
The last two while loops were incorrectly placed inside the first while loop
2024-05-30 12:30:00 +02:00
Igor Putovny
9954b24f57 Fix const warning, add few comments 2024-05-30 12:30:00 +02:00
Igor Putovny
f7161a875f Delete trie during aggregator shutdown 2024-05-30 12:30:00 +02:00
Igor Putovny
6d5e75e46d Refactor and fix aggregator_bucket_unionize() 2024-05-30 12:30:00 +02:00
Igor Putovny
45c7a5463e Fix aggregator_bucket_intersect(), add comments and fix naming 2024-05-30 12:30:00 +02:00
Igor Putovny
d046a0a42f Remove unused code 2024-05-30 12:30:00 +02:00
Igor Putovny
5a933c6fe5 Add new implementation of third_pass() and remove old implementation 2024-05-30 12:30:00 +02:00
Igor Putovny
ca4a1dc9d3 Move trie initialization to aggregator_start() 2024-05-30 12:30:00 +02:00
Igor Putovny
7d93e8b7d3 Fix previous version, aggregator is now stable but untested 2024-05-30 12:30:00 +02:00
Igor Putovny
2d822231d4 Implement basics of prefix aggregation functionality 2024-05-30 12:30:00 +02:00
Maria Matejka
ccc5166280 Aggregator: Fixed hashing of adata 2024-05-30 12:30:00 +02:00
Maria Matejka
a582ee9c6d Aggregator moved to a separate protocol
Also updated data structures and reconfigure.

Known bug: the hash doesn't take adata into account. Needs fixing!
2024-05-30 12:30:00 +02:00
Maria Matejka
732b3981b5 Aggregator: polishing of filter API 2024-05-30 12:30:00 +02:00
Igor Putovny
c48de3cf85 Basic route aggregation
User can specify list of route attributes in the configuration file
and run route aggregation on the export side of the pipe protocol.
Routes are sorted and for every group of equivalent routes
new route is created and exported to the routing table.
It is also possible to specify filter which will run for every
route before aggregation.
Furthermore, it will be possible to set attributes of new routes
according to attributes of the aggregated routes.

This is a work in progress.
2024-05-30 12:30:00 +02:00
Maria Matejka
9bdc769851 Conf: config warnings show the file position 2024-05-30 12:30:00 +02:00
Maria Matejka
0323471062 Conf: Symbol manipulation gets its context explicitly 2024-05-30 12:30:00 +02:00
Maria Matejka
51e8996fff Conf: Symbol hashes for all scopes
This is a backport cherry-pick of commits
  165156beeb
  cce974e8ea

from the v3.0 branch as we need symbol hashes directly inside their
scopes for more general usage than before.

The redefinable keywords must be specified in any .Y file as follows:

  toksym: THE_KEYWORD ;
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
7b3b8a8949 Babel: Minor changes to RTT formatting
Use existing %t printf code and move 'ms' in CLI output to table header.
2024-05-30 12:30:00 +02:00
Toke Høiland-Jørgensen
ed3b730ac3 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
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
d7163f6427 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
d44409f0c0 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
57da33172c 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
8f78c232f6 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
62aa714175 BMP: Fix reconfiguration
It is not supported, but at least it must update internal config
pointer to not keep old one.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
2f62d91b61 BMP: Allow build without BMP and disable BMP build by default
It has still several important issues to be enabled by default.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
f965e12d07 BMP: Move initialization to bmp_start()
That fixes BMP socket allocation from an invalid pool.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
549d8a991d BMP: Fix missing template
It is mandatory for protocol.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
106d206728 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
9a9752bfbe BMP: Remove duplicate functions for update encoding
Use existing BGP functions also for BMP update encoding.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
e7789317b2 BMP: Integrate bmp_conn to bmp_proto
There is only one socket per BMP instance, no need to have separate
struct (like in BGP).
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
767c820e57 BMP: Minor cleanups
Remove redundant 'disable' option, simplify IP address serialization,
and remove useless macros.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
3ab2dd3fd3 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().
2024-05-30 12:30:00 +02:00
Ondrej Zajicek (work)
43b3ea8c64 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.
2024-05-30 12:30:00 +02:00
Pawel Maslanka
25598fdf11 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.
2024-05-30 12:30:00 +02:00
Trisha Biswas
67d412fe1a 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
f6e421a2d3 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.
2024-05-30 12:30:00 +02:00
Maria Matejka
d14fd36d76 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
0cd944f119 BGP: Update RFC references 2024-05-30 12:30:00 +02:00
Ondrej Zajicek
80bd3f4806 Babel: Update RFC references 2024-05-30 12:30:00 +02:00
Toke Høiland-Jørgensen
3266fcb7e3 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.
2024-05-30 12:30:00 +02:00
Andreas Rammhold
9bb5eda3f0 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.
2024-05-30 12:30:00 +02:00
Toke Høiland-Jørgensen
d3ea843389 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
da3624d662 Babel: Improve clarity of unfeasible update handling.
Add a comment and (unnecessary) check to make correctness obvious.
2024-05-30 12:30:00 +02:00
Toke Høiland-Jørgensen
df8e86d85f 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
248b505e1f 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
084f5381f1 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.
2024-05-30 12:30:00 +02:00
Ondrej Zajicek
f8c5c22817 BGP: Add received role value to role mismatch log message 2024-05-30 12:30:00 +02:00
Ondrej Zajicek
e82b966b58 Minor cleanups 2024-05-30 12:30:00 +02:00