BFD Component
Overview
BFD (Bidirectional Forwarding Detection) provides sub-second failure detection for routing protocols. BFD sessions are created by protocols (BGP, OSPF, static routes) rather than configured directly. When a BFD session detects that a neighbor is unreachable, the associated protocol is notified immediately, enabling faster convergence than relying on protocol-level hello timers alone.
flockd sends and receives the BFD packets itself: RFC 5880 asynchronous
mode over RFC 5881 single hop, on IPv4 and IPv6, link-local included.
Echo, demand mode, authentication and multihop are not supported. A
firewall must pass UDP to port 3784, sent from source ports 49152 to
65535.
Configuration
BFD sessions are not configured independently. Instead, BFD is enabled per-protocol.
Each bfd object takes the same two parameters, both optional:
multiplier: how many packets in a row may be lost before the session goes down, from 1 to 255. Default 3.min_tx: the shortest interval between transmitted packets, in milliseconds, from 50 to 4294967. Default 1000.
A configuration file with a value outside these ranges is refused. As
both are optional, "bfd": {} enables BFD with the defaults.
The detection time is multiplier × min_tx. For example, with a multiplier of 3 and a min_tx of 1000 (1 second), failure is detected within 3 seconds.
BFD for OSPFv2 / OSPFv3 interfaces
Enable BFD on an OSPF interface by adding a bfd object with multiplier and min_tx parameters.
"ospfv2": {
"vrfs": {
"default": {
"router_id": "10.0.100.1",
"areas": {
"0.0.0.0": {
"intfs": {
"^eth": {
"bfd": {
"multiplier": 3,
"min_tx": 1000
}
}
}
}
}
}
}
}
The same configuration applies to OSPFv3 interfaces under the ospfv3 object.
BFD for BGP neighbors
Enable BFD on a BGP neighbor by adding a bfd object with multiplier and min_tx parameters.
"bgp": {
"asn": 65016,
"id": "172.16.10.1",
"vrfs": {
"default": {
"neighs": {
"172.16.20.2 172.16.20.1": {
"asn": 65016,
"bfd": {
"multiplier": 3,
"min_tx": 1000
},
"afis": {
"ipv4-unicast": {}
}
}
}
}
}
}
BFD for static routes
Enable BFD on a static route by adding a bfd object to the route.
"static": {
"vrfs": {
"default": {
"routes": {
"192.0.2.128/25": {
"next_hops": [
{ "ip_addr": "10.0.1.2", "intf_name": "r1-n1" }
],
"bfd": {
"multiplier": 3,
"min_tx": 1000
}
}
}
}
}
}
Shared sessions
BFD runs one session to a neighbor on an interface. Protocols asking for it share it, at the fastest settings any of them asks for.
Within static routing, the routes that reach one next hop make a single request, with the settings of the first of them: a later route asking for different settings is logged, and the request keeps the first route's. A route alone on its next hop has its settings changed in place.
Source address
A session runs from a source address the protocol picks: an address on its interface, or for an unnumbered OSPFv2 interface the router's lowest IPv4 address, which another interface holds.
When the system deletes that address, static routing moves the session to the interface's next address, and an unnumbered OSPFv2 interface's neighbors to the address their Hellos now use. A numbered OSPF interface that loses its address goes down with its neighbors, and BGP restarts a neighbor whose source goes. With no address left to move to, static routing and OSPF keep the source, and the session runs again once an address is added, moving to it if it is a new one.
Operational State
BFD overview
flockc bfd overview
The overview shows where sessions run, which in flockd is Software;
how many sessions are in each status, and how many have yet to report
one; and unknown_session: how many state reports named no session.
Interface receive drops
flockc bfd intfs
flockc bfd intfs --vrf <vrf-name>
Each interface and address family that has received BFD, until the interface is deleted, with the VRF the interface is in and the packets dropped there before they reached a session: a TTL other than 255, a malformed packet, a packet for no session, or one the system could not deliver whole, as it was too long or came without its TTL or source.
Show all BFD sessions
flockc bfd sessions
Each session names its interface and the VRF the interface is in, and lists the protocols sharing it, each with the source and settings it asks for. A protocol asking for a transmit interval under the floor is shown as refused: the session runs without it, and it hears the session as Down.
Each session also shows how it runs: waiting, with the reason (its interface, its source address, or a socket); open, with its source port, what the peer last sent and the timers it runs at; or lingering, sending AdminDown after its last protocol has gone. It counts the packets it sent and took, those it sent late, and those it dropped because they carried authentication. A late packet went further after the last than the transmit interval allows, which eats into the peer's detection time; a packet after one that failed to send counts as late too.
Walk the sessions a chunk at a time
flockc bfd sessions --max-entries <n>
flockc bfd sessions --max-entries <n> --start-from-dst <ip-address> \
--start-from-vrf <vrf-name> --start-from-intf <interface-name>
Sessions come ordered by VRF name, then interface name, then the peer's
address, with finished set on the chunk holding the last of them. To
carry on, start from the last session a chunk returned: its peer, VRF and
interface. A VRF or interface the system has not reported has no name,
comes after every named one, and is left out of the start.
Sessions in one VRF
flockc bfd sessions --vrf <vrf-name>
One session
flockc bfd session --vrf <vrf-name> --intf <interface-name> <ip-address>
--vrf defaults to default.