BFD

Bidirectional Forwarding Detection (BFD) detects failures of the forwarding path between two systems within milliseconds. Routing protocols use BFD to detect a failed neighbor much faster than with their own hello and hold timers, which is required for fast convergence and failover.

The BNG Blaster implements BFD in asynchronous mode as defined in RFC 5880 for single-hop sessions (RFC 5881, UDP port 3784) and multi-hop sessions (RFC 5883, UDP port 4784) over IPv4 and IPv6. BFD sessions are either configured statically or created by the routing protocols ISIS, OSPFv2, OSPFv3, BGP and LDP. This allows testing of the BFD implementation of the device under test (DUT) and of its failover behavior, triggered by disabling BFD sessions or changing timers via control commands.

The echo function and demand mode are not supported.

Configuration

BFD timers and authentication are defined in BFD profiles, which are referenced by static sessions and routing protocols. The following example shows a static single-hop session with 100 ms intervals and a multi-hop session with the default profile (1000 ms intervals, multiplier 3).

{
    "interfaces": {
        "network": [
            {
                "interface": "eth1",
                "address": "10.0.1.2/24",
                "gateway": "10.0.1.1"
            }
        ]
    },
    "bfd": [
        {
            "bfd-profile-id": 1,
            "tx-interval": 100,
            "rx-interval": 100,
            "multiplier": 3
        }
    ],
    "bfd-sessions": [
        {
            "network-interface": "eth1",
            "peer-ipv4-address": "10.0.1.1",
            "bfd-profile-id": 1,
            "name": "DUT"
        },
        {
            "network-interface": "eth1",
            "local-ipv4-address": "10.0.1.2",
            "peer-ipv4-address": "10.10.10.1",
            "multihop": true
        }
    ]
}

BFD Profile

{ "bfd": [] }

BFD profiles define the timers and authentication of BFD sessions. Static BFD sessions and routing protocols refer to a profile by its bfd-profile-id. Sessions without profile use the defaults.

Attribute

Description

bfd-profile-id

Mandatory BFD profile identifier.
Range: 1 - 65535

tx-interval

Desired min TX interval in milliseconds.
The TX interval is at least one second while the session
is not up (slow start).
Default: 1000 Range: 1 - 60000

rx-interval

Required min RX interval in milliseconds.
Default: 1000 Range: 1 - 60000

multiplier

Detect multiplier.
Default: 3 Range: 1 - 255

passive

Passive role, packets are sent only after a packet
from the peer is received.
Default: false

min-ttl

Minimum TTL or hop limit of received packets of
multi-hop sessions. Single-hop sessions always
require 255 (RFC 5881).
Default: 254 Range: 1 - 255

authentication-type

Authentication type (none, simple, keyed-md5,
meticulous-keyed-md5, keyed-sha1 or meticulous-keyed-sha1).
Default: none

authentication-key-id

Authentication key ID.
Default: 1 Range: 0 - 255

authentication-key

Authentication key (password), mandatory if
authentication is enabled.
Length: simple and MD5 1 - 16, SHA1 1 - 20 characters

BFD Session

{ "bfd-sessions": [] }

Static BFD sessions are started with BNG Blaster and kept until the end of the test, independent of routing protocols.

Attribute

Description

network-interface

Network interface of the session.
Mandatory for single-hop sessions.
Default: first network interface (multi-hop)

peer-ipv4-address

Peer IPv4 address.
Either peer-ipv4-address or peer-ipv6-address is mandatory.

local-ipv4-address

Local IPv4 address.
Default: network interface address

peer-ipv6-address

Peer IPv6 address (global or link-local).

local-ipv6-address

Local IPv6 address.
Default: network interface link-local address for
link-local peers, otherwise the global address

bfd-profile-id

BFD profile.
Default: built-in defaults (1000 ms, multiplier 3)

multihop

Multi-hop session (RFC 5883, UDP port 4784).
Default: false (single-hop, RFC 5881, UDP port 3784)

name

Optional session name shown in the session output.

Routing Protocols

BFD is enabled for a routing protocol by referencing a BFD profile. The BFD session is created when the adjacency or session of the protocol comes up and deleted when it goes down. If the BFD session goes from Up to Down, the protocol is brought down immediately. A BFD session going down because the peer signals AdminDown does not bring the protocol down (RFC 5882).

