Commit graph

366 commits

Author SHA1 Message Date
Ondrej Zajicek (work) f9f2e280ea KRT: Forbid path merging on BSD
We support ECMP routes only on Linux. Exported routes are checked in
krt_capable(), but a route generated during path merging avoids this
check.
2016-08-30 12:43:46 +02:00
Ondřej Surý 33d22f0e9e whitespace fixes 2016-08-16 09:24:12 +02:00
Ondrej Zajicek (work) f0b822a831 Log: Fix error handling of debug file open
Logging is not yet initialized, we have to use fprintf() here.

Thanks to Pavel Tvrdik for noticing and debugging it.
2016-07-11 20:22:55 +02:00
Pavel Tvrdík 8f01879c56 cppcheck: fix va_end() functions 2016-06-27 15:07:50 +02:00
Jan Moskyto Matejka 9dbcb11cb5 Unix IO: Tried to fix strange behavior after POLLHUP or POLLERR. 2016-05-30 14:28:22 +02:00
Pavel Tvrdik 8e433d6a52 Prog Doc: Complete several missing parameters 2016-05-12 15:49:44 +02:00
Pavel Tvrdik f7a99acb4e Initialize variable ifr in sk_setup()
==00:00:00:02.831 2468== Syscall param socketcall.setsockopt(optval) points to uninitialised byte(s)
==00:00:00:02.831 2468==    at 0x513BDEA: setsockopt (in /usr/lib/libc-2.23.so)
==00:00:00:02.831 2468==    by 0x45C7AF: sk_setup (io.c:1216)
==00:00:00:02.831 2468==    by 0x45CDFF: sk_open (io.c:1417)
==00:00:00:02.831 2468==    by 0x44B562: rip_open_socket (packets.c:740)
==00:00:00:02.831 2468==    by 0x4481A7: rip_iface_locked (rip.c:616)
==00:00:00:02.831 2468==    by 0x4133E4: olock_run_event (locks.c:177)
==00:00:00:02.831 2468==    by 0x45A6DE: ev_run (event.c:85)
==00:00:00:02.831 2468==    by 0x45A7AD: ev_run_list (event.c:142)
==00:00:00:02.831 2468==    by 0x45E0FC: io_loop (io.c:2066)
==00:00:00:02.831 2468==    by 0x463B56: main (main.c:845)
==00:00:00:02.831 2468==  Address 0xffefffd24 is on thread 1's stack
==00:00:00:02.831 2468==  in frame #1, created by sk_setup (io.c:1188)
==00:00:00:02.831 2468==  Uninitialised value was created by a stack allocation
==00:00:00:02.831 2468==    at 0x45C6BB: sk_setup (io.c:1188)
2016-05-03 11:02:48 +02:00
Ondrej Zajicek (work) a7baa09862 BSD: Add the IPsec SA/SP database entries control
Add code for manipulation with TCP-MD5 keys in the IPsec SA/SP database
at FreeBSD systems. Now, BGP MD5 authentication (RFC 2385) keys are
handled automatically on both Linux and FreeBSD.

Based on patches from Pavel Tvrdik.
2016-04-13 14:37:09 +02:00
Ondrej Zajicek (work) f2ae2badff Main: Add local option
Add option that changes default paths for config file and control socket
to the current working directory.
2016-04-07 12:39:49 +02:00
Ondrej Zajicek (work) bd22d7f41d IO: Avoid multiple event cycles in one loop cycle.
Event cycle may took too much time and trigger next timer events, so
avoid cycling between timer and event cycles inside the loop cycle.
2016-04-06 11:57:28 +02:00
Ondrej Zajicek (work) 9e7b3ebdf9 IO: Replace RX priority heuristic with explicit mark
In BIRD, RX has lower priority than TX with the exception of RX from
control socket. The patch replaces heuristic based on socket type with
explicit mark and uses it for both control socket and BGP session waiting
to be established.

This should avoid an issue when during heavy load, outgoing connection
could connect (TX event), send open, but then failed to receive OPEN /
establish in time, not sending notifications between and therefore
got hold timer expired error from the neighbor immediately after it
finally established the connection.
2016-04-06 11:49:34 +02:00
Ondrej Zajicek (work) e86cfd41d9 KRT: Fix route learn scan when route changed
When a kernel route changed, function krt_learn_scan() noticed that and
replaced the route in internal kernel FIB, but after that, function
krt_learn_prune() failed to propagate the new route to the nest, because
it confused the new route with the (removed) old best route and decided
that the best route did not changed.

