summaryrefslogtreecommitdiff
path: root/bfdd/bfd_packet.c
AgeCommit message (Collapse)Author
2020-04-09bfdd: remove BFD_*_FLAG macrosRafael Zalamena
Lets use what FRR provide us instead of implementing a new macros. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-03-30bfdd: fix -Wundef warningRuben Kerkhof
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-01-21bfdd: fix format stringsDavid Lamparter
... now that we get warnings about them ... Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-19Merge pull request #5274 from opensourcerouting/bfdd-vrf-socketRuss White
bfdd: VRF security improvement
2019-11-14bfdd: remove unused initialization sa warningMark Stapp
There's a variable initialization that's triggering an SA warning - don't do that. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-11-04bfdd: bind VRF sockets to devicesRafael Zalamena
Always bind the created sockets to their respective VRF devices. With this it should be possible to run BFD on VRFs without needing to weaken the security setting `net.ipv4.udp_l3mdev_accept=1`. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-10-25bfdd: VRF and CoverityDonald Sharp
Fixup a couple of Coverity issues surrounding pointers Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-03*: frr_elevate_privs -> frr_with_privsDavid Lamparter
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-06lib,bgpd,babeld,ripngd,nhrpd,bfdd: clean up SA warningsMark Stapp
Clean up several SA warnings. Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-05-14bfdd, lib, bgpd: add bfd cbit usagePhilippe Guibert
bfd cbit is a value carried out in bfd messages, that permit to keep or not, the independence between control plane and dataplane. In other words, while most of the cases plan to flush entries, when bfd goes down, there are some cases where that bfd event should be ignored. this is the case with non stop forwarding mechanisms where entries may be kept. this is the case for BGP, when graceful restart capability is used. If BFD event down happens, and bgp is in graceful restart mode, it is wished to ignore the BFD event while waiting for the remote router to restart. The changes take into account the following: - add a config flag across zebra layer so that daemon can set or not the cbit capability. - ability for daemons to read the remote bfd capability associated to a bfd notification. - in bfdd, according to the value, the cbit value is set - in bfdd, the received value is retrived and stored in the bfd session context. - by default, the local cbit announced to remote is set to 1 while preservation of the local path is not set. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07bfd: add bfdd_privs to the bglobal structurePhilippe Guibert
this structure contains the bfdd_privs structure in charge of the privilege settings. The initialisation has moved a bit, in order that the preinit settings are done. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07bfdd: socket handling per vrf contextPhilippe Guibert
sockets are created foreach network namespace context enabled. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07bfdd: use vrf api for creation socket with binding with vrf litePhilippe Guibert
in the case vrf-lite is used, it is possible to call SO_BINDTODVICE, by using vrf_socket() call. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07bfdd: socket creation in a vrf can be donePhilippe Guibert
vrf_socket() call is performed instead of socket() call. Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-03-19bfdd: fix echo loopback functionRafael Zalamena
Add the address family to the sockaddr structure otherwise `sendmsg` will fail with `EAFNOSUPPORT`. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-11bfdd: change session lookup data structureRafael Zalamena
Use simplier data structure key to avoid having to do complex and error-prone key building (e.g. avoid expecting caller to know IPv6 scope id, interface index, vrf index etc...). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-25*: use proper bool initializers & fix comparisonsQuentin Young
- bools should be initialized with true/false - bools do not need to be compared Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-14bfdd: fix CI warningsRafael Zalamena
Fix a few checkpatch warnings and a clang analyzer warning of uninitialized variable. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: fix discriminator mismatch log messageRafael Zalamena
The discriminator is an unsigned 32bit variable. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: apply new timers on on-going connectionsRafael Zalamena
Apply new timers when only one side is negotiating new settings: when sending the final bit we must apply the remote settings, otherwise we'll keep the previous transmission rate. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: implement session interface observerRafael Zalamena
Allow `bfdd` to configure inexisting interfaces / VRF and only activate them once the interface/VRF start existing. This implementation doesn't handle dynamic VRFs yet. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: refactor session lookupRafael Zalamena
Use internal data to lookup sessions. This approach has two main advantages: * it uses less memory because it doesn't use strings for interface / vrf, it uses OS indexes instead; * prepares code to support VRF; Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: simplify timer data structureRafael Zalamena
Remove some legacy left overs of the old timer data structure bits and use a simpler version: We always keep the current configuration in the timer structure, but also keep the running timers (before poll transition) in `cur_timers`. With this we can remove `new_timers` and avoid timer copy configuration copy on final handler (this also simplifies peer show command). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: fix bug on poll sequenceRafael Zalamena
Poll and Final bits can't be set at the same time in a packet. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: refactor timer handlingRafael Zalamena
Move timer calculation code outside of the packet handling function and explain how timers are calculated. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14bfdd: refactor state change handlerRafael Zalamena
Expand state change handling into smaller functions with more explanatory commentaries. This also handles some corner cases that were not being handled. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-01-10bfdd: use zebra to learn about network interfacesRafael Zalamena
Don't use system calls to search for and get interface information, instead use the FRR provided API to learn and cache it. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-11-30bfdd: fix multihop on FreeBSDRafael Zalamena
Some systems have a extra `struct sockaddr*` field (`_len`) which must be filled in order for the peer lookup to work. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-10-01bfdd: disable echo on neighbor requestRafael Zalamena
Don't send echo packets when the neighbor configures echo-interval of 0 (e.g. disabled). Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-08bfdd: fix garbage "port" stringDavid Lamparter
bfd_recv_ipv4() is getting an uninitialized buffer passed in as port, and then checks it without clearing it first. Thus we can end up leaving garbage data in it. Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-05bfdd: fix crash when receiving invalid echo packetRafael Zalamena
The log function would improperly format a string using an integer causing a crash. This situation was found when switching echo mode with a active connection. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-05bfdd: use THREAD_OFF() instead of thread_cancel()Rafael Zalamena
Use a standardized function to cancel threads instead of hand rolling our own. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-03bfdd: use UDP sockets instead of rawRafael Zalamena
Avoid all complexities of handling ethernet/IP/UDP headers and just use UDP sockets: let the OS kernel handle this task. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-03bfdd: enumerate all diagnositic codesRafael Zalamena
Enumerate all codes, update the string representation and fix the misdiagnosed echo failure. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-03bfdd: make bfd_recv_* more genericRafael Zalamena
We'll reuse these functions later to receive echo packets, so we need to despecialize them first. Another improvement here is that we are going to remove the global buffer variable and opt to use the stack. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-03bfdd: remove VxLAN codeRafael Zalamena
Remove all VxLAN code. There are probably better ways to write VxLAN support without having to use raw sockets and depend on extra user configuration input. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-03bfdd: remove global variables and improve logsRafael Zalamena
Remove some more global variables and make the log messages look like the rest of the code. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-16bfdd: fix coverity scan issues (1472630, 1472623)Rafael Zalamena
Always initialize/santize string before calling the `read` function. It ensures that the debug function will always pick up the right thing. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-14bfdd: fix alpine buildRafael Zalamena
Move `recvmsg` parameter option initialization to function, initialize the parameter struct with zeroes and access field by name. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08bfdd: fix IPv6 peers using link-local addressRafael Zalamena
When using link-local address we must specify the scope-id for the address in order to bind to the interface. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08bfdd: improve logging messagesRafael Zalamena
Show a little more details, remove some duplicated calls and remove the macro compatibility with old debugging functions. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08bfdd: clean up header inclusionRafael Zalamena
Most of the headers we need are included by zebra.h, so lets simplify this. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08bfdd: imported new daemon source codeRafael Zalamena
Import source code from external `bfdd` daemon ported from Cumulus PTM. Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>