summaryrefslogtreecommitdiffstats
path: root/bfdd (follow)
Commit message (Collapse)AuthorAgeFilesLines
* *: 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>
* Merge pull request #7476 from opensourcerouting/bfd-fixesRuss White2020-11-171-51/+73
|\ | | | | bfdd,lib: integration fixes
| * bfdd: missing BFD integration debug valueRafael Zalamena2020-11-081-3/+9
| | | | | | | | | | | | Show the TTL value sent by the routing protocol. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
| * bfdd,lib: simplify integration protocolRafael Zalamena2020-11-081-48/+64
| | | | | | | | | | | | | | | | | | Let the integration protocol always send the full configuration instead of saving a few bytes. It will also allow protocols to specify source address for IPv4 single hop connections and interface for multi hop configuration. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* | bfdd: On interface address delete we are leaking memoryDonald Sharp2020-11-151-1/+4
|/ | | | | | | The interface address delete callback from zebra was not deleting the ifc that was created as per normal work methodologies Signed-off-by: Donald Sharp <sharpd@nvidia.com>
* Merge pull request #7473 from eololab/fix-crash-bfdd-show-counters-jsonDonald Sharp2020-11-071-1/+1
|\ | | | | bfdd: fix crash on show bfd peers counters json
| * bfdd: fix crash on show bfd peers counters jsonEmanuele Bovisio2020-11-061-1/+1
| | | | | | | | | | | | wrong pointer passed to bfd_id_iterate function Signed-off-by: Emanuele Bovisio <emanuele.bovisio@eolo.it>
* | bfdd: fix possible null dereferenceIgor Ryzhov2020-11-051-2/+2
|/ | | | | | bs->ifp may be null, so we should check it before dereferencing. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* * : update signature of thread_cancel apiMark Stapp2020-10-231-17/+4
| | | | | | | | Change thread_cancel to take a ** to an event, NULL-check before dereferencing, and NULL the caller's pointer. Update many callers to use the new signature. Signed-off-by: Mark Stapp <mjs@voltanet.io>
* :* Convert prefix2str to %pFXDonatas Abraitis2020-10-221-3/+2
| | | | Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
* vtysh: dynamically generate the list of daemons for commandsIgor Ryzhov2020-10-021-0/+1
| | | | | | | Some daemons were actually missing from the static definitions: nhrpd, babeld, eigrpd and bfdd. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: Make new multihop peer if local-address is uniqueTashana Mehta-Wilson2020-09-291-12/+13
| | | | | | | | | | | | | Previously if there were two multihop peers created that had the same peer address but different local addresses then the second peer to be created would be merged with the first one and niether would be able to be deleted. This was due to an issue in the function bfd_key_lookup(). When the second peer was created its key would be sent into the lookup function and would reach the last section, even though it shouldn't have. A check has been placed around the section so that it will not be entered if a peer is multihop. Signed-off-by: Tashana Mehta-Wilson <tashana.mehta-wilson@alliedtelesis.co.nz>
* Merge pull request #7063 from idryzhov/yang-leafrefRenato Westphal2020-09-264-19/+13
|\ | | | | yang: use leafref instead of string
| * bfdd: use * as a placeholder for an empty interface name in northboundIgor Ryzhov2020-09-243-5/+8
| | | | | | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| * bfdd: interface and vrf are mandatory leafsIgor Ryzhov2020-09-241-14/+3
| | | | | | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
| * bfdd: add missing includesIgor Ryzhov2020-09-221-0/+2
| | | | | | | | Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* | *: move all userdata when changing node xpathIgor Ryzhov2020-09-241-0/+6
|/ | | | | | The same thing was done for interfaces in commit f7c20aa1f. Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: fix parameter lengthIgor Ryzhov2020-08-241-2/+2
| | | | | | There is no space reserved for "[source-addr='']". Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
* bfdd: Allow it to work when V6 is completely turned offDonald Sharp2020-08-142-12/+36
| | | | | | | Experimental patch to allow us to discuss if we should allow bfdd to work when v6 is turned off in the kernel. Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
* bfdd: implement minimum TTLRafael Zalamena2020-08-1210-6/+200
| | | | | | | | Initial BFD protocol implementation had a hard coded value of maximum 5 hops, now we have a configurable hop amount with a safe default of 1 hop. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* bfdd: simplify and remove duplicated codeRafael Zalamena2020-08-113-55/+37
| | | | | | Move the session configuration application logic to a single function. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* bfdd: implement passive modeRafael Zalamena2020-08-118-5/+183
| | | | | | | | | | | | | | | | | | The passive mode is briefly described in the RFC 5880 Bidirectional Forwarding Detection (BFD), Section 6.1. Overview: > A system may take either an Active role or a Passive role in session > initialization. A system taking the Active role MUST send BFD > Control packets for a particular session, regardless of whether it > has received any BFD packets for that session. A system taking the > Passive role MUST NOT begin sending BFD packets for a particular > session until it has received a BFD packet for that session, and thus > has learned the remote system's discriminator value. At least one > system MUST take the Active role (possibly both). The role that a > system takes is specific to the application of BFD, and is outside > the scope of this specification. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* *: introduce DEFPY_YANG & friendsRenato Westphal2020-08-031-19/+19
| | | | | | | | | | DEFPY_YANG will allow the CLI to identify which commands are YANG-modeled or not before executing them. This is going to be useful for the upcoming configuration back-off timer work that needs to commit pending configuration changes before executing a command that isn't YANG-modeled. Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
* Merge pull request #6731 from opensourcerouting/style-string-prepDonald Sharp2020-07-165-21/+16
|\ | | | | *: string coding style
| * *: remove PRI[udx](8|16|32)David Lamparter2020-07-143-13/+12
| | | | | | | | | | | | | | | | | | | | | | These are completely pointless and break coccinelle string replacements. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --pri8-16-32 `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
| * *: un-split strings across linesDavid Lamparter2020-07-143-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove mid-string line breaks, cf. workflow doc: .. [#tool_style_conflicts] For example, lines over 80 characters are allowed for text strings to make it possible to search the code for them: please see `Linux kernel style (breaking long lines and strings) <https://www.kernel.org/doc/html/v4.10/process/coding-style.html#breaking-long-lines-and-strings>`_ and `Issue #1794 <https://github.com/FRRouting/frr/issues/1794>`_. Scripted commit, idempotent to running: ``` python3 tools/stringmangle.py --unwrap `git ls-files | egrep '\.[ch]$'` ``` Signed-off-by: David Lamparter <equinox@diac24.net>
* | bfdd: update detect multiplier on profile changeRafael Zalamena2020-07-131-0/+1
|/ | | | | | Add missing profile update hook for detection multiplier change. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
* bfdd: Use XFREE, clean up SA warning for bfd profilesMark Stapp2020-07-031-1/+2
| | | | | | | Use XFREE instead of raw free, clean up SA warning in bfd profile delete. Signed-off-by: Mark Stapp <mjs@voltanet.io>