Commit graph

424 commits

Author SHA1 Message Date
David Lamparter 3efd0893d0 *: un-split strings across lines
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>
2020-07-14 10:37:25 +02:00
Rafael Zalamena 2975f578de bfdd: update detect multiplier on profile change
Add missing profile update hook for detection multiplier change.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-07-13 10:12:18 -03:00
Mark Stapp dd8bc21d2f bfdd: Use XFREE, clean up SA warning for bfd profiles
Use XFREE instead of raw free, clean up SA warning in bfd
profile delete.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2020-07-03 11:50:34 -04:00
Donald Sharp 7799deeed6
Merge pull request #6437 from opensourcerouting/bfd-profiles-bgp
bfdd,bgpd: profiles integration support
2020-07-02 12:22:44 -04:00
Russ White cba183561b
Merge pull request #6390 from opensourcerouting/bfd-cp-fix
bfdd: tell peer when our control plane is dead
2020-06-16 07:56:03 -04:00
Rafael Zalamena c2aab69336 *: add filter northbound support
Allow all daemons to work with filter northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-06-05 14:31:26 -03:00
Rafael Zalamena f3e1d2241e bfdd: don't update peers settings on shutdown
During the shutdown phase don't attempt to apply settings to peers
as it is useless and will crash if the peer hash is gone.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-29 17:55:40 -03:00
Rafael Zalamena 18322efd13 bfdd,lib: implement protocol profile selection
Implement the infrastructure for other protocols daemon (e.g. `bgpd`,
`ospfd`, `isisd` etc...) to communicate to BFD daemon which profile
they want to use with their peers.

It was also added the ability for protocols to change profile while
running (no need to remove the registration and then register again).

The protocols message building function was rewritten to support
multiple arguments through `struct bfd_session_arg`, so we can
implement new features without the need of changing function
prototypes. The old function was also rewritten to keep
compatibility.

The profile message part is only available for BFD daemon at the
moment.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-29 17:48:14 -03:00
Rafael Zalamena f6dfa24739 bfdd: remove profile pointers on removal
Remove all profile references on removal and free all resources on shutdown.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-20 15:18:06 -03:00
Rafael Zalamena ccc9ada868 bfdd: implement BFD session configuration profiles
Allow user to pre-configure peers with a profile. If a peer is using a
profile any configuration made to the peer will take precedence over
the profile configuration.

In order to track the peer configuration we have now an extra copy of
the peer configuration in `peer_profile` inside `struct bfd_session`.
This information will help the profile functions to detect user
configurations and avoid overriding what the user configured. This is
especially important for peers created via other protocols where the
default `shutdown` state is disabled (peers created manually are
`shutdown` by default).

Profiles can be used before they exist: if no profile exists then it
will use the default configuration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-20 15:18:00 -03:00
Rafael Zalamena d40d6c2274 bfdd,lib,vtysh: new command node for BFD profiles
Add the necessary code to implement the BFD profile command node.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-20 10:39:34 -03:00
Rafael Zalamena 4d12e1f90e bfdd: remove duplicated code
Move echo/shutdown toggle code to a function and remove the duplicated
logic.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-15 11:32:47 -03:00
Rafael Zalamena 29191d3183 bfdd: tell peer when our control plane is dead
Simplify and fix the code that handles session teardown on control
plane shutdown (either failure or graceful).

- Don't move the `NULL` check inside `free` functions that expect
  data: it creates harder to understand flows.
- Add some new debug messages to aid visualizing session deletions.
- Add sanity check error message (if it ever happens).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-05-13 19:41:50 -03:00
Rafael Zalamena c516ebf90f
Merge pull request #6301 from pguibert6WIND/bfd_debug_show
bfdd: display debugging status of bfd
2020-04-27 15:12:07 -03:00
Philippe Guibert 9be4b18a2f bfdd: display debugging status of bfd
display debugging status of bfd.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2020-04-27 17:22:13 +02:00
David Lamparter 189be3996d bfdd: fix frr-format false warning
Dealing with PRIu64 is unfortunately a bit hacky in the frr-format
plugin, as in, it works correctly with snprintfrr, but breaks on plain
snprintf.  There's no good solution unfortunately :/.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02:00
David Lamparter 94cfb0692e build: make clippy Makefile rules nicer
These are easy to get subtly wrong, and doing so can cause
nondeterministic failures when racing in parallel builds.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:52:41 +02:00
David Lamparter 2768748b88 build: use VPATH for vtysh_scan
No need to put $(top_srcdir) everywhere.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-04-27 09:30:01 +02:00
Renato Westphal 60ee8be107 *: change the signature of the northbound callbacks to be more flexible
Having a fixed set of parameters for each northbound callback isn't a
good idea since it makes it difficult to add new parameters whenever
that becomes necessary, as several hundreds or thousands of existing
callbacks need to be updated accordingly.

To remediate this issue, this commit changes the signature of all
northbound callbacks to have a single parameter: a pointer to a
'nb_cb_x_args' structure (where x is different for each type
of callback). These structures encapsulate all real parameters
(both input and output) the callbacks need to have access to. And
adding a new parameter to a given callback is as simple as adding
a new field to the corresponding 'nb_cb_x_args' structure, without
needing to update any instance of that callback in any daemon.

This commit includes a .cocci semantic patch that can be used to
update old code to the new format automatically.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2020-04-23 10:14:32 -03:00
Rafael Zalamena 5920b3eb38 *: replace all random() calls
Replace all `random()` calls with a function called `frr_weak_random()`
and make it clear that it is only supposed to be used for weak random
applications.

Use the annotation described by the Coverity Scan documentation to
ignore `random()` call warnings.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-17 20:57:43 -03:00
Donald Sharp a83014ccd6
Merge pull request #6247 from FRRouting/nb_conversions
Merge nb_converions branch to master
2020-04-16 19:39:14 -04:00
Donald Sharp 2ff99507ad
Merge pull request #6135 from opensourcerouting/cli-node-cleanup
*: clean up the mess that is CLI command nodes
2020-04-16 19:24:56 -04:00
Chirag Shah 6fd8972aef *: include vrf northbound module in init
Signed-off-by: Chirag Shah <chirag@cumulusnetworks.com>
2020-04-16 08:00:15 -07:00
Santosh P K 09133ff4f7
Merge pull request #5451 from opensourcerouting/rcu-log
logging subsystem rewrite
2020-04-16 20:23:44 +05:30
David Lamparter f4b8291fcb *: move CLI node names to cmd_node->name
And again for the name.  Why on earth would we centralize this, just so
people can forget to update it?

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:59 +02:00
David Lamparter 243895805a *: move CLI parent data to cmd_node->parent_node
Same as before, instead of shoving this into a big central list we can
just put the parent node in cmd_node.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter 612c2c15d8 *: remove second parameter on install_node()
There is really no reason to not put this in the cmd_node.