Protocol

Configuration

BFD Session

BFD Down

ISIS

isis-bfd-profile-id (network interface)

Adjacency up, single-hop

Adjacency down

OSPFv2

ospfv2-bfd-profile-id (network interface)

Neighbor 2-Way or higher, single-hop

Neighbor down

OSPFv3

ospfv3-bfd-profile-id (network interface)

Neighbor 2-Way or higher, single-hop

Neighbor down

BGP

bfd-profile-id, bfd-multihop (BGP session)

Established, single- or multi-hop

NOTIFICATION Cease with subcode BFD Down (RFC 9384)

LDP

ldp-bfd-profile-id (network interface)

Operational, single-hop

Session closed with Shutdown notification

LDP (targeted)

bfd-profile-id (targeted neighbor)

Operational, multi-hop

Session closed with Shutdown notification

The peer address of the BFD session is:

  • ISIS: one session per address family (RFC 6213) to the IPv4 interface address of the neighbor (hello TLV 132, if the network interface has an IPv4 address) and to the IPv6 link-local address of the neighbor (hello TLV 232). Implementations using only one address family for BFD (e.g. FRR uses IPv6 on dual-stack circuits) leave the other session down, which does not affect the adjacency. On broadcast circuits, the sessions are bound to each neighbor in state Up, and a BFD failure brings down only this neighbor.

  • OSPFv2: the interface address of the neighbor.

  • OSPFv3: the link-local address of the neighbor.

  • BGP: the peer address of the session. Without bfd-multihop, the session is single-hop if the peer address is in a connected network of the network interface (or an IPv6 link-local address), otherwise multi-hop.

  • LDP: the source address of the hello which initialized the LDP session (link hellos) or the targeted neighbor address (targeted hellos, multi-hop).

Multiple protocols may share one BFD session to the same peer, for example OSPFv2 and ISIS or ISIS level 1 and level 2. A shared session uses the profile of the protocol which created it, and all protocols are brought down if it goes down. A static session to the same peer is shared as well.

The sessions follow address changes of OSPF and ISIS neighbors. Single-hop sessions of OSPF and ISIS are sent to the MAC address of the neighbor, all other single-hop sessions (static, BGP, LDP) to the gateway MAC address of the network interface until the first packet of the peer is received.

{
    "interfaces": {
        "network": [
            {
                "interface": "eth1",
                "address": "10.0.1.2/24",
                "gateway": "10.0.1.1",
                "isis-instance-id": 1,
                "isis-bfd-profile-id": 1,
                "ldp-instance-id": 1,
                "ldp-bfd-profile-id": 1
            }
        ]
    },
    "bfd": [
        {
            "bfd-profile-id": 1,
            "tx-interval": 50,
            "rx-interval": 50,
            "multiplier": 3
        }
    ],
    "isis": [
        {
            "instance-id": 1,
            "system-id": "1921.6800.1001"
        }
    ],
    "ldp": [
        {
            "instance-id": 1,
            "lsr-id": "10.10.10.11"
        }
    ],
    "bgp": [
        {
            "network-interface": "eth1",
            "local-ipv4-address": "10.0.1.2",
            "peer-ipv4-address": "10.0.1.1",
            "local-as": 65001,
            "peer-as": 65001,
            "bfd-profile-id": 1
        }
    ]
}

Behavior

  • Each session has a unique non-zero local discriminator. Received packets are demultiplexed by the your discriminator field, or by interface, source and destination address if it is zero (RFC 5880 Section 6.3).

  • All reception checks of RFC 5880 Section 6.8.6 are applied. Single-hop packets are accepted with TTL or hop limit 255 only, multi-hop packets with at least min-ttl (default 254). All packets are sent with TTL or hop limit 255 and a source port between 49152 and 65535, which is unique per session.

  • While a session is not Up, the desired min TX interval is at least one second. Changed timers of a session in state Up (e.g. after the session came up or via bfd-session-update) start a poll sequence. The new TX interval is used after the poll sequence terminated if it is longer, a shorter one immediately (RFC 5880 Section 6.8.3).

  • The TX interval is reduced by a random jitter of 0 to 25 % (10 to 25 % with multiplier 1), the detection time is the remote multiplier times the larger of the local required min RX interval and the remote desired min TX interval.

  • The local diagnostic is set to control detection time expired (1), neighbor signaled session down (3) or administratively down (7).

  • With authentication, the sequence number of keyed MD5 and SHA1 is incremented with every packet. Packets with an unexpected authentication type, key ID, key or a sequence number outside of the window of RFC 5880 Section 6.7 are dropped and counted as rx-auth-errors.

  • At the end of the test, all sessions are set to AdminDown, which is signaled to the peers before the routing protocols are torn down.

