Commit graph

3823 commits

Author SHA1 Message Date
Ondrej Zajicek
ba2a076001 BGP: Improve tx performance during feed/flush
The prefix hash table in BGP used the same hash function as the rtable.
When a batch of routes are exported during feed/flush to the BGP, they
all have similar hash values, so they are all crowded in a few slots in
the BGP prefix table (which is much smaller - around the size of the
batch - and uses higher bits from hash values), making it much slower due
to excessive collisions. Use a different hash function to avoid this.

Also, increase the batch size to fill 4k BGP packets and increase minimum
BGP bucket and prefix hash sizes to avoid back and forth resizing during
flushes.

This leads to order of magnitude faster flushes (on my test data).
2022-05-15 15:05:37 +02:00
Vincent Bernat
207ac48533 Doc: fix mating -> matching in flowspec section 2022-04-22 17:06:27 +02:00
Toke Høiland-Jørgensen
d829800138 Babel: Fix compilation when LOCAL_DEBUG is set in packets.c
The debug output was not updated with the rest of the code, so packets.c
fails to compile if LOCAL_DEBUG is set.
2022-04-22 17:04:56 +02:00
Toke Høiland-Jørgensen
4aef70136d Babel: Send out low-interval hello on shutdown
When shutting down a Babel instance we send a wildcard retraction to make
sure all peers can quickly switch to other route origins. Add another small
optimisation borrowed from babeld: sending a Hello message (along with the
retraction) with a very low interval.

This will cause neighbours to modify their expiry timers for the node's
state to quickly time it out, thus conserving resources in the network.
2022-04-22 16:43:17 +02:00
Maria Matejka
9eec503b25 Fixed a munmap abort bug
When BIRD was munmapping too many pages, it sometimes aborted, saying
that munmap failed with "Not enough memory" as the address space was
getting more and more fragmented.

There is a workaround in place, simply keeping that page for future use,
yet it has never been compiled in because I somehow forgot to include
errno.h. And because I also thought that somebody may have ENOMEM not
defined (why?!), there was a check which quietly omitted that
workaround.

Anyway, ENOMEM is POSIX. It's an utter nonsense to check for its
existence. If it doesn't exist, something is broken.
2022-04-13 11:36:54 +02:00
Ondrej Zajicek (work)
692055e3df BFD: Add 'strict bind' option
Add BFD protocol option 'strict bind' to use separate listening socket
for each BFD interface bound to its address instead of using shared
listening sockets.
2022-04-07 19:33:40 +02:00
Ondrej Zajicek (work)
4b1aa37f93 Netlink: Remove superfluous sysdep/linux/netlink.c.orig
Thanks to Vincent Bernat for notice.
2022-03-16 23:16:26 +01: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
Vincent Bernat
c3828879a3 Pkg: Improve RPM package unit file
Update the RPM package unit file to check configuration before start and
to use "birdc configure" instead of "kill -HUP".
2022-03-11 15:47:00 +01:00
Ondrej Zajicek (work)
9b0b2c0d41 Client: Use exit status to report errors
When birdc is called with a command as an argument, it should set exit
status to non-zero when BIRD replied with an error reply code.

Thanks to Vincent Bernat and others for suggestion.
2022-03-11 03:52:50 +01:00
Ondrej Filip
5ddf98f6bd Small improvement in directory test 2022-03-02 10:52:09 +01:00
Ondrej Zajicek (work)
fcb4dd0c83 Babel: Fix bug in iface reconfiguration
A recent change in Babel causes ifaces to disappear after
reconfiguration. The patch fixes that.

Thanks to Johannes Kimmel for an insightful bugreport.
2022-02-27 03:10:38 +01:00
Ondrej Filip
eb859a3fb0 Small change to fix doc building on Debian 2022-02-20 15:30:47 +01:00
Ondrej Filip
9b13fa4d9c Small changes related to the new release 2022-02-20 14:28:06 +01:00
Ondrej Zajicek (work)
64d5d6d2c3 NEWS: Fix formatting and add some notes 2022-02-13 16:45:49 +01:00
Ondrej Zajicek (work)
71c9484b00 NEWS and version update 2022-02-09 03:47:49 +01:00
Ondrej Zajicek (work)
2fc8b4c4ba Alloc: Use posix_memalign() instead of aligned_alloc()
For compatibility with older systems use posix_memalign(). We can
switch to aligned_alloc() when we commit to C11 for multithreading.
2022-02-08 22:42:00 +01:00
Ondrej Zajicek (work)
ef614f2984 Netlink: Minor cleanup 2022-02-08 22:21:08 +01:00
Ondrej Zajicek (work)
edc1a24017 Lib: Update alignment of slabs
Alignment of slabs should be at least sizeof(ptr) to avoid unaligned
pointers in slab structures. Fixme: Use proper way to choose alignment
for internal allocators.
2022-02-07 04:39:49 +01:00
Ondrej Zajicek (work)
53a2540687 Merge branch 'oz-trie-table' 2022-02-06 23:42:10 +01:00
Ondrej Zajicek (work)
24600c642a Trie: Fix trie format
After switching to 16-way tries, trie format ignored unaligned / internal
prefixes and only reported the primary prefix of a trie node.

