summaryrefslogtreecommitdiffstats
path: root/bfdd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: Drop `break` after using frr_help_exit() in switch/caseDonatas Abraitis2021-08-251-1/+0
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* *: Do not check for XMALLOC/XCALLOC against NULLsDonatas Abraitis2021-06-291-2/+0
| | | | | | | We don't check this pattern anywhere in the code basically, so let's unify the code. Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* Merge pull request #8758 from idryzhov/bfd-fixesRafael Zalamena2021-06-075-33/+57
|\ | | | | BFD fixes
| * bfdd: forbid setting interface for multihop sessionsIgor Ryzhov2021-06-013-31/+55
| | | | | | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| * bfdd: don't store interface pointer for multihop sessionsIgor Ryzhov2021-06-011-1/+1
| | | | | | | | | | | | It breaks "neighbor A.B.C.D update-source" config in BGP. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| * lib: fix bfd multihopIgor Ryzhov2021-06-011-1/+1
| | | | | | | | | | | | | | Never send an interface name/index for multihop sessions. It breaks "neighbor A.B.C.D update-source" config in BGP. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | bfdd: fix bfd key structureIgor Ryzhov2021-06-021-3/+14
|/ | | | | | | | | | | | | There's a padding byte between "mhop" and "peer" fields in this structure. This structure is sometimes passed by value to functions and used in assignments. The standard doesn't guarantee that the padding bytes are copied on assignments. As this structure is used as a hash key, having this padding byte with unspecified value can lead to unwanted behavior. Fix the possible issue by making the "mhop" field to be 2 bytes. Also make the struct packed as a precaution for future changes. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* lib: adapt to version 2 of libyangChristian Hopps2021-05-131-4/+4
| | | | | | | | | Compile with v2.0.0 tag of `libyang2` branch of: https://github.com/CESNET/libyang staticd init load time of 10k routes now 6s vs ly1 time of 150s Signed-off-by: Christian Hopps <chopps@labn.net>
* Merge pull request #8100 from qlyoung/remove-sample-conf-filesDavid Lamparter2021-04-132-6/+0
|\
| * *: remove *.conf.sample filesQuentin Young2021-04-092-6/+0
| | | | | | | | | | | | | | | | | | | | Most of these are many, many years out of date. All of them vary randomly in quality. They show up by default in packages where they aren't really useful now that we use integrated config. Remove them. The useful ones have been moved to the docs. Signed-off-by: Quentin Young <qlyoung@nvidia.com>
* | bfdd: fix nb cli show with defaultsIgor Ryzhov2021-04-121-63/+21
|/ | | | | | | | | The idea of the "with-defaults" flag is to show the default values for parameters that were not configured by the user. But bfdd incorrectly shows the default values for all parameters, including the user-configured ones. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: fix profiles autocompletionIgor Ryzhov2021-04-011-1/+1
| | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bbfd: clear nb config entries when removing bfd nodeIgor Ryzhov2021-04-011-1/+15
| | | | | | | | When bfd node is removed, we must clear all NB entries set by its children - sessions and profiles. Let's store some fake data as an entry for the bfd node to be able to unset it later. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: remove profiles when removing bfd nodeIgor Ryzhov2021-04-013-0/+10
| | | | | | Fixes #8379. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #8121 from opensourcerouting/macro-cleanupDonatas Abraitis2021-03-225-13/+15
|\ | | | | *: require ISO C11 + semicolons after file-scope macros
| * *: require semicolon after FRR_DAEMON_INFO & co.David Lamparter2021-03-171-1/+2
| | | | | | | | | | | | ... again ... Signed-off-by: David Lamparter <equinox@diac24.net>
| * *: require semicolon after DEFINE_MTYPE & coDavid Lamparter2021-03-175-12/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Back when I put this together in 2015, ISO C11 was still reasonably new and we couldn't require it just yet. Without ISO C11, there is no "good" way (only bad hacks) to require a semicolon after a macro that ends with a function definition. And if you added one anyway, you'd get "spurious semicolon" warnings on some compilers... With C11, `_Static_assert()` at the end of a macro will make it so that the semicolon is properly required, consumed, and not warned about. Consistently requiring semicolons after "file-level" macros matches Linux kernel coding style and helps some editors against mis-syntax'ing these macros. Signed-off-by: David Lamparter <equinox@diac24.net>
* | Merge pull request #8225 from idryzhov/bfd-echo-modeRafael Zalamena2021-03-172-1/+7
|\ \ | | | | | | bfdd: fix echo receive timer and disable echo mode
| * | bfdd: warn users about echo-mode restrictionsIgor Ryzhov2021-03-161-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Echo-mode implementation is currently broken. Instead of sending packets to it's own address, bfdd is sending echo packets to the peer's address. It may seem to work when testing between two FRR instances, because FRR loops back such packets, but no other implementation is supposed to do that. Let's warn users that the current implementation works only between two FRR instances. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| * | bfdd: fix starting echo receive timerIgor Ryzhov2021-03-161-1/+3
| |/ | | | | | | | | | | | | | | Currently this timer is only started when we receive the first echo packet. If we never receive the packet, the timer is never started and the user falsely assumes that echo function is working. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* / bfdd: separate echo rx/tx timersIgor Ryzhov2021-03-1612-50/+290
|/ | | | | | | | | | Currently there is a single interval for both RX and TX echo functions. This commit introduces separate RX and TX timers for echo packets. The main advantage is to be able to set the receive interval to zero when we don't want to receive echo packets from the remote system. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: make sessions administratively up by defaultIgor Ryzhov2021-03-144-7/+4
| | | | | | | | | | | | | | | | Current behavior is inconsistent. When the session is created by another daemon, it is up by default. When we later configure peer in bfdd, the session is still up, but the NB layer thinks that it is down. More than that, even when the session is created in bfdd using peer command, it is created in DOWN state, not ADM_DOWN. And it actually starts sending and receiving packets. The sessions is marked with SHUTDOWN flag only when we try to reconfigure some parameter. This behavior is also very unexpected. Fixes #7780. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: fix detect timeoutIgor Ryzhov2021-03-091-3/+3
| | | | | | | | | | | | RFC 5880 Section 6.8.4: In Asynchronous mode, the Detection Time calculated in the local system is equal to the value of Detect Mult received from the remote system, multiplied by the agreed transmit interval of the remote system (the greater of bfd.RequiredMinRxInterval and the last received Desired Min TX Interval). Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: fix echo configuration in profileIgor Ryzhov2021-03-041-2/+8
| | | | | | | | | | | | | | It's not currently possible to configure echo mode in profile node: ``` (config)# bfd (config-bfd)# profile test (config-bfd-profile)# echo-mode % Echo mode is only available for single hop sessions. (config-bfd-profile)# echo-interval 20 % Echo mode is only available for single hop sessions. ``` Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: forbid creation of the same peer with and without interface nameIgor Ryzhov2021-03-031-0/+52
| | | | | | | | | | | | | | | | | | | | | | | | Currently it is possible to configure the same peer with and without interface name: ``` bfd peer 1.1.1.1 ! peer 1.1.1.1 interface enp0s3 ! ``` There are multiple problems with that: 1. Both nodes actually control the same BFD session. So the config is either duplicated or, even worse, different - and there is no way to say which one actually works. 2. When the user deletes both nodes, the session is not actually freed, because its refcount is always greater than 1. Such configuration must be forbidden. User should either have single node with wildcard name or multiple nodes with actual names. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: actually return validation error instead of loggingIgor Ryzhov2021-03-031-20/+17
| | | | | | | | | | | | | | | | | | | | | Before: ``` (config-bfd)# peer fe80::a00:27ff:fea2:5803 multihop local-address fe80::a00:27ff:fea2:5802 % Configuration failed. Error type: validation ``` After: ``` (config-bfd)# peer fe80::a00:27ff:fea2:5803 multihop local-address fe80::a00:27ff:fea2:5802 % Configuration failed. Error type: validation Error description: When using link-local you must specify an interface ``` Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: require local-address when using multihopIgor Ryzhov2021-03-031-2/+6
| | | | | | | | | If local-address is not supplied, then an incorrect xpath is generated which is not expected by NB CLI. Fixes #7465. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* *: fix format string SNAFUsDavid Lamparter2021-02-161-2/+2
| | | | Signed-off-by: David Lamparter <equinox@diac24.net>
* Merge pull request #8006 from idryzhov/fix-bfd-lookupPhilippe Guibert2021-02-121-115/+45
|\ | | | | bfdd: fix session lookup
| * bfdd: fix session lookupIgor Ryzhov2021-02-031-115/+45
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BFD key has optional fields "local" and "ifname" which can be empty when the BFD session is created. In this case, the hash key will be calculated with these fields filled with zeroes. Later, when we're looking for the BFD session using the key with fields "local" and "ifname" populated with actual values, the hash key will be different. To work around this issue, we're doing multiple hash lookups, first with full key, then with fields "local" and "ifname" filled with zeroes. But there may be another case when the initial key has the actual values for "local" and "ifname", but the key we're using for lookup has empty values. This case is covered for IPv4 by using additional hash walk with bfd_key_lookup_ignore_partial_walker function but is not covered for IPv6. Instead of introducing more hacks and workarounds, the following solution is proposed: - the hash key is always calculated in bfd_key_hash_do using only required fields - the hash data is compared in bfd_key_hash_cmp, taking into account the fact that fields "local" and "ifname" may be empty Using this solution, it's enough to make only one hash lookup. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | bfdd: Prevent use after free ( again )Donald Sharp2021-02-071-1/+3
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Valgrind is still reporting: 466020-==466020== by 0x11B9F4: main (bfdd.c:403) 466020-==466020== Address 0x5a7d544 is 84 bytes inside a block of size 272 free'd 466020:==466020== at 0x48399AB: free (vg_replace_malloc.c:538) 466020-==466020== by 0x490A947: qfree (memory.c:140) 466020-==466020== by 0x48F2AE8: if_delete (if.c:322) 466020-==466020== by 0x48F250D: if_destroy_via_zapi (if.c:195) 466020-==466020== by 0x497071E: zclient_interface_delete (zclient.c:2040) 466020-==466020== by 0x49745F6: zclient_read (zclient.c:3687) 466020-==466020== by 0x4955AEC: thread_call (thread.c:1684) 466020-==466020== by 0x48FF64E: frr_run (libfrr.c:1126) 466020-==466020== by 0x11B9F4: main (bfdd.c:403) 466020-==466020== Block was alloc'd at 466020:==466020== at 0x483AB65: calloc (vg_replace_malloc.c:760) 466020-==466020== by 0x490A805: qcalloc (memory.c:115) 466020-==466020== by 0x48F23D6: if_new (if.c:160) 466020-==466020== by 0x48F257F: if_create_name (if.c:214) 466020-==466020== by 0x48F3493: if_get_by_name (if.c:558) 466020-==466020== by 0x49705F2: zclient_interface_add (zclient.c:1989) 466020-==466020== by 0x49745E0: zclient_read (zclient.c:3684) 466020-==466020== by 0x4955AEC: thread_call (thread.c:1684) 466020-==466020== by 0x48FF64E: frr_run (libfrr.c:1126) 466020-==466020== by 0x11B9F4: main (bfdd.c:403) Apparently the bs->ifp pointer is being set even in cases when the bs->key.ifname is not being set. So go through and just match the interface pointer and cut-to-the-chase. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bfdd: Prevent storage of ifp pointer that has been deletedDonald Sharp2021-01-301-1/+3
| | | | | | | | On shutdown, interfaces are deleted but if the bfd session is down we retain the interface pointer. Remove the retained pointer. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bfdd: Prevent unininited data transmittalDonald Sharp2021-01-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | Valgrind reports: 2052866-==2052866== 2052866-==2052866== Syscall param sendmsg(msg.msg_name) points to uninitialised byte(s) 2052866:==2052866== at 0x49C8E13: sendmsg (sendmsg.c:28) 2052866-==2052866== by 0x11DC08: bp_udp_send (bfd_packet.c:823) 2052866-==2052866== by 0x11DD76: ptm_bfd_echo_snd (bfd_packet.c:179) 2052866-==2052866== by 0x114C2D: ptm_bfd_echo_xmt_TO (bfd.c:469) 2052866-==2052866== by 0x114C2D: ptm_bfd_echo_start (bfd.c:498) 2052866-==2052866== by 0x114C2D: bs_echo_timer_handler (bfd.c:1199) 2052866-==2052866== by 0x11E478: bfd_recv_cb (bfd_packet.c:702) 2052866-==2052866== by 0x4904846: thread_call (thread.c:1681) 2052866-==2052866== by 0x48CB4DF: frr_run (libfrr.c:1126) 2052866-==2052866== by 0x113044: main (bfdd.c:403) 2052866-==2052866== Address 0x1ffefff3e8 is on thread 1's stack In ptm_bfd_echo_snd, for the v4 case we were memsetting the v6 memory then setting the v4 memory. Just fix it. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bfdd: Remove #if 0Donald Sharp2021-01-281-4/+0
| | | | | | We do have a bunch of old code that is never used. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* bfdd: improve some debug messages related to zebra notificationsPhilippe Guibert2021-01-092-7/+10
| | | | | | | | | when receiving interface and address notifications, one may be puzzled by the information since for example, the presence of an interface is not enough to use it in a bfd session, simply because the interface is in the wrong vrf. add VRF information on those traces. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bfdd: update vrf of received packetPhilippe Guibert2021-01-091-0/+10
| | | | | | | | | | on vrf-lite environment, all incoming bfd packets are received by the same socket on the default namespace. the vrfid is not relevant and needs to be updated based on the incoming interface where traffic has been received. If the traffic is received from an interface belonging to a separate vrf, update the vrfid value accordingly. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bfdd: enable bfd session if vrf interface availablePhilippe Guibert2021-01-092-6/+20
| | | | | | | | | | | | | | | The vrf interface notification and interface notifications are separated on zapi interface between the system (zebra daemon) and other daemons (bfd for instance). In the case of bfd, the initial code was waiting for vrf notification to create the socket. Actually, in vrf-lite world, we need to wait the vrf interface to be present, in order to create the socket and bind to the vrf interface (this is the usual way to work with vrf-lite). On bfd, the changes consist in delaying the socket creation first, then when interface is created, check the interface name presence instead of checking the interface configuration. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bfdd: socket should be bound to vrf interface by defaultPhilippe Guibert2021-01-091-4/+6
| | | | | | | | | When running in vrf-lite mode, the socket used in a vrf environment should be bound to an interface belonging to the vrf. If no one is selected, then the vrf interface itself should be bound to that socket, so that outgoing packets are being applied routing rules for that vrf. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
* bfd: fix session lookupIgor Ryzhov2020-12-041-1/+1
| | | | | | local-address is optional for both IPv4 and IPv6. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* Merge pull request #6950 from opensourcerouting/bfd-distributed-v3Donald Sharp2020-12-038-26/+1924
|\ | | | | bfdd: distributed BFD
| * bfdd: move interface/vrf reset codeRafael Zalamena2020-11-242-3/+2
| | | | | | | | | | | | | | Don't reset interface/vrf pointer everytime a session is disabled instead only do it when it was explicitly removed. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: support connecting to BFD data planeRafael Zalamena2020-11-243-15/+229
| | | | | | | | | | | | | | Add option to connect to a data plane server instead of receiving connections. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: distributed BFD show commandsRafael Zalamena2020-11-243-0/+151
| | | | | | | | | | | | | | Show BFD sessions updated counters by asking the data plane for this information and show data plane statistics. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: integrate distributed BFDRafael Zalamena2020-11-243-5/+209
| | | | | | | | | | | | | | | | | | | | | | | | Add hooks in the correct places so the BFD daemon uses the data plane instead of the software packet sending implementation to monitor the session. This code also adds some handlers to support fallback to FRR BFD session handling, however since this complicates the code it won't work at the moment (the BFD sockets are disabled by default when using data plane). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: disable sockets when using distributed BFDRafael Zalamena2020-11-241-16/+25
| | | | | | | | | | | | | | | | | | | | The current distributed BFD implementantion doesn't support falling back to software implementation in FRR, so to keep the code simple lets give the data plane full control of the BFD packet handling (helps running a software data plane for testing too otherwise it would fail with 'address in use' error). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: distributed BFD debugging knobRafael Zalamena2020-11-241-0/+21
| | | | | | | | | | | | Add a knob to show/hide the distributed BFD (data plane) debug messages. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: import distributed BFD implementationRafael Zalamena2020-11-244-2/+921
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Distributed BFD is a term used for BFD implementations that do not run on the routing engine, instead it is run on a data plane (software or hardware based). The current code implements the basic communication between FRR BFD daemon with an external BFD data plane and defines the protocol format in the file `bfddp_packet.h`. To enable/use data plane you need to start BFD daemon with the command line `--dplaneaddr <type>:<address>`, then a socket will be opened to listen for incoming data plane connections. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd: import data plane protocol headerRafael Zalamena2020-11-241-0/+381
| | | | | | | | | | | | | | | | The BFD data plane header has definitions for the data plane communication protocol that will be used to implement the distributed BFD feature. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* | bfdd: session specific command type checksRafael Zalamena2020-12-011-0/+20
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replace the unclear error message: ``` % Failed to edit configuration. YANG error(s): Schema node not found. YANG path: /frr-bfdd:bfdd/bfd/sessions/single-hop[dest-addr='192.168.253.6'][interface=''][vrf='default']/minimum-ttl ``` With: ``` frr(config-bfd-peer)# minimum-ttl 250 % Minimum TTL is only available for multi hop sessions. ! or frr(config-bfd-peer)# echo % Echo mode is only available for single hop sessions. frr(config-bfd-peer)# echo-interval 300 % Echo mode is only available for single hop sessions. ``` Reported-by: Trae Santiago Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* bfdd: fix multiple links same addressRafael Zalamena2020-11-181-2/+5
| | | | | | | | Allows users with multiple links using same IPv6 address (same VRF) to work. Reported-by: Matti Suuronen Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>