Commit graph

766 commits

Author SHA1 Message Date
Maria Matejka
ff397df7ed Routing table is now a resource allocated from its own pool
This also fixes memory leaks from import/export tables being never
cleaned up and freed.
2021-03-30 21:56:08 +02:00
Maria Matejka
886dd92eee Slab: head now uses bitmask for used/free nodes info instead of lists
From now, there are no auxiliary pointers stored in the free slab nodes.
This led to strange debugging problems if use-after-free happened in
slab-allocated structures, especially if the structure's first member is
a next pointer.

This also reduces the memory needed by 1 pointer per allocated object.
OTOH, we now rely on pages being aligned to their size's multiple, which
is quite common anyway.
2021-03-25 16:47:48 +01:00
Ondrej Zajicek (work)
82f19ba95e NEWS and version update 2021-03-18 20:18:38 +01:00
Ondrej Zajicek (work)
7be3af7fa6 Rate-limit scheduling of work-events
In general, events are code handling some some condition, which is
scheduled when such condition happened and executed independently from
I/O loop. Work-events are a subgroup of events that are scheduled
repeatedly until some (often significant) work is done (e.g. feeding
routes to protocol). All scheduled events are executed during each
I/O loop iteration.

Separate work-events from regular events to a separate queue and
rate limit their execution to a fixed number per I/O loop iteration.
That should prevent excess latency when many work-events are
scheduled at one time (e.g. simultaneous reload of many BGP sessions).
2021-03-12 15:35:56 +01:00
Vincent Bernat
714238716e BGP: Add support for BGP hostname capability
This is an implementation of draft-walton-bgp-hostname-capability-02.
It is implemented since quite some time for FRR and in datacenter, this
gives a nice output to avoid using IP addresses.

It is disabled by default. The hostname is retrieved from uname(2) and
can be overriden with "hostname" option. The domain name is never set
nor displayed.

Minor changes by committer.
2021-02-10 16:53:57 +01:00
Ondrej Zajicek (work)
df83f62697 Netlink: Ignore dead routes
With net.ipv4.conf.XXX.ignore_routes_with_linkdown sysctl, a user can
ensure the kernel does not use a route whose target interface is down.
Such route is marked with a 'dead' / RTNH_F_DEAD flag.

Ignore these routes or multipath nexthops during scan.

Thanks to Vincent Bernat for the original patch.
2021-01-14 02:01:07 +01:00
Ondrej Zajicek (work)
2a8cc7259e Kernel: Do not check templates
So one can define kernel protocol template without channels.
For other protocols, it is either irrelevant or already done.

Thanks to Clemens Schrimpe for the bugreport.
2021-01-07 01:56:00 +01:00
Ondrej Zajicek (work)
21f9acd2a0 Kernel: Fix handling of krt_realm with ECMP routes
For ECMP routes, RTA_FLOW attribute must be set per-nexthop, not
per-route. Our corresponding krt_realm attribute is per-route.

Thanks to Mikhail Petrov for the bugreport.
2021-01-06 05:25:59 +01:00
Ondrej Zajicek (work)
62d57b9bdf Log: Fix locking during log reconfiguration
The log subsystem should be locked earlier, as default_log_list() may
internally manipulate with the current_log_list (if it is also a default
log list).
2020-11-25 15:15:13 +01:00
Ondrej Zajicek (work)
0ef082c51e Log: Reinitialize the static logging structures
The static logging structures are reused, we need to reinitialize them
otherwise add_tail() would fail in debug build. Reinitializing these
structures should be fine as the list they belong to is being
reinitialized on entry to the very same function.

Thanks to Andreas Rammhold and Mikael Magnusson for patches.
2020-11-25 15:04:34 +01:00
Kazuki Yamaguchi
f1b5f179db Netlink: Fix parsing of MPLS multipath routes
Add support for RTA_MULTIPATH attribute parsing for AF_MPLS routes.

BIRD is capable of installing a multipath route into kernel on Linux,
but it would not be seen because parsing fails. This made BIRD attempt
to install the same route repeatedly.