Fix trie format by showing internal prefixes based on the 'local' bitmask
of a node. Also do basic (intra-node) reconstruction of prefix patterns
by finding common subtrees in 'local' bitmask.

In future, we could improve that by doing inter-node reconstruction, so
prefixes entered as one pattern for a subtree (e.g. 192.168.0.0/18+)
would be reported as such, like with aligned prefixes.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
5a89edc6fd Nest: Implement locking of prefix tries during walks
The prune loop may may rebuild the prefix trie and therefore invalidate
walk state for asynchronous walks (used in 'show route in' cmd). Fix it
by adding locking that keeps the old trie in memory until current walks
are done.

In future this could be improved by rebuilding trie walk states (by
lookup for last found prefix) after the prefix trie rebuild.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
de6318f70a Nest: Implement prefix trie pruning
When rtable is pruned and network fib nodes are removed, we also need to
prune prefix trie. Unfortunately, rebuilding prefix trie takes long time
(got about 400 ms for 1M networks), so must not be atomic, we have to
rebuild a new trie while current one is still active. That may require
some considerable amount of temporary memory, so we do that only if
we expect significant trie size reduction.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
ba5aec94cd Trie: Add prefix counter
Add counter of prefixes stored in trie. Works only for 'restricted' tries
composed of explicit prefixes (pxlen == l == h), like ones used in rtables.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
d0f9a77f64 Doc: Describe routing table options 2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
1f2eb2aca8 BGP: Implement flowspec validation procedure
Implement flowspec validation procedure as described in RFC 8955 sec. 6
and RFC 9117. The Validation procedure enforces that only routers in the
forwarding path for a network can originate flowspec rules for that
network.

The patch adds new mechanism for tracking inter-table dependencies, which
is necessary as the flowspec validation depends on IP routes, and flowspec
rules must be revalidated when best IP routes change.

The validation procedure is disabled by default and requires that
relevant IP table uses trie, as it uses interval queries for subnets.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
1ae42e5223 Nest: Add routing table configuration blocks
Allow to specify sorted flag, trie fla, and min/max settle time.

Also do not enable trie by default, it must be explicitly enabled.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
fde1cff012 Nest: Add convenience functions to check rtable net type 2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
61375bd0b3 Nest: Avoid unnecessary net_format() in 'show route' command
When output of 'show route' command was generated, the net_format() was
called for each network prematurely, even if the result was not needed.

Fix the code to call net_format() only when needed. This makes queries
that process many networks but show only few (e.g. 'show route where ..',
or 'show route count') much faster (like 5x - 10x faster).
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
9ac16df3d7 Nest: Add trie iteration code to 'show route'
Add trie iteration code to rt_show_cont() CLI hook and use it to
accelerate 'show route in <addr>' commands using interval queries.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
ea97b89051 Nest: Implement 'show route in <addr>' command
Implement 'show route in <addr>' command, which shows all routes in
networks that are subnets of given network. Currently limited to IP
network types.
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
836a87b8ac Nest: Attach prefix trie to rtable for faster LPM and interval queries
Attach a prefix trie to IP/VPN/ROA tables. Use it for net_route() and
net_roa_check(). This leads to 3-5x speedups for IPv4 and 5-10x
speedup for IPv6 of these calls.

TODO:
 - Rebuild the trie during rt_prune_table()
 - Better way to avoid trie_add_prefix() in net_get() for existing tables
 - Make it configurable (?)
2022-02-06 23:27:13 +01:00
Ondrej Zajicek (work)
4c6ee53f31 BGP: Make routing loops silent
One of previous commits added error logging of invalid routes. This
also inadvertently caused error logging of route loops, which should
be ignored silently. Fix that.
2022-01-28 18:13:18 +01:00
Ondrej Zajicek (work)
963b2c7ce2 BGP: Use proper class in attribute error messages
Most error messages in attribute processing are in rx/decode step and
these use L_REMOTE log class. But there are few that are in tx/export
step and these should use L_ERR log class.

Use tx-specific macro (REJECT()) in tx/export code and rename field
err_withdraw to err_reject in struct bgp_export_state to ensure that
appropriate error reporting macros are called in proper contexts.
2022-01-28 05:35:22 +01:00
Ondrej Zajicek (work)
75d01ecc2d BGP: Improve 'invalid next hop' error reporting
Distinguish multiple causes of 'invalid next hop' message and report
the relevant next hop address.

