Commit graph

30 commits

Author SHA1 Message Date
Acee Lindem aa50f5ebb8 bfdd: Add BFD "log-session-changes" feature.
Add the BFD "log-session-changes" via the YANG and northbound API. Also
add the configured value to show and operational state.

Signed-off-by: Acee Lindem <acee@lindem.com>
2025-03-03 22:46:01 +00:00
Donald Sharp 6d80d0c595 bfdd: Use pass by reference instead of pass by value for a struct
The function bfd_key_lookup is currently sending by value for
a now very large structure.  Let's convert this over to pass
by reference.  This is noticed by coverity.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-05 08:42:00 -05:00
wumu.zsl e58f018e43 bfdd: implement Xpath callbacks for SBFD
Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:30:44 +00:00
wumu.zsl 12af5e19a1 bfdd: support sbfd session create and destroy
refactor bfd_session_create and bfd_session_destroy to support SBFD

Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:29:09 +00:00
wumu.zsl c4f9964aec bfdd: add bfdname in bfd_key
sbfd will use bfdname for key hash, We introduced a bfd-name for every sbfd session, normal BFD sessions can leave it as NULL.
A unique bfd-name can be used to identify a sbfd session quickly. This is quite useful in our Srv6 deployment for path protection case.
For example, if use the sbfd session to protect the SRv6 path A-B-D, we would assign the name 'path-a-b-d' or 'a-b-d' to the session.

Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-22 15:00:24 +00:00
Christian Hopps 2c01083d35 lib: all: remove './' from xpath 22% speedup
fixes #8299

Signed-off-by: Christian Hopps <chopps@labn.net>
2023-11-29 14:37:23 -05:00
Igor Ryzhov f7884aedf7 bfdd: remove redundant nb destroy callbacks
Fixes warning logs:
```
2023/05/29 20:11:50 BFD: [ZKB8W-3S2Q4][EC 100663330] unneeded 'destroy' callback for '/frr-bfdd:bfdd/bfd/profile/minimum-ttl'
2023/05/29 20:11:50 BFD: [ZKB8W-3S2Q4][EC 100663330] unneeded 'destroy' callback for '/frr-bfdd:bfdd/bfd/sessions/multi-hop/minimum-ttl'
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2023-05-31 15:28:08 +03:00
David Lamparter acddc0ed3c *: auto-convert to SPDX License IDs
Done with a combination of regex'ing and banging my head against a wall.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2023-02-09 14:09:11 +01:00
anlan_cs ebf8b885de bfdd,yang: optimize nb with YANG
A few optimizations for bfd NB:
    - Remove unuseful checks for parameters with the same values
    - Replace checking values of bfd parameters with YANG's "range"
    - Append "required-echo-receive-interval" with 0 for it can be disabled

Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-01-25 04:00:49 -05:00
Igor Ryzhov 874ca76997 bfdd: forbid setting interface for multihop sessions
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-01 18:08:29 +03:00
Igor Ryzhov f13ad7c542 bbfd: clear nb config entries when removing bfd node
When bfd node is removed, we must clear all NB entries set by its
children - sessions and profiles. Let's store some fake data as an entry
for the bfd node to be able to unset it later.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-01 15:49:27 +03:00
Igor Ryzhov e93c3c003d bfdd: remove profiles when removing bfd node
Fixes #8379.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-04-01 15:49:18 +03:00
Igor Ryzhov 4df3e31c3d bfdd: separate echo rx/tx timers
Currently there is a single interval for both RX and TX echo functions.
This commit introduces separate RX and TX timers for echo packets.

The main advantage is to be able to set the receive interval to zero
when we don't want to receive echo packets from the remote system.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-16 22:14:57 +03:00
Igor Ryzhov 632f36100c bfdd: forbid creation of the same peer with and without interface name
Currently it is possible to configure the same peer with and without
interface name:
```
bfd
 peer 1.1.1.1
 !
 peer 1.1.1.1 interface enp0s3
 !
```

There are multiple problems with that:
1. Both nodes actually control the same BFD session. So the config is
   either duplicated or, even worse, different - and there is no way to
   say which one actually works.
2. When the user deletes both nodes, the session is not actually freed,
   because its refcount is always greater than 1.

Such configuration must be forbidden. User should either have single
node with wildcard name or multiple nodes with actual names.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-03 23:10:19 +03:00
Igor Ryzhov 5e4d0fbc93 bfdd: actually return validation error instead of logging
Before:
```
(config-bfd)# peer fe80::a00:27ff:fea2:5803 multihop local-address fe80::a00:27ff:fea2:5802
% Configuration failed.

Error type: validation
```

After:
```
(config-bfd)# peer fe80::a00:27ff:fea2:5803 multihop local-address fe80::a00:27ff:fea2:5802
% Configuration failed.

Error type: validation
Error description: When using link-local you must specify an interface
```

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-03-03 19:43:00 +03:00
Igor Ryzhov 4ec8e74bd9 bfdd: use * as a placeholder for an empty interface name in northbound
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-24 20:43:38 +03:00
Igor Ryzhov 2e8d292578 bfdd: interface and vrf are mandatory leafs
Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2020-09-24 20:23:21 +03:00
Rafael Zalamena 262e1d2528 bfdd: implement minimum TTL
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>
2020-08-11 21:22:39 -03:00
Rafael Zalamena 4e38f82a0a bfdd: simplify and remove duplicated code
Move the session configuration application logic to a single function.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-08-11 16:46:10 -03:00
Rafael Zalamena 1a2e2fff35 bfdd: implement passive mode
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>
2020-08-11 16:46:10 -03:00
Donald Sharp 3eb15671ee
Merge pull request #6731 from opensourcerouting/style-string-prep
*: string coding style
2020-07-15 20:06:55 -04:00
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
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 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
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 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 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
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
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