Interoperability notes:

  • BIRD sends multi-hop packets with TTL 64, which requires min-ttl 64 or lower. BIRD and FRR (when deleting dynamic sessions) do not signal AdminDown, so the BNG Blaster detects a timeout.

  • FRR requires local-address for single-hop sessions to IPv6 link-local peers, otherwise it sends from its global address, which does not match the session.

  • FRR ignores packets with your discriminator zero, which the BNG Blaster sends after a detection timeout (RFC 5880 Section 6.8.1), so FRR detects a timeout as well.

BFD runs in the main thread of the BNG Blaster with one TX and one detection timer per session. 1000 sessions with 100 ms intervals (10000 packets per second received and sent) are supported.

Commands

All sessions are listed by the command bfd-sessions, which accepts the filters bfd-session-id, network-interface, peer-address and state.

$ sudo bngblaster-cli run.sock bfd-sessions

{
    "status": "ok",
    "code": 200,
    "bfd-sessions": [
        {
            "bfd-session-id": 1,
            "name": "DUT",
            "network-interface": "eth1",
            "local-address": "10.0.1.2",
            "peer-address": "10.0.1.1",
            "multihop": false,
            "state": "Up",
            "remote-state": "Up",
            "local-diagnostic": "none",
            "local-discriminator": 1720564481,
            "remote-discriminator": 2214,
            "remote-diagnostic": "none",
            "authentication-type": "none",
            "multiplier": 3,
            "remote-multiplier": 3,
            "desired-min-tx-interval-us": 100000,
            "required-min-rx-interval-us": 100000,
            "remote-desired-min-tx-interval-us": 100000,
            "remote-required-min-rx-interval-us": 100000,
            "tx-interval-us": 100000,
            "detection-time-us": 300000,
            "state-seconds": 4,
            "min-ttl": 255,
            "passive": false,
            "poll": false,
            "admin-state": "enabled",
            "clients": [
                "static"
            ],
            "stats": {
                "tx-packets": 51,
                "tx-errors": 0,
                "rx-packets": 53,
                "rx-errors": 0,
                "rx-auth-errors": 0,
                "up": 1,
                "down": 0,
                "timeout": 0,
                "poll-sequences": 1
            }
        }
    ]
}

The commands bfd-session-disable and bfd-session-enable set all matching sessions administratively down (AdminDown) or enable them again, for example to verify the behavior of the DUT if a BFD peer signals AdminDown.

$ sudo bngblaster-cli run.sock bfd-session-disable bfd-session-id 1

The timers of matching sessions are changed at runtime with bfd-session-update, which starts a poll sequence for sessions in state Up.

$ sudo bngblaster-cli run.sock bfd-session-update tx-interval 50 rx-interval 50 multiplier 5

Command

Description

bfd-sessions

Display all matching BFD sessions.

Arguments:
bfd-session-id
network-interface
peer-address IPv4 or IPv6 address
state e.g. Up, Down, Init or AdminDown

bfd-session-disable

Set all matching BFD sessions administratively
down (AdminDown with diagnostic 7).

Arguments:
bfd-session-id
network-interface
peer-address
state

bfd-session-enable

Enable all matching BFD sessions again.

Arguments:
bfd-session-id
network-interface
peer-address
state

bfd-session-update

Change the timers of all matching BFD sessions,
which starts a poll sequence for sessions in state Up.

Arguments:
tx-interval in milliseconds
rx-interval in milliseconds
multiplier
bfd-session-id
network-interface
peer-address
state

The final JSON report contains the section bfd with the totals of all sessions and the session details (bfd-sessions), see Reports.