Wow, the original code (and the bug) is almost 17 years old.
2016-04-06 11:46:25 +02:00
Jan Moskyto Matejka ea0a8be2ff IO/Poll: fix mistaken variable merge
The events variable is used in the short loop decision. The reasons are
not much clear, keeping this to keep the former behaviour.
2016-03-30 16:21:32 +02:00
Jan Moskyto Matejka 9c92f69272 Unix: Substituted select -> poll also in congestion checker
It does strange things when even one fd larger than FD_SETSIZE is
passed to select().
2016-03-18 11:47:13 +01:00
Jan Moskyto Matejka fd926ed4ee Poll: Prevent the improbable case of EAGAIN after POLLIN 2016-03-15 14:57:49 +01:00
Jan Moskyto Matejka e1c13a5a7b Unix: Rework of select-loop to poll-loop
This should lift the limit of FD_SETSIZE and allow more than 1024 fd's.
FD_SETSIZE limit doesn't matter now when creating new sockets.
2016-03-11 12:45:10 +01:00
Ondrej Zajicek (work) c2106b674c Unix: Fix bug in syslog name handling
Pointer to current_log_name has to be changed even if the name is the
same, because the old one will be invalid/freed after reconfiguration.
2016-02-11 21:53:55 +01:00
Ondrej Zajicek (work) 1e4891e48e Nest: Fix bug in device proto
If an interface address notification is received during device protocol
shutdown/restart, BIRD crashed.

Thanks to Wei Huang for the bugreport.
2015-11-23 11:13:40 +01:00
Jan Moskyto Matejka 9ddbfbddf8 Netlink: Allow more than 256 routing tables.
Since 2.6.19, the netlink API defines RTA_TABLE routing attribute to
allow 32-bit routing table IDs. Using this attribute to index routing
tables at Linux, instead of 8-bit rtm_table field.
2015-11-11 11:40:49 +01:00
Ondrej Zajicek (work) 9b9a7143c4 Conf: Fixes bug in symbol lookup during reconfiguration
Symbol lookup by cf_find_symbol() not only did the lookup but also added
new void symbols allocated from cfg_mem linpool, which gets broken when
lookups are done outside of config parsing, which may lead to crashes
during reconfiguration.

The patch separates lookup-only cf_find_symbol() and config-modifying
cf_get_symbol(), while the later is called only during parsing. Also
new_config and cfg_mem global variables are NULLed outside of parsing.
2015-11-09 00:42:02 +01:00
Ondrej Zajicek (work) 3aed0a6ff7 IO: Fix the previous bugfix
I should check it after making some trivial changes. The original patch
from Alexander has it right.
2015-11-03 11:27:27 +01:00
Ondrej Zajicek (work) 338f85ca77 IO: Handle fd values too big for select()
If the number of sockets is too much for select(), we should at least
handle it with proper error messages and reject new sockets instead of
breaking the event loop.

Thanks to Alexander V. Chernikov for the patch.
2015-11-03 11:08:57 +01:00
Ondrej Zajicek 8d9eef1771 BGP multipath support
Kernel option 'merge paths' allows to merge routes exported to kernel
protocol (currently BGP and static routes) to multipath routes.
2015-06-08 02:24:08 +02:00
Ondrej Zajicek 78a2cc289f KRT: Fixes some minor bugs in kernel protocol 2015-06-08 02:24:08 +02:00
Pavel Tvrdík ae80a2de95 unsigned [int] -> uint 2015-06-08 02:24:08 +02:00
Ondrej Zajicek 9fdf9d29b6 KRT: Add support for plenty of kernel route metrics
Linux kernel route metrics (RTA_METRICS netlink route attribute) are
represented and accessible as new route attributes:

krt_mtu, krt_window, krt_rtt, krt_rttvar, krt_sstresh, krt_cwnd, krt_advmss,
krt_reordering, krt_hoplimit, krt_initcwnd, krt_rto_min, krt_initrwnd,
krt_quickack, krt_lock_mtu, krt_lock_window, krt_lock_rtt, krt_lock_rttvar,
krt_lock_sstresh, krt_lock_cwnd, krt_lock_advmss, krt_lock_reordering,
krt_lock_hoplimit, krt_lock_rto_min, krt_feature_ecn, krt_feature_allfrag
2015-05-12 16:42:22 +02:00
Ondrej Zajicek 7069fc9e72 KRT: Fixes route reload
Did not really worked
2015-04-25 21:41:43 +02:00
Ondrej Zajicek c5ff44a703 KRT: Fixes learning of preferred kernel routes.
When a new route was imported from kernel and chosen as preferred, then
the old best route was propagated as a withdraw to the kernel protocol.
Under some circumstances such withdraw propagated to the BSD kernel could
remove the new alien route and thus reverting the import.
2015-04-25 20:43:43 +02:00
Ondrej Zajicek b867a87c2f Fixes port range socket option 2015-04-19 00:31:59 +02:00
Ondrej Zajicek 9aed29e605 BGP: Enhanced route refresh (RFC 7313) support
Also hook feed_done is renamed to feed_end.
2015-03-29 18:29:49 +02:00
Ondrej Zajicek af454f9b7c Fixes bug in debug dumps
Using 'dump sockets' in IPv6 mode caused crash due to mismatched format string.

