Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

RIB Component

The RIB component receives routes from each routing protocol and stores them in the RIB. For each network prefix the 'best' route is sent to the dataplane for use when forwarding packets. By default, flock uses the Linux kernel as dataplane, but it can be configured to use other dataplanes.

Operational State

Stats

flock@r70:~$ flockc rib vrf default stats
{"v4":{"total_route_count":12,"active_route_count":12,"protocol_stats":[{"origin":"Connected","counters":{"total_route_count":4,"active_route_count":4},"vpn_counters":null,"evpn_counters":null}, ...]},"v6":{"total_route_count":3, ...}}

Longest Prefix Match (LPM) for destination

The matching prefix is returned alongside its entry.

  • fib_ip_nhs are the resolved next hops taken from the 'best' protocol

      flock@r70:~$ flockc rib vrf default lpm 70.0.70.1
      ["70.0.70.0/24",{"protos":[{"admin_dist":0,"origin":"Connected", ...,"ip_nhs":[{"ConnectedNh":{...}}],"last_modified":"2026-08-03T09:14:22.481Z"}],"fib_ip_nhs":[{"ConnectedNh":{"vrf":{"vrf_id":254,"vrf_name":"default"},"intf":{"intf_id":125675,"intf_name":"r70-n70"}, ...}}], ...}]
    

Each entry in protos carries last_modified, when that protocol's route to the prefix last changed.

Each next hop names its VRF in vrf, and its interface in intf where it has one, as the id with the name beside it.

Single RIB prefix entry

flock@r70:~$ flockc -f json-pretty rib vrf default lookup 70.0.0.0/8
{
  "protos": [
    {
      "admin_dist": 1,
      "origin": {
        "Static": "Conf"
      },
      ...
      "ip_nhs": [
        {
          "SpecialNh": {
            "vrf": {
              "vrf_id": 254,
              "vrf_name": "default"
            },
            "special_nh_type": "discard",
            ...
          }
        }
      ],
      ...
    }
  ],
  "fib_ip_nhs": [
    {
      "SpecialNh": {
        ...
        "special_nh_type": "discard",
        ...
      }
    }
  ],
  ...
}

All prefix entries in the RIB

Walk starts at <root> and returns all prefixes within. Use 0.0.0.0/0 or ::/0 for the full IPv4 / IPv6 table. Each entry is the one lookup returns.

    flock@r70:~$ flockc rib vrf default walk 0.0.0.0/0
    {"entries":[{"prefix":"50.0.0.0/8","entry":{"protos":[{"admin_dist":20,"origin":"Bgp", ...,"ip_nhs":[{"RecursiveNh":{ ...,"ip_addr":"90.0.93.61", ...}}], ...}],"fib_ip_nhs":[{"AttachedNh":{ ...,"ip_addr":"90.0.93.61", ...}}], ...}},{"prefix":"70.0.0.0/8","entry":{"protos":[{"admin_dist":1,"origin":{"Static":"Conf"}, ...}], ...}},{"prefix":"70.0.70.0/24","entry":{"protos":[{"admin_dist":0,"origin":"Connected", ...}], ...}}, ...],
     "finished":true}

Entries come in prefix order. A large table can be walked a chunk at a time: --max-entries N returns at most N entries, and --start-from <prefix> resumes after the prefix a previous chunk ended on. finished is true when no entries follow the last one returned, including when the chunk is exactly full. A walk that finds no entries -- nothing under the root, or a resume at or past the last entry -- returns none with finished set.

    flock@r70:~$ flockc rib vrf default walk 0.0.0.0/0 --max-entries 100 --start-from 70.0.0.0/8

--origin <origin> returns only the entries holding a route from that origin, each whole, so an entry may show routes from other origins too. --max-entries then counts the entries returned. The origins are ospfv2, ospfv3, static, bgp, connected and isis; static is every static route, whether configured, reported by the system or asked for by the local host.

    flock@r70:~$ flockc rib vrf default walk 0.0.0.0/0 --origin bgp

Connected routes

A route from another origin whose prefix falls inside a connected prefix is not installed: the RIB holds it against that connected route. The connected subcommand shows each connected prefix with the routes held under it, as staged_paths. The walk takes a root, as the RIB walk does (use 0.0.0.0/0 or ::/0 for every IPv4 / IPv6 connected prefix), and pages the same way with --max-entries and --start-from:

flockc rib vrf <vrf-name> connected lookup <ip-network>
flockc rib vrf <vrf-name> connected walk <root> [--start-from <prefix>] [--max-entries <N>]

flock@r70:~$ flockc rib vrf default connected walk 0.0.0.0/0 --max-entries 1
{"entries":[{"connected":"70.0.70.0/24","staged_paths":{}}],"finished":false}

RIB Operation

Help

flockc rib --help

RIB stats

flockc rib vrf <vrf-name> stats

RIB prefix lookup

flockc rib vrf <vrf-name> lookup <ip-network>

RIB walk

flockc rib vrf <vrf-name> walk <root> [--start-from <prefix>] [--max-entries <N>] [--origin <origin>]

Longest Prefix Match (LPM)

flockc rib vrf <vrf-name> lpm <ip-address>

Connected route lookup / walk

flockc rib vrf <vrf-name> connected lookup <ip-network>
flockc rib vrf <vrf-name> connected walk <root> [--start-from <prefix>] [--max-entries <N>]

Label RIB (LRIB)

The Label RIB manages MPLS label bindings programmed by protocols such as BGP and OSPF Segment Routing.

LRIB stats

flockc lrib stats

LRIB label lookup

flockc lrib lookup <label>

LRIB walk

flockc lrib walk [--start-from <label>] [--max-entries <N>]

Entries come in label order. A large table can be walked a chunk at a time: --max-entries N returns at most N entries, and --start-from <label> resumes after the label a previous chunk ended on. finished is true when no entries follow the last one returned, including when the chunk is exactly full.

Multicast RIB (mRIB)

The multicast RIB holds the (S,G) entries flockd programs into the multicast forwarding plane, written by PIM. It is documented in the Multicast RIB Component chapter.