Commit graph

106 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 8119e167b0 bfdd: Use pass by reference for bfd_key_delete
Coverity is pointing out that bfd_key_delete is
passing by value instead of reference for a very
large structure.  Double plus not good.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2025-02-05 08:47:31 -05: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 3548b3004d bfdd: enable sbfd session
1) create socket to send sbfd packets
2) integrate sbfd logic with existing BFD

Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:59:09 +00:00
wumu.zsl c58cbb2c44 bfdd: add sbfd state machine functions
Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:58:46 +00:00
wumu.zsl e6a531d092 bfdd: implement functions for sending sbfd pkts with SRv6 header
Two types of sbfd packets are supported: initiator packet and echo packet

Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:57:12 +00:00
wumu.zsl 5107e273d0 bfdd: create a hash table for local sbfd reflector info
Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-23 02:32:03 +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
wumu.zsl 32705fe720 bfdd: add enum bfd_mode_type for different bfd types
Signed-off-by: wumu.zsl <wumu.zsl@alibaba-inc.com>
2025-01-07 03:31:56 +00:00
Rafael Zalamena 20c3756f30 bfdd: disable echo socket when not using it
Lets avoid a performance penalty in forwarding when not using the BFD
echo feature. The echo socket uses raw packet capturing along with a BPF
filter which causes performance issues.

While here change code to use `-1` for closed sockets instead of valid
FD number `0`.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2024-11-12 23:03:20 -03:00
Rafael Zalamena 88a9aa9c6b bfdd: remove control socket obsolete code
Let's remove the obsolete BFD control socket. If the functionality is
needed then YANG/northbound notifications / getting should be used
instead.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2024-07-25 10:37:11 -03:00
sri-mohan1 d9e51c6399 bfdd: changes for code maintainability
these changes are for improving the code maintainability and readability

Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
2024-07-16 15:30:41 +05:30
Igor Ryzhov d315382d47 bfdd: fix BFD_GETCBIT
The macro should check C bit, not F bit.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2024-04-15 01:57:16 +03:00
Igor Ryzhov b6e6656a2e
Merge pull request #15697 from zmw12306/bfd_check_Mflag
bfdd: Add check for flag Multipoint (M)
2024-04-12 16:09:43 +03:00
zmw12306 665ec41339 bfdd: add check for flag M
Signed-off-by: zmw12306 <zmw12306@gmail.com>
2024-04-11 20:30:56 -04:00
David Lamparter 80b6787e27 build: nuke BFDD_CONTROL_SOCKET
This just unnecessarily complicates things by involving autoconf.

Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
2024-01-27 19:01:19 +01:00
Christian Hopps bb6fe6beb9
Merge pull request #14811 from donaldsharp/zebra_final_shutdown_finally
Zebra final shutdown finally
2023-11-28 20:14:42 +01:00
Donald Sharp a3dfb08662 bfdd: Free zclient memory on shutdown
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 12:41:18 -05:00
Donald Sharp 07b91ca096 *: Let's use the native IFNAMSIZ instead of INTERFACE_NAMSIZ
INTERFACE_NAMSIZ is just a redefine of IFNAMSIZ and IFNAMSIZ
is the standard for interface name length on all platforms
that FRR currently compiles on.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-11-21 08:08:29 -05:00
Igor Ryzhov 5b28833d38
Merge pull request #13675 from zmw12306/bfd_version_check
bfd:fix version bits check
2023-06-11 14:16:50 +03:00
zmw12306 3f658e8b1c bfdd: fix version bits check.
The version of bfd pkt is represented by 3 bits in B[0].
Signed-off-by: zmw12306 <zmw12306@gmail.com>
2023-06-03 15:08:34 -04:00
zmw12306 98707b04d4 bfd: fix missing Authentication in control pkt
According RFC 5880, add a simpilfed version handling authentication
Signed-off-by: zmw12306 <zmw12306@gmail.com>
2023-04-25 13:48:18 -04:00
Donald Sharp cd9d053741 *: Convert struct event_master to struct event_loop
Let's find a better name for it.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp 2453d15dbf *: Convert struct thread_master to struct event_master and it's ilk
Convert the `struct thread_master` to `struct event_master`
across the code base.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04:00
Donald Sharp e6685141aa *: Rename struct thread to struct event
Effectively a massive search and replace of
`struct thread` to `struct event`.  Using the
term `thread` gives people the thought that
this event system is a pthread when it is not

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2023-03-24 08:32:17 -04: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
lynnemorrison 618a06fe11 BFDD: Add RTT to BFD IPV4 Echo packet processing
Add a send time into the BFD Echo packet. When the BFD Echo
packet is received back store time it took in usec. When
user issues a show bfd peer(s) command calculate and display
minimum, average, and max time it took for the BFD Echo packet
to be looped back.

Signed-off-by: Lynne Morrison <lynne.morrison@ibm.com>
2022-08-02 10:09:01 -04:00
lynnemorrison 57485b0b4f bfdd: add IPv4 BFD Echo support that matches RFC
Modify the existing BFD Echo code to send an Echo message that will
be looped in the peers forwarding plane.   The existing Echo code
only works with other FRR implementations because the Echo packet
must go up to BFD to be turned around and forwarded back to the
local router.    The new BFD Echo code sets the src/dst IP of the
packet to be the local router's IP and sets the dest MAC to be the
peers MAC address.    The peer receives the packet and because it
is not it's IP address it forwards it back to the local router.