Thanks to Pavel Tvrdik for noticing it.
2015-03-02 09:42:44 +01:00
Ondrej Zajicek 8bcb5fb1e8 Implement latency tracking, internal event log and watchdog 2015-03-02 09:41:14 +01:00
Ondrej Zajicek 9c89560e6c Use IP_PORTRANGE_HIGH for BFD where available 2015-02-22 20:14:14 +01:00
Ondrej Zajicek 2bbc308321 Store protocol config size inside protocol structure
Make proto_config_new() use this info instead of supplied size.

Thanks to Alexander V. Chernikov for the patch.
2015-02-21 21:08:23 +01:00
Pavel Tvrdik e598853e68 Add const to a param msg at functions log_msg, log_rl, die, bug and debug 2015-02-21 19:32:57 +01:00
Pavel Tvrdik 4a591d4b94 Replacing GNU old-style field designator extension 2015-02-21 19:31:36 +01:00
Ondrej Zajicek 6f8bbaa10b Fininshing integrated OSPF. 2014-11-03 10:42:55 +01:00
Ondrej Zajicek 88a183c6c9 Integrated IP functions. 2014-10-24 11:11:43 +02:00
Ondrej Zajicek 1123e70740 Implements token bucket filter for rate limiting. 2014-10-02 12:52:50 +02:00
Ondrej Zajicek 252c7e4d0b Refresh kernel protocol when interface disappears.
When an interface goes down, (Linux) kernel removes routes pointing to
that ifacem but does not send withdraws for them. We rescan the
kernel table to ensure synchronization.

Thanks to Alexander Demenshin for the bugreport.
2014-10-02 12:52:50 +02:00
Ondrej Zajicek 0479b44373 Fixes some warnings. 2014-10-02 12:52:50 +02:00
Ondrej Zajicek 8945f73d94 Ensures that msg_controllen includes last padding.
Although RFC 3542 allows both cases, Theo de Raadt thinks
he knows better, and msg_controllen without last padding
fails on OpenBSD.

Thanks to Job Snijders for the bugreport.
2014-06-26 13:30:27 +02:00
Ondrej Zajicek 9eceab33f9 String constants could be used for string option values.
Thanks to Frederik Kriewitz for the patch.
2014-05-29 23:05:03 +02:00
Ondrej Zajicek 05476c4d04 IPv4/IPv6 integrated socket code. 2014-05-18 11:42:26 +02:00
Ondrej Zajicek 0c791f873a BGP graceful restart support.
Also significant core protocol state changes needed for that,
global graceful restart recovery state and kernel proto support
for recovery.
2014-03-20 14:07:12 +01:00
Ondrej Zajicek 4e398e34bf Workaround thread-unsafeness of cli_echo(). 2014-02-07 13:09:55 +01:00
Ondrej Zajicek 48e5f32db6 Many changes in I/O and OSPF sockets and packet handling.
I/O:
 - BSD: specify src addr on IP sockets by IP_HDRINCL
 - BSD: specify src addr on UDP sockets by IP_SENDSRCADDR
 - Linux: specify src addr on IP/UDP sockets by IP_PKTINFO
 - IPv6: specify src addr on IP/UDP sockets by IPV6_PKTINFO
 - Alternative SKF_BIND flag for binding to IP address
 - Allows IP/UDP sockets without tx_hook, on these
   sockets a packet is discarded when TX queue is full
 - Use consistently SOL_ for socket layer values.

OSPF:
 - Packet src addr is always explicitly set
 - Support for secondary addresses in BSD
 - Dynamic RX/TX buffers
 - Fixes some minor buffer overruns
 - Interface option 'tx length'
 - Names for vlink pseudoifaces (vlinkX)
 - Vlinks use separate socket for TX
 - Vlinks do not use fixed associated iface
 - Fixes TTL for direct unicast packets
 - Fixes DONTROUTE for OSPF sockets
 - Use ifa->ifname instead of ifa->iface->name
2014-02-06 17:46:01 +01:00
Ondrej Zajicek 283c7dfada Merge branch 'master' into add-path 2013-11-25 18:42:47 +01:00
Ondrej Zajicek 90eb5e7a8b Use ISO 8601 timeformats by default. 2013-11-25 13:44:07 +01:00
Ondrej Zajicek e237b28a4d Changes primary addr selection on BSD to respect SIOCGIFADDR ioctl() result.
Thanks to Alexander V. Chernikov for the original patch.
2013-11-25 01:21:39 +01:00