And while we're add it, rename from pointless ".func" to ".config_write".

[v2: fix forgotten ldpd config_write]

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter 249a771b63 *: remove cmd_node->vtysh
The only nodes that have this as 0 don't have a "->func" anyway, so the
entire thing is really just pointless.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
David Lamparter 62b346eefa *: clean up cmd_node initializers
... and use named assignments everywhere (so I can change the struct.)

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-16 12:53:00 +02:00
Rafael Zalamena 24843702a0 bfdd: add more zebra debug messages
Uncomment old debug about relayed messages from zebra.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 09:35:08 -03:00
Rafael Zalamena 6e10bd9772 bfdd: constify satostr
Detect modifications to the `sockaddr_any` struct.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 09:35:08 -03:00
Rafael Zalamena 869dada534 bfdd: remove time calculation debugs
These were disabled by default and not used by a long time.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 09:35:08 -03:00
Rafael Zalamena 08de92aff3 bfdd: simplify code flow
Don't attempt to handle out-of-memory situations: XMALLOC/XCALLOC will
`assert` if there is no memory left.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 09:35:08 -03:00
Rafael Zalamena 48da2c3169 bfdd: add debug fine tuning capabilities
Move most of the log messages to debug guards so they only get activated
if the user configured the proper debug level.

Current debug levels:
- Peer events.
- Zebra events.
- Network layer debugs.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-14 09:35:08 -03:00
Rafael Zalamena 259b64ebb5 bfdd: use standard log macros
Remove old log_* macros and standardize on FRR's logging infrastructure.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-10 11:06:22 -03:00
Rafael Zalamena 4caf638833 bfdd: fix transmission timer calculation
According to the RFC 5880 the transmission time should be mandated by
the slowest system.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-09 17:46:02 -03:00
Rafael Zalamena bfea10110c bfdd: initialize packet data with zeroes
Lets avoid garbage data on packets by zeroing the packet before setting
the fields/flags.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-09 17:44:56 -03:00
Rafael Zalamena b88113ef73 bfdd: remove BFD_*_FLAG macros
Lets use what FRR provide us instead of implementing a new macros.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-04-09 16:54:11 -03:00
David Lamparter 0bdeb5e58d lib: rewrite zlog lock-free & TLS-buffered
This is a full rewrite of the "back end" logging code.  It now uses a
lock-free list to iterate over logging targets, and the targets
themselves are as lock-free as possible.  (syslog() may have a hidden
internal mutex in the C library;  the file/fd targets use a single
write() call which should ensure atomicity kernel-side.)

Note that some functionality is lost in this patch:
- Solaris printstack() backtraces are ditched (unlikely to come back)
- the `log-filter` machinery is gone (re-added in followup commit)
- `terminal monitor` is temporarily stubbed out.  The old code had a
  race condition with VTYs going away.  It'll likely come back rewritten
  and with vtysh support.
- The `zebra_ext_log` hook is gone.  Instead, it's now much easier to
  add a "proper" logging target.

v2: TLS buffer to get some actual performance

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-04-01 06:53:26 +02:00
Ruben Kerkhof 0cd61f8d24 bfdd: fix -Wundef warning
Signed-off-by: Ruben Kerkhof <ruben@rubenkerkhof.com>
2020-03-30 11:22:58 +02:00
David Lamparter 566bdaf68c *: fix format string warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2020-03-29 10:45:46 +02:00
David Lamparter d6951e5ef9 *: remove tabs from log messages
Some logging systems are, er, "allergic" to tabs in log messages.
(RFC5424: "The syslog application SHOULD avoid octet values below 32")

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2020-03-24 18:47:12 +01:00
Donatas Abraitis a8f58eb6a5 *: Use short version of bool expressions
Signed-off-by: Donatas Abraitis <donatas.abraitis@gmail.com>
2020-03-04 15:04:23 +02:00
Donald Sharp 7f5818fbd6 *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-28 13:59:13 -05:00
Jafar Al-Gharaibeh 4d67e75282 Revert "*: change hash_backet to hash_bucket"
This reverts commit 3895c42a2e.

LabN CI update needs to be coordinated before merging this

Signed-off-by: Jafar Al-Gharaibeh <jafar@atcorp.com>
2020-02-27 09:52:02 -06:00
Donald Sharp 3895c42a2e *: change hash_backet to hash_bucket
It's been a year search and destroy.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2020-02-26 20:03:34 -05:00
Quentin Young b3ba5dc7fe *: don't null after XFREE; XFREE does this itself
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2020-02-03 11:22:13 -05:00
Russ White 6fe6a8b544
Merge pull request #5716 from opensourcerouting/bfdd-log
bfdd: remove logging shim & fix warnings
2020-01-28 10:25:56 -05:00
Quentin Young abe5af1774
Merge pull request #5412 from opensourcerouting/bfdd-vrf-fix
bfdd: fix multiple VRF handling
2020-01-22 14:14:21 -05:00
David Lamparter b7b3d466eb bfdd: fix format strings
... now that we get warnings about them ...

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-01-21 16:35:00 +01:00
David Lamparter d85b048d48 bfdd: remove logging shim
This does exactly nothing, other than hiding format warnings...

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-01-21 16:35:00 +01:00
David Lamparter 429576883e doc: rename man pages to frr-*
The vrrpd one conflicts with the standalone vrrpd package; also we're
installing daemons to /usr/lib/frr on some systems so they're not on
PATH.

Signed-off-by: David Lamparter <equinox@diac24.net>
2020-01-15 14:05:11 +01:00
SumitAgarwal123 1d0a11e6cf bfdd: Json fields for multiplier
Adding fields "detect-multiplier" and "remote-detect-multiplier"
for JSON to to reflect changes in "show bfd peers output"

Signed-off-by: Sayed Mohd Saquib sayed.saquib@broadcom.com
2019-12-03 21:20:31 -05:00
SumitAgarwal123 fa6e709f3f bfdd: Adding new CLI, show bfd peers brief
Added new CLI to display all BFD peer in brief format

Signed-off-by: Sayed Mohd Saquib <sayed.saquib@broadcom.com>
2019-12-03 21:20:28 -05:00
SumitAgarwal123 d679003308 bfdd: Adding new cli, clear bfd counters
Adding new CLI clear bfd counters,
This CLI wil only reset Rx/Tx counters,
it will not reset session UP/DOWN and Zebra event count