Signed-off-by: Lynne Morrison <lynne.morrison@ibm.com>
2022-06-27 16:21:08 -04:00
Donald Sharp 59ba003346
Merge pull request #11137 from opensourcerouting/if-name-len-fixes
*: standardize interface name maximum length
2022-05-04 07:44:26 -04:00
Rafael Zalamena 3682bd90f3 *: use FRR interface name definition everywhere
Don't rely on the OS interface name length definition and use the FRR
definition instead.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2022-05-02 13:00:12 -03:00
ewlumpkin e9cea444a4 bfdd: remove "local_address" of bfd session
The "local_address" of bfd is only used in `show bfd peers brief`
for single hop sessions which are configured without "local address".
Since it is set by destination address of received packet, not
completely correct, so remove it.

Signed-off-by: ewlumpkin <ewlumpkin@gmail.com>
Signed-off-by: anlan_cs <vic.lan@pica8.com>
2022-05-02 10:40:53 -04:00
Donald Sharp 2b669d3a21 *: Fix spelling of overriden
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-04-19 08:27:02 -04:00
Donald Sharp cc9f21da22 *: Change thread->func to return void instead of int
The int return value is never used.  Modify the code
base to just return a void instead.

Signed-off-by: Donald Sharp <sharpd@nvidia.com>
2022-02-23 19:56:04 -05:00
Igor Ryzhov ac2cb9bf94 *: rework renaming the default VRF
Currently, it is possible to rename the default VRF either by passing
`-o` option to zebra or by creating a file in `/var/run/netns` and
binding it to `/proc/self/ns/net`.

In both cases, only zebra knows about the rename and other daemons learn
about it only after they connect to zebra. This is a problem, because
daemons may read their config before they connect to zebra. To handle
this rename after the config is read, we have some special code in every
single daemon, which is not very bad but not desirable in my opinion.
But things are getting worse when we need to handle this in northbound
layer as we have to manually rewrite the config nodes. This approach is
already hacky, but still works as every daemon handles its own NB
structures. But it is completely incompatible with the central
management daemon architecture we are aiming for, as mgmtd doesn't even
have a connection with zebra to learn from it. And it shouldn't have it,
because operational state changes should never affect configuration.

To solve the problem and simplify the code, I propose to expand the `-o`
option to all daemons. By using the startup option, we let daemons know
about the rename before they read their configs so we don't need any
special code to deal with it. There's an easy way to pass the option to
all daemons by using `frr_global_options` variable.

Unfortunately, the second way of renaming by creating a file in
`/var/run/netns` is incompatible with the new mgmtd architecture.
Theoretically, we could force daemons to read their configs only after
they connect to zebra, but it means adding even more code to handle a
very specific use-case. And anyway this won't work for mgmtd as it
doesn't have a connection with zebra. So I had to remove this option.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-12-21 22:09:29 +03:00
Igor Ryzhov eb4135bad2 bfdd: cleanup vrf handling in packet receive
We get the pointer to the interface on which the packet was received
right at the beginning of bfd_recv_cb. So let's use this pointer and
don't perform additional interface lookups.

Also explain in more detail how we process VRF id with different
backends.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-10-14 18:55:33 +03:00
Igor Ryzhov 03e3333b11 bfdd: fix bfd key structure
There's a padding byte between "mhop" and "peer" fields in this structure.
This structure is sometimes passed by value to functions and used in
assignments. The standard doesn't guarantee that the padding bytes are
copied on assignments. As this structure is used as a hash key, having
this padding byte with unspecified value can lead to unwanted behavior.

Fix the possible issue by making the "mhop" field to be 2 bytes. Also
make the struct packed as a precaution for future changes.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
2021-06-02 20:58:35 +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
Donatas Abraitis 37916b2b11
Merge pull request #8121 from opensourcerouting/macro-cleanup
*: require ISO C11 + semicolons after file-scope macros
2021-03-22 11:00:34 +02:00
David Lamparter bf8d3d6aca *: require semicolon after DEFINE_MTYPE & co
Back when I put this together in 2015, ISO C11 was still reasonably new
and we couldn't require it just yet.  Without ISO C11, there is no
"good" way (only bad hacks) to require a semicolon after a macro that
ends with a function definition.  And if you added one anyway, you'd get
"spurious semicolon" warnings on some compilers...

With C11, `_Static_assert()` at the end of a macro will make it so that
the semicolon is properly required, consumed, and not warned about.

Consistently requiring semicolons after "file-level" macros matches
Linux kernel coding style and helps some editors against mis-syntax'ing
these macros.

Signed-off-by: David Lamparter <equinox@diac24.net>
2021-03-17 06:18:17 +01: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
Rafael Zalamena 6655b43d51 bfdd: support connecting to BFD data plane
Add option to connect to a data plane server instead of receiving
connections.

Signed-off-by: Rafael Zalamena <rzalamena@opensourcerouting.org>
2020-11-24 07:55:07 -03:00
Rafael Zalamena 400632a9a2 bfdd: distributed BFD show commands
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>
2020-11-24 07:54:07 -03:00
Rafael Zalamena efd04d60ca bfdd: integrate distributed BFD
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>
2020-11-24 07:54:07 -03:00
Rafael Zalamena 230aefe258 bfdd: import distributed BFD implementation
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>
2020-11-24 07:54:07 -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
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 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