(The patch minorly updated by committer)
2020-06-03 15:18:02 +02:00
Ondrej Zajicek (work)
fae5448134 Log: Do not open logfiles when parse-and-exit option is active
This is a quick workaround for an issue where configured logfiles are
opened/created during parsing of a config file even when parse-and-exit
option is active. We should later refactor the logging code to avoid
opening log during parsing altogether.
2020-06-03 14:59:20 +02:00
Maria Matejka
cdde3550dc Unix socket: Path length check directly before copying the path.
This is not needed as the string is always short enough, anyway
it may be needed in future and one strlen during BIRD start is
cheap enough.
2020-05-01 15:19:12 +02:00
Maria Matejka
258be56539 Nest: Added const to ea_show just to declare that this shouldn't really change anything 2020-05-01 15:19:12 +02:00
Maria Matejka
fd9f0c0640 Configuration strings are constant.
This is merely a const propagation. There was no problem in there.
2020-04-09 15:37:14 +02:00
Ondrej Zajicek (work)
e2630a494e Netlink: Handle interfaces with missing broadcast addresses 2020-03-07 05:11:21 +01:00
Ondrej Zajicek (work)
757cab18d6 BGP: Support for MD5SIG together with remote range
When dynamic BGP with remote range is configured, MD5SIG needs to use
newer socket option (TCP_MD5SIG_EXT) to specify remote addres range for
listening socket.

Thanks to Adam Kułagowski for the suggestion.
2020-02-27 17:29:17 +01:00
Maria Matejka
ab089f4fb5 Conf: Better error message when reading iproute2 config
Reported by: Martin Weinelt <martin@darmstadt.freifunk.net>
2020-02-04 10:34:46 +01:00
Ondrej Zajicek (work)
7d767c5a3d KRT: Improve syncer code to avoid using temporary data in rtable
The old code stored route verdicts and temporary routes directly in
rtable. The new code do not store received routes (it immediately
compares them with exported routes and resolves conflicts) and uses
internal bitmap to keep track of which routes were received and which
needs to be reinstalled.