Signed-off-by: Sayed Mohd Saquib <sayed.saquib@broadcom.com>
2019-12-03 21:14:36 -05:00
SumitAgarwal123 825e3b9457 bfdd: Adding new fields to display show bfd peer
Adding 2 two new fields
1. Peer type, configured/dynamic
2. Detect multiplier

Signed-off-by: Sayed Mohd Saquib <sayed.saquib@broadcom.com>
2019-12-03 21:14:36 -05:00
David Lamparter 2b64873d24 *: generously apply const
const const const your boat, merrily down the stream...

Signed-off-by: David Lamparter <equinox@diac24.net>
2019-12-02 15:01:29 +01:00
David Lamparter 0d8c7a26a1 *: make frr_yang_module_info const
Signed-off-by: David Lamparter <equinox@diac24.net>
2019-11-30 00:38:32 +01:00
Rafael Zalamena d1ca89aead bfdd: fix multiple VRF handling
Use the interface VRF information instead of relying on the VRF specific
socket information.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit c05c48621c)
2019-11-22 08:37:18 -03:00
Russ White 1157238115
Merge pull request #5274 from opensourcerouting/bfdd-vrf-socket
bfdd: VRF security improvement
2019-11-19 11:41:06 -05:00
Mark Stapp f7b3ca193b bfdd: remove unused initialization sa warning
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-14 08:29:09 -05:00
Rafael Zalamena 4a9feb66b9 bfdd: bind VRF sockets to devices
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-11-04 09:50:54 -03:00
Renato Westphal 6c57402944 bfdd: split northbound callbacks into multiple files
Rearrange the bfdd northbound callbacks as following:
* bfd_nb.h: prototypes of all northbound callbacks.
* bfd_nb.c: definition of all northbound callbacks and their
  associated YANG data paths.
* bfd_nb_config.c: implementation of YANG configuration nodes.
* bfd_nb_state.c: implementation of YANG state nodes.

This should help to keep to code more organized and easier to
maintain.

No behavior changes intended.

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2019-10-30 10:32:51 -03:00
Rafael Zalamena 37cdb6e91d
Merge pull request #5197 from SumitAgarwal123/BFD_ADMIN_DOWN
bfdd: Handling local and remote admin-down
2019-10-29 12:12:27 -03:00
SumitAgarwal123 7555dc6116 bfdd: Handling local and remote admin-down
Scenarios where this code change is required:

1. BFD is un-configured from BGP at remote end.

Neighbour BFD sends ADMIN_DOWN state, but BFD on local side will send
DOWN to BGP, resulting in BGP session DOWN.
Removing BFD session administratively shouldn't bring DOWN BGP session
at local or remote.

2. BFD is un-configured from BGP or shutdown locally.

BFD will send state DOWN to BGP resulting in BGP session DOWN.
(This is akin to saying do not use BFD for BGP)
Removing BFD session administratively shouldn't bring DOWN BGP session at
local or remote.

Signed-off-by: Sayed Mohd Saquib sayed.saquib@broadcom.com
2019-10-28 21:38:20 -07:00
Donald Sharp 102e215737 bfdd: VRF and Coverity
Fixup a couple of Coverity issues surrounding pointers

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-10-25 20:26:29 -04:00
Rafael Zalamena 38e9efd85f bfdd: don't allow link-local without interface
When using link-local addresses we must provide scope-id to the
operating system so it knows where to send packets.

Spotted by Pavel Ivashchenko (@zays26).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-10-11 16:54:51 -03:00
Rafael Zalamena ced291deb7 bfdd: simplify session observers code
Don't be selective about what to observe, always observe all possible
aspects of the session that may change on run-time (i.e. bind address,
interface and VRF existence).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-10-11 16:13:24 -03:00
Rafael Zalamena 8ee0862e80 bfdd: set session down after disabling it
If a session is no longer able to send/receive packets, it is very
likely it will be down in a few milliseconds so lets speed up the
process and correctly mark it as down.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-10-11 16:12:49 -03:00
Rafael Zalamena 507d75d453 bfdd: disable sockets polling before closing it
Otherwise the `thread_read` will keep waking us up to handle closing
sockets which are never unregistered.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-10-11 11:15:56 -03:00
Philippe Guibert c7666ae7a1 bfdd: upon vrf disable, unlink bfd session with vrf
bfd session has a vrf pointer that needs to be reset, when vrf is
disabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-10-11 11:12:21 -03:00
SumitAgarwal123 13044b6f6f bfdd: Fixing coredump in log
Param missing in debug log, leading to coredump

Signed-off-by: Sayed Mohd Saquib <sayed.saquib@broadcom.com>
2019-10-11 10:59:20 -03:00
Igor Ryzhov 1e81afc365 *: remove redundant brackets in commands
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-10-08 15:31:40 +03:00
Russ White 9898a2fb34
Merge pull request #5009 from donaldsharp/interface_deletion
lib, zebra: Allow for interface deletion when kernel event happens
2019-09-30 07:46:19 -04:00
Igor Ryzhov e429a2a0cc *: fix missing VRF autocompletions
Current autocompletion works only for simple "vrf NAME" case.

This commit expands it also for the following cases:
- "nexthop-vrf NAME" in staticd
- usage of $varname in many daemons

All daemons are updated to use single varname "$vrf_name".

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2019-09-24 19:51:46 +03:00
Donald Sharp 3c3c325203 *: Convert zapi->interface_delete to ifp callback
Convert the callback of the interface_delete to the new
ifp callback.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp ef7bd2a3d5 *: Switch all zclient->interface_add to interface create callback
Switch the zclient->interface_add functionality to have everyone
use the interface create callback in lib/if.c

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Donald Sharp 138c5a7450 *: Add infrastructure to support zapi interface callbacks
Start the conversion to allow zapi interface callbacks to be
controlled like vrf creation/destruction/change callbacks.

This will allow us to consolidate control into the interface.c
instead of having each daemon read the stream and react accordingly.
This will hopefully reduce a bunch of cut-n-paste stuff

Create 4 new callback functions that will be controlled by
lib/if.c

create -> A upper level protocol receives an interface creation event
The ifp is brand spanking newly created in the system.
up -> A upper level protocol receives a interface up event
This means the interface is up and ready to go.
down -> A upper level protocol receives a interface down
destroy -> A upper level protocol receives a destroy event
This means to delete the pointers associated with it.

At this point this is just boilerplate setup for future commits.
There is no new functionality.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-09-19 13:34:06 -04:00
Renato Westphal 8685be73e0 Revert "lib: introduce a read-write lock for northbound configurations"
Adding a lock to protect the global running configuration doesn't
help much since the FRR daemons are not prepared to process
configuration changes in a pthread that is not the main one (a
whole lot of new protections would be necessary to prevent race
conditions).