Thanks to Simon Ruderich for the original patch.
2022-01-28 05:03:03 +01:00
Ondrej Zajicek (work)
9dbb7eb6eb BGP: Log route updates that were changed to withdraws
Typical BGP error handling is treat-as-withdraw, where an invalid route
is replaced with a withdraw. Log route network when it happens.
2022-01-24 03:44:21 +01:00
Matous Holinka
a9646efd40 .gitlab-ci.yml: minor changes inside the .yml file.
+ ubuntu:21.10 added into the pipeline,
- ubuntu:20.10 removed from the pipeline,

+ misc/docker/ubuntu-21.10-amd64/Dockerfile added,
- misc/docker/ubuntu-20.10-amd64/Dockerfile removed.
2022-01-17 05:17:50 +01:00
Ondrej Zajicek (work)
81ee6cda2e Netlink: Add option to specify netlink socket receive buffer size
Add option 'netlink rx buffer' to specify netlink socket receive buffer
size. Uses SO_RCVBUFFORCE, so it can override rmem_max limit.

Thanks to Trisha Biswas and Michal for the original patches.
2022-01-17 05:11:29 +01:00
Ondrej Zajicek (work)
bbc33f6ec3 Netlink: Add another workaround for older kernel headers
Unfortunately, SOL_NETLINK is both recently added and arch-dependent,
so we cannot just define it.
2022-01-15 22:39:40 +01:00
Ondrej Zajicek (work)
8988264a64 Netlink: Add workaround for older kernel headers 2022-01-14 23:15:05 +01:00
Ondrej Zajicek (work)
e818f16448 Netlink: Enable strict checking for KRT dumps
Add strict checking for netlink KRT dumps to avoid PMTU cache records
from FNHE table dump along with KRT.

Linux Kernel added FNHE table dump to the netlink API in patch:

8d3b68cd37.1561131177.git.sbrivio@redhat.com/

Therefore, since Linux 5.3 these route cache entries are dumped together
with regular routes during periodic KRT scans, which in some cases may be
huge amount of useless data. This can be avoided by using strict checking
for netlink dumps:

https://lore.kernel.org/netdev/20181008031644.15989-1-dsahern@kernel.org/

The patch mitigates the risk of receiving unknown and potentially large
number of FNHE records that would block BIRD I/O in each sync. There is a
known issue caused by the GRE tunnels on Linux that seems to be creating
one FNHE record for each destination IP address that is routed through
the tunnel, even when the PMTU equals to GRE interface MTU.

Thanks to Tomas Hlavacek for the original patch.
2022-01-14 21:53:40 +01:00
Ondrej Zajicek (work)
d0dd1d20cd Netlink: Explicitly skip received cloned routes
Kernel uses cloned routes to keep route cache entries, but reports them
together with regular routes. They were skipped implicitly as they
do not have rtm_protocol filled. Add explicit check for cloned flag
and skip such routes explicitly.

Also, improve debug logs of skipped routes.
2022-01-14 19:07:57 +01:00
Ondrej Zajicek (work)
60e9def9ef BGP: Add option 'free bind'
The BGP 'free bind' option applies the IP_FREEBIND/IPV6_FREEBIND
socket option for the BGP listening socket.

Thanks to Alexander Zubkov for the idea.
2022-01-09 02:44:32 +01:00
Alexander Zubkov
87a02489f3 IO: Support nonlocal bind in socket interface
Add option to socket interface for nonlocal binding, i.e. binding to an
IP address that is not present on interfaces. This behaviour is enabled
when SKF_FREEBIND socket flag is set. For Linux systems, it is
implemented by IP_FREEBIND socket flag.

Minor changes done by commiter.
2022-01-08 19:02:31 +01:00
Ondrej Zajicek (work)
bcb25084d3 Test: Activate some remaining build tests 2022-01-05 20:07:27 +01:00
Ondrej Zajicek (work)
f5c8fb5fba Netlink: Do not ignore dead routes from BIRD
Currently, BIRD ignores dead routes to consider them absent. But it also
ignores its own routes and thus it can not correctly manage such routes
in some cases. This patch makes an exception for routes with proto bird
when ignoring dead routes, so they can be properly updated or removed.

Thanks to Alexander Zubkov for the original patch.
2022-01-05 19:25:42 +01:00
Ondrej Zajicek (work)
77d032c71f Netlink: Improve multipath parsing errors
Function nl_parse_multipath() should handle errors internally.
2022-01-05 18:46:41 +01:00
Ondrej Zajicek (work)
29dda184e5 Conf: Fix parsing full-length IPv6 addresses
Lexer expression for bytestring was too loose, accepting also
full-length IPv6 addresses. It should be restricted such that
colon is used between every byte or never.

Fix the regex and also add some test cases for it.

Thanks to Alexander Zubkov for the bugreport
2022-01-05 16:38:49 +01:00
Matous
75aceadaf7 gitlab-ci.yml: failing gitlab runner fixed.
'registry.labs.nic.cz' -> 'registry.nic.cz' changed
2022-01-05 04:13:39 +01:00
Alexander Zubkov
77042292ff Doc: Document min/max operators for lists 2021-12-28 04:09:36 +01:00