By not putting 'invalid' temporary routes to rtable, we keep rtable
in consistent state, therefore scan no longer needs to be atomic
operation and could be splitted to multiple events.
2020-01-07 18:35:03 +01:00
Ondrej Zajicek (work)
cc75b3e1dc KRT: Remove KRF_SYNC_ERROR flag
This info is now stored in an internal bmap. Unfortunately, net.flags
is still needed for temporary kernel data.
2019-12-19 16:34:35 +01:00
Ondrej Zajicek (work)
90a9c97e38 KRT: Fix removal of KRF_INSTALLED
Use route id from net->routes to check export_map. Route received from
sysdep KRT code does not have proper id.
2019-12-17 16:30:29 +01:00
Ondrej Zajicek (work)
c132acae36 KRT: Remove KRF_INSTALLED flag
The same information is stored in export_map of kernel protocol.
2019-12-16 02:42:24 +01:00
Ondrej Zajicek (work)
5ea39eaa96 Nest: Use bitmaps to keep track of exported routes
Use a hierarchical bitmap in a routing table to assign ids to routes, and
then use bitmaps (indexed by route id) in channels to keep track whether
routes were exported. This avoids unreliable and inefficient re-evaluation
of filters for old routes in order to determine whether they were exported.
2019-11-26 18:39:25 +01:00
Ondrej Zajicek
53401bef63 Netlink: Handle IPv4 routes with IPv6 nexthops
Accept RTA_VIA attribute in all cases. The old code always used
RTA_GATEWAY for IPv4 / IPv6 and RTA_VIA for MPLS. The new code uses
RTA_VIA in cases where AF of network and AF of nexthop differs.
2019-11-12 18:13:21 +01:00
Ondrej Zajicek
5ce881be82 Accept uppercase letters in iproute2 names
Names read from texfiles in /etc/iproute2/* are normalized by replacing
non-alphanumeric chars with underscore. The patch fixes handling of
uppercase letters, which were handled as non-alphanumberic.

Thanks to Igor Gavrilov for the bugreport.
2019-10-22 16:25:38 +02:00
Ondrej Zajicek (work)
b000a94275 NEWS and version update 2019-10-11 00:18:38 +02:00
Ondrej Zajicek (work)
759b204be3 Lib: Support for 64-bit numbers in bvsnprintf()
Use 'l' for s64/u64 instead of for long/ulong, as that is much more
useful. Also make number() correct with regard to signed/unsigned
typecasts.
2019-10-09 17:53:23 +02:00
Maria Matejka
24493e9169 Fixed undefined behavior on signals.
The C11 specification allows only sig_atomic_t and _Atomic variable
access. All other accesses to global variables are undefined behavior.

Using int was probably OK on x86 and x86_64; yet there were some reports
from other architectures (especially some MIPS) that in rare cases,
after issuing SIGHUP, BIRD did strange things.
2019-10-04 20:52:07 +02:00
Ondrej Zajicek (work)
9c79022153 Nest: Fix help for 'graceful restart' command
Multi-worded commands are not automatically added to top-level
help output.

Thanks to Christoph for the bugreport.
2019-09-23 14:52:31 +02:00
Ondrej Zajicek (work)
5235c3f78d NEWS and version update 2019-09-10 17:34:41 +02:00
Ondrej Zajicek (work)
5ab3447de1 Sysdep: Drop supplementary groups when dropping GID
We forgot to do that. Oops.
2019-08-21 17:30:00 +02:00
Ondrej Zajicek (work)
543875e080 NEWS and version update 2019-07-31 23:35:29 +02:00
Ondrej Zajicek (work)
96e4d0960c Change 'graceful down' command to 'graceful restart' and update docs
The command initiating planned graceful restart including bird shutdown
should be called 'graceful restart' instead of 'graceful down', as the
later should be reserved for graceful shutdown in style of RFC 8326.
2019-07-31 19:45:29 +02:00
Maria Matejka
48addc88be Log: Fixed race condition in reconfigure while BFD is running 2019-07-30 12:26:37 +02:00
Ondrej Zajicek (work)
cec40a7467 Merge remote-tracking branch 'origin/mq-filter-stack' 2019-07-24 15:38:32 +02:00
Ondrej Zajicek (work)
15b0a92294 RPKI: Fix reconfiguration when ssh parameters are undefined 2019-07-23 01:52:18 +02:00
Ondrej Zajicek (work)
2eaf65ec60 Netlink: Fix parsing of multipath routes with MPLS labels 2019-07-15 18:16:55 +02:00
Ondrej Zajicek (work)
8235c4747d Netlink: Use route replace for IPv4
Use route replace netlink op instead of delete+add netlink ops for kernel
IPv4 route replace. This avoids some packetloss during route replace.
Still use the old behavior for IPv6, as some kernel bugs are hidden in
IPv6 ECMP handling.
2019-07-15 16:23:18 +02:00
Maria Matejka
b2a4feeb4c Merge branch 'master' into mq-filter-stack 2019-07-10 11:27:08 +02:00
Maria Matejka
422a933429 Debug: growing message format buffer
This led in corner cases to undefined buffer content
and garbage output.
2019-07-10 11:12:41 +02:00
Maria Matejka
eac9250fd5 Merge branch 'master' into mq-filter-stack 2019-07-03 11:12:25 +02:00
Maria Matejka
78976974e7 Dynamic attributes definition split whether it is bitmask or not. 2019-07-03 00:00:11 +02:00
Ondrej Zajicek (work)
59d3a3611f Netlink: Handle alien routes with unsorted nexthops
Nest requires that nexthops are sorted, the kernel protocol have to
ensure that for alien routes.
2019-07-02 18:23:06 +02:00
Ondrej Zajicek (work)
1187627a1d Netlink: Do unified scan for both IPv4 and IPv6
Instead of separate scans for IPv4, IPv6 and MPLS, do one AF_UNSPEC scan.

This also avoids kernel issue when kernel reported IPv4 and IPv6 routes
during MPLS scan if MPLS is not active.
2019-07-02 16:30:36 +02:00
Ondrej Zajicek (work)
8a68316eb9 Nest: Add command to request graceful restart
When 'graceful down' command is entered, protocols are shut down
with regard to graceful restart. Namely Kernel protocol does
not remove routes and BGP protocol does not send notification,
just closes the connection.
2019-06-30 21:29:24 +02:00
Ondrej Zajicek (work)
9106a750cd Add CLI command to test reconfiguration status
Based on patch from Kenth Eriksson <kenth.eriksson@infinera.com>.
2019-06-12 17:15:35 +02:00
Ondrej Zajicek (work)
e0835db4f1 BGP: Dynamic BGP
Support for dynamically spawning BGP protocols for incoming connections.
Use 'neighbor range' to specify range of valid neighbor addresses, then
incoming connections from these addresses spawn new BGP instances.
2019-04-30 13:32:39 +02:00
Maria Matejka
7078aa63ae Fixed one warning and one undefined value. 2019-03-22 21:40:35 +01:00
Maria Matejka
8d65add626 Merge branch 'master' into HEAD 2019-03-18 12:54:40 +01:00
Ondrej Zajicek (work)
875cc073b0 Nest: Update handling of temporary attributes
The temporary atttributes are no longer removed by ea_do_prune(), but
they are undefined by store_tmp_attrs() protocol hooks. This fixes
several bugs where temporary attributes were removed when they should
not or not removed when they should be. The flag EAF_TEMP is no longer
needed and was removed.

Update all protocol make_tmp_attrs() / store_tmp_attrs() hooks to use
helper functions and to handle unset attributes properly.

Also fix some related bugs like improper handling of empty eattr list.
2019-03-14 17:31:40 +01:00