This means the lock added by commit 83981138 only adds more
complexity for no benefit. Remove it now to simplify the code.

All northbound clients, including the gRPC one, should either run
in the main pthread or use synchronization primitives to process
configuration transactions in the main pthread.

This reverts commit 83981138fe.
2019-09-18 14:35:10 -03:00
Russ White fe8d933c2c
Merge pull request #4564 from pguibert6WIND/misc_vrf_update_name
Misc vrf update name
2019-09-17 07:22:22 -04:00
Quentin Young 9dcb41a65c
Merge pull request #4604 from opensourcerouting/mutex-sugar
mutex syntactic sugar
2019-09-03 14:55:14 -04:00
David Lamparter 0cf6db21ec *: frr_elevate_privs -> frr_with_privs
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-09-03 17:18:35 +02:00
Philippe Guibert 8cf3c21737 bfdd: close bfd echo sockets, upon vrf disable
upon vrf disable, an event informs bfd daemon that the vrf contexts
should be removed. in the case a vrf backend is netns based, all sockets
opened under that netns have to be closed. otherwise it is impossible
for the system to completely close the network namespace. that implies
that some interfaces may not be deleted, and may not be given back to
default vrf.

PR=65291
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Acked-by: Julien Floret <julien.floret@6wind.com>
2019-09-03 17:06:52 +02:00
Philippe Guibert 955d3ad8a8 bfdd: change vrf name with bypassing nb api
bfd operational & config data may already applied and available, while
an external event requests for changing the vrf name. this change
updates the config and operational context of yang.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 16:58:47 +02:00
Philippe Guibert f06e248c53 bfdd: update vrf name of bfd session if necessary
if the bfd session is already enabled, then dynamically change the vrf
name if the vrf where bfd is executed changed its name.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 15:08:50 +02:00
Philippe Guibert 43ba41c1a3 bfdd: add the vrf update hook in case vrf name changes
in case vrf name changes, use a hook to be notified about the vrf
change.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 15:08:50 +02:00
Philippe Guibert e0f36c91e2 bfdd: if no vrfname is passed, use default vrf name
default vrf name is used to forge the key that permits storing the
session.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 15:08:50 +02:00
Philippe Guibert 3a20889ff6 bfdd: add vrf information as key element for bfd session search
the default vrf is looked up, in the search list algorithm.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-08-27 15:08:50 +02:00
Rafael Zalamena 284062bf17 bfdd: keep source information for single hop
Add source address to northbound when creating sessions with this
information. It is not possible to change source address after the
session was created, but we should be able to set it to make IPv6 work.

Spotted by Philippe Guibert.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-09 09:49:45 -03:00
Rafael Zalamena 307fc4259a bfdd: fix some CI warnings
Use `static` functions for file local functions to please `check_patch.pl`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-07-02 13:05:27 -03:00
Rafael Zalamena fdf8ac87f8 bfdd: convert bfd command to northbound
This helps northbound to create the `bfd` node on the configuration
output sooner than adding a peer.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-25 09:34:14 -03:00
Rafael Zalamena 77452ad263 bfdd: small tweaks on northbound
* Change `ERR_VALIDATION` to `ERR_INCONSISTENCY` to error on
    inconsistent state.
  * Duplicated sanity checks:
    * Remove detection multiplier sanity check.
    * Remove duplicated session sanity check.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-25 09:06:48 -03:00
Rafael Zalamena 8e0c84ff27 bfdd: fix compilation warnings on OmniOS
Build will fail with `Werror` enabled with:

```
  CC       bfdd/bfdd_cli.o
In file included from ./lib/frratomic.h:21:0,
                 from ./lib/memory.h:22,
                 from ./lib/vector.h:25,
                 from ./lib/command.h:25,
                 from bfdd/bfdd_cli.c:23:
./config.h:665:0: error: "_FILE_OFFSET_BITS" redefined [-Werror]
 #define _FILE_OFFSET_BITS 64
 ^
In file included from /usr/include/iso/stdlib_iso.h:49:0,
                 from /usr/include/stdlib.h:37,
                 from ./lib/memory.h:20,
                 from ./lib/vector.h:25,
                 from ./lib/command.h:25,
                 from bfdd/bfdd_cli.c:23:
/opt/gcc-5.1.0/lib/gcc/i386-pc-solaris2.11/5.1.0/include-fixed/sys/feature_tests.h:231:0: note: this is the location of the previous definition
 #define _FILE_OFFSET_BITS 32
 ^
In file included from ./lib/thread.h:24:0,
                 from ./lib/vty.h:27,
                 from ./lib/command.h:26,
                 from bfdd/bfdd_cli.c:23:
./lib/zebra.h:271:2: error: #warning "assuming 4-byte alignment for CMSG_SPACE" [-Werror=cpp]
 #warning "assuming 4-byte alignment for CMSG_SPACE"
  ^
./lib/zebra.h:277:2: error: #warning "assuming 4-byte alignment for CMSG_LEN" [-Werror=cpp]
 #warning "assuming 4-byte alignment for CMSG_LEN"
  ^
cc1: all warnings being treated as errors
Makefile:6876: recipe for target 'bfdd/bfdd_cli.o' failed
gmake[1]: *** [bfdd/bfdd_cli.o] Error 1
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-24 13:42:40 -03:00
Rafael Zalamena eefca51eb3 bfdd: fix compilation warnings on OpenBSD
Build will fail with `Werror` enabled with:

```
bfdd/bfdd_northbound.c:876: warning: initialized field overwritten
bfdd/bfdd_northbound.c:876: warning: (near initialization for 'frr_bfdd_info.nodes[0].cbs')
...
cc1: error: unrecognized command line option "-Wno-unused-result"
gmake[1]: *** [Makefile:6875: bfdd/bfdd_northbound.o] Error 1
```

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-24 11:46:29 -03:00
Philippe Guibert f7bb830439 bfdd: authorise multihop and interface setting
the restriction to authorise multihop and interface setting has no
meaning here.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-22 10:10:56 -03:00
Philippe Guibert 7818c5fba0 bfdd: add not '\n' to shutdown help string
help string had not a '\n' at the end of the line for bfd shutdown help
command.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 8a676ce6b1 bfdd: use microseconds timers in YANG
Lets allow specification to accept microseconds, but limit the timers
configuration in FRR to milliseconds (minimum is 10 ms and maximum is 60
seconds).

This matches the RFC 5880 and the IETF BFD YANG draft model.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 2a573ff672 bfdd: support global BFD reset
Add command 'no bfd' to remove all BFD sessions configuration and fix
other daemon integration.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 47a7b00c2d bfdd: fix daemon warning on startup
```
warnings: BFD: [EC 100663317] YANG model "frr-bfdd@*" not embedded, trying external file
```

Embed the YANG model into the binary to avoid reading an external file.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 49cc9e7b64 bfdd: implement configuration reload
Reload configuration on SIGHUP using the northbound.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 0030482f5e bfdd: fix northbound remote-discriminator display
When the remote discriminator hasn't been assigned yet, then we can't
return a value of 0. The value '0' is an invalid discriminator and the
yang handlers will complain about it.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 0287a64a6e bfdd: implement write_config using northbound
Move all the `show running-config` logic to the new northbound
implementation.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena adc26455bf bfdd: migrate session commands to northbound
Lets start using the new BFD yang model and translate the BFD session
configuration commands to use the northbound.

One important change: all sessions will default to use
`VRF_DEFAULT_NAME` (usually "default") when no VRF is configured. All
places which search for BFD sessions must now take this into account.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:10:56 -03:00
Rafael Zalamena 3e4e7405ff bfdd: remove the label command
This command has no use for CLI and is relevant for the control socket only.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:08:33 -03:00
Rafael Zalamena 014cab13bf bfdd: export some private functions
These functions are going to be used by the future northbound
implementation to handle BFD sessions.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-06-22 10:08:33 -03:00
Donald Sharp 574fa9a597
Merge pull request #4536 from pguibert6WIND/bfd_startup_does_not_work
bfdd: avoid double socket initialisation on same netns
2019-06-21 19:41:02 -04:00
Philippe Guibert 30c5d21ee3 bfdd: avoid double socket initialisation on same netns
when working with a standard vrf backend, bfdd ignores that and tries to
create and configure bfd sockets for each vrf, which will fail for the
second vrf discovered, since the network namespace used is the same, and
it is not possible to use same socket settings twice. Handle this case,
and avoids to reinitialise sockets.
This patch however does not leverage bfd support for vrf-lite.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-06-21 09:21:03 +02:00
David Lamparter 1b88c3cb4c bfdd: use MTYPE_STATIC
MTYPE definitions should be local to the file using them whereever
possible.  Also remove some superfluous ;

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2019-06-21 08:54:25 +02:00
Mark Stapp fa3bf3a21b lib,bgpd,babeld,ripngd,nhrpd,bfdd: clean up SA warnings
Clean up several SA warnings.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
2019-06-06 13:13:15 -04:00
Rafael Zalamena 9e8238f5d6
Merge pull request #4431 from donaldsharp/mad_gainz
Switch over to `-N FOO` adding FOO to the various directories/files we open up
2019-06-05 11:30:19 -03:00
Donald Sharp 9f95a33ad0 bfdd: Modify bfdd to quietly accept access-lists
The `access-list ...` command was causing bfdd to return
'unknown commands'.  Make bfdd at least cognizant of
access-lists enough to not create strange error messages

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-04 21:38:11 -04:00
Donald Sharp 89277ebf76 bfdd: Allow -N to influence BFDD_CONTROL_SOCKET
When selecting to run bfdd with -N allow the namespace passed
in to be added to the $frr_statedir/<namespace name>/bfdd.sock

If --bfdctl is passed in that will override the -N option.

If neither --bfdctl or -N is passed in then the default
of  $frr_statedir/bfdd.sock is used.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-06-04 10:37:19 -04:00
Russ White ace430f0db
Merge pull request #4144 from pguibert6WIND/bfd_cbit
BFD CBIT
2019-05-16 10:13:26 -04:00
Quentin Young d8b87afe7c lib: hashing functions should take const arguments
It doesn't make much sense for a hash function to modify its argument,
so const the hash input.

BGP does it in a couple places, those cast away the const. Not great but
not any worse than it was.

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-14 21:23:08 +00:00
Philippe Guibert 9beff0bda9 bfdd, lib, bgpd: add bfd cbit usage
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-14 16:49:49 +02:00
Philippe Guibert f21536d2f0 bfd: add bfdd_privs to the bglobal structure
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-07 16:01:47 +02:00
Philippe Guibert 533ba31ff4 bfdd: show bfd [vrf NAME] peer command change
the vrf keyword is possible through show bfd command. However, there is
a change with previous version, since that show command was accepting
vrf keyword, only after peer keyword. Now, the vrf keyword is accepted,
but before peer keyword.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert 6f37416509 bfdd: add show bfd [vrf NAME] counters command
that command permits to filter bfd peer counter contexts per vrf.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert 9146cc2a10 bfdd: add show bfd [vrf NAME] peers command
this command permits to filter among the list of bfd peers which one is
to be displayed.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:47 +02:00
Philippe Guibert 5ef92a2b20 bfdd: avoid creating duplicate peer contexts
when configuring bfd peers, some parameters may or may not be taken into
account to search for a previous context. This has as consequence that
the result is different with the order of vty commands:

bfd
peer 4.5.6.7 vrf AAAA local-address 1.2.3.5
end
peer 4.5.6.7 vrf AAAA   <--- should not create new session
end

Similarly, the user thinks it has overwritten some key parameters like
local address, whereas it is wrong.
here, some informational message should be present.

bfd
peer 4.5.6.7 vrf AAAA
end
peer 4.5.6.7 vrf AAAA local-address 1.2.3.5
<--- should inform that the key lookup 1.2.3.5 is wrong
end

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 16:01:42 +02:00
Philippe Guibert 3e60827a3b bfdd: do not insert obs entry in the list, once disabled
the bfd entry has not to be inserted in the obs list again.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:54:30 +02:00
Philippe Guibert b433551595 bfdd: check bfd on upon interface presence from separate vrf
if a separate vrf detects a new interface, then some bfd sessions may be
run.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:54:30 +02:00
Philippe Guibert d24af713c1 bfdd: upon vrf enable/disable, update bs and obs list
parse observer list, and update bs context if vrf pointer is not yet populated.
this is helpful for validation, but also will permit bfd to send
notification to remote daemon.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:54:30 +02:00
Philippe Guibert 54aadda13d bfdd: register to interfaces from other vrfs
registration for new interfaces is done.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:53:07 +02:00
Philippe Guibert 45b000d085 bfdd, zebra: pass the vrf identifier between zebra and bfdd
messages from daemons to bfd daemons go through zebra. zebra reuses the
vrf identifier to send messages to bfd.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:53:07 +02:00
Philippe Guibert 7bcadbaefe bfdd: socket handling per vrf context
sockets are created foreach network namespace context enabled.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert 9fc0bc5cfc bfdd: add vrf framework
vrf initialisation is done. hooks are installed. no specific action is
done, except the vrf initialisation.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert 1f4b73e54c bfdd: use vrf api for creation socket with binding with vrf lite
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-07 15:49:39 +02:00
Philippe Guibert 218afa3671 bfdd: permit to configure both iface and vrf
it is possible to configure both iface and vrfname. also, the
appropriate vrf is used, in case an iface is given.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert 4e6b48d3db bfdd: add sys_admin capability and net_raw capability
in order to be able to create sockets on separate namespaces, add the
privs setting needed.
the former capability is needed to use SO_BINDTODEVICE option.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert e52a638341 bfdd: socket creation in a vrf can be done
vrf_socket() call is performed instead of socket() call.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert 5764d816d3 bfdd: remove the constraint of bfd vrf and multihop
there is no specific constraints that should prevent from configuring a
multihop bfd session within a bfd session.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert bc50bcc83c bfdd: move bfd_ses_[xx] to bfd_sess_[xx] like other routines
this is a change to be more consistent with function naming convention
in bfd. a small change for 3 functions.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Philippe Guibert 1ac865e7d4 bfdd: use logging convention for remaining zlog_debug
zlog_debug is being replaced with log_debug, because all bfdd code uses
that way of logging information.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-05-07 15:49:39 +02:00
Quentin Young 121f9dee7c *: use ZAPI_CALLBACK_ARGS macro for zapi handlers
This macro:
- Marks ZAPI callbacks for readability
- Standardizes argument names
- Makes it simple to add ZAPI arguments in the future
- Ensures proper types
- Looks better
- Shortens function declarations

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-05-03 20:57:35 +00:00
Russ White a34fd5b9f1
Merge pull request #4155 from pguibert6WIND/bfd_increase_config
bfdd: avoid having bfd config inherited from operation context
2019-04-25 18:48:35 -04:00
Rafael Zalamena 545d3f7046 bfdd: fix UDP source port range
RFC 5881 Section 4 tells us that the BFD source port must be between
49152 and 65535 inclusive.

Spotted by Lucian Cristian.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-04-25 14:41:44 -03:00
Philippe Guibert 4c741971a5 bfdd: remove operational bfd sessions from remote daemons
when a remote daemon wants to get rid of a session, a request is sent,
but the deletion of the bfd session was not done. The flush is done,
provided that there is not someone else that is using that session.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-18 11:48:16 +02:00
Philippe Guibert 6bdb4a42ac bfdd: avoid having bfd config inherited from operation context
there are cases where bfd sessions are created from remote daemons. in
that case, the bfd daemon were appearing in both operational and
configuration contexts of bfd. Change that by only keeping operational
contexts.

Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
2019-04-18 11:48:16 +02:00
Renato Westphal 84cffea04f
Merge pull request #4042 from donaldsharp/bfd_sa
bfdd: Clean up assignment without being used SA issue
2019-03-30 00:19:24 -03:00
Donald Sharp 9d6c33eadf bfdd, nhrpd, pimd: When deleting an interface clean up
When we delete an interface, we need to set the interface
ifindex to an internal value so that we don't end up in
a state where the re-addition of the same ifindex, due to
a rename operation, causes an infinite loop.

Fixes:#4007
Fix-Suggested-by: Saravanan K
Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-29 12:44:05 -04:00
Donald Sharp 3cef9b7ffd bfdd: Clean up assignment without being used SA issue
Clang's SA is reporting that we have a assignment without
subsuquent use.  Modify the code such that we no-longer
do this.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-29 11:35:07 -04:00
Donald Sharp ed74032b7f bfdd: Prevent uninited use of data
Running valgrind w/ bfdd and shut/no shuting interfaces
can result in this valgrind issue:

==20279== Conditional jump or move depends on uninitialised value(s)
==20279==    at 0x115848: bfdd_sessions_enable_address (ptm_adapter.c:644)
==20279==    by 0x115848: bfdd_interface_address_update (ptm_adapter.c:674)
==20279==    by 0x48D8CAB: zclient_read (zclient.c:2698)
==20279==    by 0x48CCEE3: thread_call (thread.c:1603)
==20279==    by 0x48A84EF: frr_run (libfrr.c:1011)
==20279==    by 0x10DAC3: main (bfdd.c:236)
==20279==

When creating the bso data structure set the bso_isaddress to false
as a default value.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-03-20 10:32:58 -04:00
Rafael Zalamena 4cf4e83297 bfdd: fix echo loopback function
Add the address family to the sockaddr structure otherwise `sendmsg`
will fail with `EAFNOSUPPORT`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-19 17:25:00 -03:00
Rafael Zalamena 5ff7d1be75 bfdd: fix JSON API local-address translation
Get the local-address from the right key struct member.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-19 17:22:58 -03:00
Rafael Zalamena 261e0ba94d bfdd: don't enable sessions without local-address
When the local-address configured by the peer doesn't exist, then we
must observe the session until the mentioned address comes up.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-11 22:03:29 -03:00
Rafael Zalamena 79b4a6fceb bfdd: change session lookup data structure
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-03-11 22:03:23 -03:00
Rafael Zalamena 2435b7defe bfdd: fix single hop IPv6 configurations
Don't assume IPv6 will always be multi hop and handle the single hop
link-local address case.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-03-06 17:50:04 -03:00
Quentin Young 76f0146890 *: do not check XMALLOC / XCALLOC for null ret
They never return NULL

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:44 +00:00
Quentin Young d8729f8cb5 *: use proper bool initializers & fix comparisons
- bools should be initialized with true/false
- bools do not need to be compared

Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
2019-02-25 23:00:16 +00:00
Tim Bray e3b78da875 *: Rename backet to bucket
Presume typo from original author

Signed-off-by: Tim Bray <tim@kooky.org>
2019-02-25 16:22:36 +00:00
Rafael Zalamena 9f37770f59 bfdd: fix CI warnings
Fix a few checkpatch warnings and a clang analyzer warning of
uninitialized variable.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena e945606e1e bfdd: fix discriminator mismatch log message
The discriminator is an unsigned 32bit variable.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena 0c1af3e49f bfdd: apply new timers on on-going connections
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-14 14:18:23 -02:00
Rafael Zalamena 33400b469e bfdd: header clean up
Remove some unused definitions in the bfd daemon header.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena 46c8ef96a3 bfdd: don't allow VRF for single hop session
Single hop sessions already allow you to select the interface, which
should be enough to determine the VRF we are running in.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:18:23 -02:00
Rafael Zalamena d245e522f0 bfdd: implement session interface observer
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-14 14:18:23 -02:00
Rafael Zalamena 843b324ddd bfdd: generate random session identificators
This also avoids returning `session_id == 0` which should not happen.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena 6f4beb7b30 bfdd: remove unused vrf/interface data structures
Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena b333abc295 bfdd: refactor session lookup
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-14 14:17:29 -02:00
Rafael Zalamena b912b189c7 bfdd: slow down on peer connection loss
Lets be more RFC 5880 compliant and slow down control packets on
connection loss.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena ff91bf7fb2 bfdd: don't try to start echo on protocol restart
`echo-mode` should and will automatically start after session goes up
and it is allowed by the remote peer. See `bs_echo_timer_handler` for
more information.

This avoids having echo controling code spread.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena 1f2d5f91ee bfdd: change slow time value
Let's use the RFC 5880 suggested value of 1 second for slow
transmission speed.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena f43b93686f bfdd: simplify timer data structure
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-14 14:17:29 -02:00
Rafael Zalamena f78dd3a793 bfdd: don't poll to make echo/multiplier changes
RFC 5880 says that it is only necessary to run polling in two cases:

  - Desired minimum transmission interval;
  - Required minimum receive interval;

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena 73c62f8eb3 bfdd: deduplicate echo handling code
Use the standardized echo timer handling function.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena 0592db9630 bfdd: fix bug on poll sequence
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-14 14:17:29 -02:00
Rafael Zalamena 8bd859f6d3 bfdd: echo-mode doesn't need poll to start/stop
Remove all polling negotiation when starting/stopping `echo-mode` as it
is not necessary.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-02-14 14:17:29 -02:00
Rafael Zalamena c0ef9a8a50 bfdd: refactor timer handling
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-14 14:17:29 -02:00
Rafael Zalamena aef131afc5 bfdd: refactor state change handler
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-02-14 14:17:29 -02:00
Donald Sharp a244e59954 bfdd: Add show debugging [bfd] command
This will prevent vtysh from displaying `command imcomplete`
for a `show debugging` issued and we are running this
bfd daemon.  A quick look showed me that there was not
really the ability to turn on/off debugging like other
daemons.  I imagine future work can be focused here.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-13 23:24:05 -05:00
Donald Sharp 6038fe4584 bfdd: Add some code so we can compile from w/ in the bfdd dir
Copy pattern of Makefile from other daemons to allow us to
compile this thingie(tm) from within the bfdd directory.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-02-13 23:23:48 -05:00
Rafael Zalamena 46b020ce1a
Merge pull request #3605 from donaldsharp/bfd_24_minutes
bfdd: Fix timer print-out function
2019-01-14 11:20:54 -02:00
Donald Sharp 23586b0552 bfdd: Fix timer print-out function
The timer2str function thought 24 minutes was an hour and had a
couple of other issues that needed to be corrected.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2019-01-12 16:22:32 -05:00
Rafael Zalamena 75351ffae0 bfdd: remove unused OS specific functions
We are using zebra to learn about the network interfaces and no longer
need to use OS specific system calls to get it.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2019-01-10 17:20:09 -02:00
Rafael Zalamena 80edb6758f bfdd: use zebra to learn about network interfaces
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>
2019-01-10 17:18:35 -02:00
Rafael Zalamena f43a14d2d3 bfdd: fix multihop on FreeBSD
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-11-30 15:02:23 -02:00
Renato Westphal 9f0dc29b03
Merge pull request #3276 from donaldsharp/zclient_update
*: Replace zclient_new with zclient_new_notify
2018-11-12 13:40:47 -02:00
Donald Sharp 26f63a1ec6 *: Replace zclient_new with zclient_new_notify
It's been a year since we added the new optional parameters
to instantiation.  Let's switch over to the new name.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-11-12 09:16:23 -05:00
Rafael Zalamena dcc39aa510 bfdd: fix BGP unnumbered peer setup
The session key uses the scope id to figure out which interface we are
using with that link-local address, so if we don't set it when
registering a session we'll end up with multiple IPv6 sessions.

This bug was spotted by Sandro Bolliger.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
(cherry picked from commit de61f256d6)
2018-11-09 10:04:34 -02:00
David Lamparter 064518517c Merge branch 'pull/3197'
...with a nit fix

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-10-23 12:31:25 +02:00
Renato Westphal affa816bd6 bfdd: do not allow multihop peers without a local-address
The BFD code assumes that multihop peers have a local address
configured. When that doesn't happen, the BFD client daemons fail to
decode some BFD ZAPI messages and abort. To fix this, do not accept the
configuration of multhop peers unless a local-address is configured.

Fixes the following segfaults:
- bgpd aborted: vtysh -c "configure terminal" -c "bfd" -c "peer 1.1.1.1 multihop"
- bgpd aborted: vtysh -c "configure terminal" -c "bfd" -c "peer 1.1.1.1 multihop vrf NAME"
- bgpd aborted: vtysh -c "configure terminal" -c "bfd" -c "peer 1.1.1.1 vrf NAME multihop"
- ospf6d aborted: vtysh -c "configure terminal" -c "bfd" -c "peer 1.1.1.1 multihop"
- ospf6d aborted: vtysh -c "configure terminal" -c "bfd" -c "peer 1.1.1.1 multihop vrf NAME"
- ospf6d aborted: vtysh -c "configure terminal" -c "bfd" -c "peer 1.1.1.1 vrf NAME multihop"

Signed-off-by: Renato Westphal <renato@opensourcerouting.org>
2018-10-20 12:39:05 -03:00
Donald Sharp 74df8d6d9d *: Replace hash_cmp function return value to a bool
The ->hash_cmp and linked list ->cmp functions were sometimes
being used interchangeably and this really is not a good
thing.  So let's modify the hash_cmp function pointer to return
a boolean and convert everything to use the new syntax.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-10-19 13:14:45 -04:00
Rafael Zalamena 2055ea0969 bfdd: fix multi hop hash lookup
Use the proper multi hop hash for matching multi hop peers.

Spotted by Dmitrii Turlupov.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-10-14 15:39:55 +02:00
Rafael Zalamena 744f824a73 bfdd: allow timer deactivation on shutdown
Peers being shutdown were keeping their timers, so move the cancel code
before the shutdown check.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-10-01 14:15:25 -03:00
Rafael Zalamena 451eb5a2f8 bfdd: disable echo on neighbor request
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-10-01 14:15:25 -03:00
F. Aragon 4848ef7430
bfdd zebra: dead code (Coverity 1472624 1473199)
Signed-off-by: F. Aragon <paco@voltanet.io>
2018-09-26 17:50:33 +02:00
Donald Sharp eac04cfd59
Merge pull request #2977 from opensourcerouting/doc-fix
build: fix not building docs w/o sphinx
2018-09-09 14:52:38 -04:00
Donald Sharp 5381b930b3
Merge pull request #2965 from opensourcerouting/buildfoo-20180904
more build fixes & warning-free build
2018-09-09 14:11:10 -04:00
David Lamparter f4f2f2ccac build: fix not building docs w/o sphinx
Can't build manpages without sphinx-build, oops...

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-09 20:01:08 +02:00
Donald Sharp 55e6c1329f
Merge pull request #2862 from opensourcerouting/non-recursive
final non-recursive make
2018-09-09 13:51:58 -04:00
David Lamparter ae9eebcaeb *: fix some solaris warnings
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
David Lamparter e7c25325cc *: cleanup .gitignore files
Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:42 +02:00
David Lamparter 74dc19a2f5 build: move vtysh & manpage listings to subdir.am
Since we're now building through one large Makefile, we can easily put
things with their daemons and crossreference nicely.

Signed-off-by: David Lamparter <equinox@diac24.net>
2018-09-08 21:30:19 +02:00
David Lamparter e10cfdaf51 bfdd: fix garbage "port" string
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-08 20:34:35 +02:00
Rafael Zalamena 9835f17d33 bfdd: fix crash when receiving invalid echo packet
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-05 12:29:14 -03:00
Rafael Zalamena 8529e18048 bfdd: use THREAD_OFF() instead of thread_cancel()
Use a standardized function to cancel threads instead of hand rolling
our own.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-05 12:27:52 -03:00
Rafael Zalamena 2f11c53f55 bfdd: use UDP sockets instead of raw
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-03 10:41:33 -03:00
Rafael Zalamena 40675ea908 bfdd: enumerate all diagnositic codes
Enumerate all codes, update the string representation and fix the
misdiagnosed echo failure.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-09-03 10:41:33 -03:00
Rafael Zalamena 50571b2ee7 bfdd: make bfd_recv_* more generic
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-03 10:41:33 -03:00
Rafael Zalamena 8a9f760ed9 bfdd: remove VxLAN code
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-03 10:41:33 -03:00
Rafael Zalamena 6e01e275dd bfdd: remove global variables and improve logs
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-09-03 10:41:33 -03:00
Rafael Zalamena 3bcd76c4af bfdd: fix coverity scan issue (CID 1472622)
Don't use the stack variable, but what we have recorded in our buffered
data on the heap.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-16 18:33:32 -03:00
Rafael Zalamena ae9f45a3ae bfdd: improve ptm_adapter log messages
Make them look like the rest of the daemon: message begins with a unique
descriptive message to help locate debug messages.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-16 18:33:32 -03:00
Rafael Zalamena ff98a58940 bfdd: fix coverity scan issues (1472630, 1472623)
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-16 18:32:16 -03:00
Rafael Zalamena 0684c9b12c bfdd: add new counters and command to show them
Added 3 new counters to BFD sessions:
* Session up events count;
* Session down events count;
* Zebra notifications count;

In addition to previosly available counters:
* Count of received control packets;
* Count of transmitted control packets;
* Count of received echo packets;
* Count of transmitted echo packets;

With this count we are able to visualize the BFD activity, bandwidth
usage, interface/network flapping and excess of zebra notifications.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-15 17:09:54 -03:00
Rafael Zalamena 89a634c1f8 bfdd: turn repeatable code into functions
Turn some code that will be repeated in the next commits into functions
so we avoid that.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-15 17:09:54 -03:00
Donald Sharp 97f21f8c64
Merge pull request #2838 from opensourcerouting/bfd-alpine
bfdd: fix alpine build
2018-08-15 15:30:26 -04:00
Donald Sharp f0d2be3317 bfdd: Fix don't assign to value to ourself compiler warning
We were attempting to get around a unused value by setting
a variable to itself, but it runs afoul of a different
compiler and a message about not setting a variable to
itself.  So let's mark the ttl value as unused.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
2018-08-15 13:48:09 -04:00
Rafael Zalamena 1608496459 bfdd: fix alpine build
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-14 17:52:14 -03:00
Rafael Zalamena 98ef9c165c bfdd: fix downtime display
BFD peer status show command was using the wrong variable to display the
downtime counter.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-14 17:52:14 -03:00
Rafael Zalamena 43adc702e1 bfdd: fix IPv6 peers using link-local address
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-08 18:25:08 -03:00
Rafael Zalamena 788378fefa bfdd: clean-up bfd clients data on shutdown
On `zebra` / `bfdd` shutdown we now clean up all client data to avoid
memory leaks (ghost clients). This also prevents 'slow' shutdown on
`zebra` sparing us from seeing some rare topotests shutdown failures
(signal handler getting stopped by signal).

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena 03e7f08881 bfdd: improve logging messages
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-08 18:25:08 -03:00
Rafael Zalamena 6ed8494935 bfdd: clean up header inclusion
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-08 18:25:08 -03:00
Rafael Zalamena 9d63adda98 bfdd: code refactory for simplification
Simplify code and remove unnecessary log messages. The old log messages
are going to be shown by the caller anyway.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena a375de5c46 bfdd: free zebra clients data on unregistration
Avoid a memory leak on client daemons restart by getting rid of old
registrations.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena 971532e2e7 bfdd: send replay request on zebra connection
This will make `bfdd` synchronize with its client when zebra dies or
bfdd is restarted.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena f85498ef0a bfdd: show single hop local-address
Show local-address on single hop when configured.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena d3f3a2c4dc bfdd: smooth configuration transition
After configuring a new value set the polling bit to negotiate speeds
again next transmission cycle.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena 674680df69 bfdd: show the correct transmission speed
When configured transmission speed doesn't match the actual speed, show
the difference in the output.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:08 -03:00
Rafael Zalamena d3af6147a1 bfdd: re-route PTM-BFD daemon messages
When `bfdd` is enabled - which it is by default - re-route the PTM-BFD
messages to the FRR's internal BFD daemon instead of the external
PTM daemon.

This will help the migration of BFD implementations and avoid
duplicating code.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:04 -03:00
Rafael Zalamena c2f29cf3d7 bfdd: add vty shell commands
Implement vty shell integration and allow `bfdd` to be configured
through FRR's vtysh.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:25:04 -03:00
Rafael Zalamena e9e2c950d7 bfdd: imported new daemon source code
Import source code from external `bfdd` daemon ported from Cumulus PTM.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2018-08-08 18:24:53 -03:00