rustbgpd
Cookbook

Controller / monitoring feed (BMP trio, events, MRT)

Export routing state to your monitoring stack.

Export routing state to your monitoring stack.

When this is you: Your controller, analytics pipeline, or NOC needs routing state. It needs to see what this daemon sees — pre-policy, post-policy, and Loc-RIB route streams into BMP collectors, a live event stream your controller follows after reading a snapshot, periodic MRT table archives, and a Grafana dashboard on top. rustbgpd exports the full BMP monitoring trio on one exporter (RFC 7854 Adj-RIB-In, RFC 8671 Adj-RIB-Out as byte-exact wire PDUs, RFC 9069 Loc-RIB), selectable per collector.

Proven by: M24 (BMP Initiation / PeerUp / RouteMonitoring ordering vs a BMP receiver) and M81 (the trio plus BMPv4, validated against three independent decoders at once: pmacct, gobmp, and tshark). Config shape derived from tests/interop/configs/rustbgpd-m81-bmp-rr.toml and examples/route-collector/.

Config

The example is an RR that also feeds the monitoring stack; the same [bmp] / [mrt] blocks bolt onto any of the other recipes unchanged.

[global]
asn = 65000
router_id = "10.255.0.1"
listen_port = 179
cluster_id = "10.255.0.1"
# RFC 8212 posture, stated explicitly. It governs eBGP sessions only, so
# these iBGP clients are unaffected; an eBGP neighbor added later needs
# explicit import and export policy.
ebgp_requires_policy = true

[global.telemetry]
prometheus_addr = "127.0.0.1:9179"
log_format = "json"

# Owner-only local socket (default mode 0600): clients are authorized as the
# implicit "local-operator" principal — no [security.grpc] block needed.
[global.telemetry.grpc_uds]
path = "/var/lib/rustbgpd/grpc.sock"

# Periodic MRT TABLE_DUMP_V2 snapshots — readable by bgpdump, BGPKIT,
# and the RouteViews/RIPE RIS toolchains.
[mrt]
output_dir = "/var/lib/rustbgpd/mrt"
dump_interval = 3600
compress = true
file_prefix = "feed"

[bmp]
sys_name = "rustbgpd-feed"
sys_descr = "fabric RR monitoring feed"

# Production collector: BMP v3 (the default), all three RIB views.
# On (re)connect the collector receives Initiation and the cached Peer Up
# state; the loc_rib view also gets a chunked Loc-RIB dump closed by
# End-of-RIB. rib_in_pre and rib_out_post have no reconnect dump and start
# at the next UPDATE. A configured collector can (re)connect at any time
# without a daemon restart; adding or changing a [[bmp.collectors]] entry is
# restart-required (see the reload matrix).
[[bmp.collectors]]
address = "10.20.0.10:1790"
reconnect_interval = 5
monitor = ["rib_in_pre", "rib_out_post", "loc_rib"]

# Optional second collector with BMPv4 TLV framing. Code points follow
# draft-ietf-grow-bmp-tlv-21 and remain pre-IANA. Path Marking is temporarily
# unavailable because its draft type 5 collides with Sequence Number. Keep
# production collectors on v3 (the default); point v4 only at tooling that
# tracks the draft (M81 validates the v4 bytes with a raw oracle and tshark).
#[[bmp.collectors]]
#address = "10.20.0.11:1790"
#reconnect_interval = 5
#version = 4
#monitor = ["rib_in_pre", "rib_out_post", "loc_rib"]

[[neighbors]]
address = "10.0.0.11"
remote_asn = 65000
description = "pe-1"
hold_time = 90
route_reflector_client = true
families = ["ipv4_unicast", "ipv6_unicast", "l3vpn_ipv4_unicast"]

[[neighbors]]
address = "10.0.1.2"
remote_asn = 65000
description = "pe-2"
hold_time = 90
route_reflector_client = true
families = ["ipv4_unicast", "ipv6_unicast", "l3vpn_ipv4_unicast"]

Passive iBGP relay

Use a passive relay when two routers feed a collector through rustbgpd and the relay must advertise nothing. The route-collector starter provides the same accept-all import and deny-all export posture for eBGP sources. This minimal IPv4 configuration uses two sources in the relay's own AS and sends only the pre-policy Adj-RIB-In BMP view:

[global]
asn = 65001
router_id = "10.255.0.1"
listen_port = 179
ebgp_requires_policy = true

[global.telemetry]
prometheus_addr = "127.0.0.1:9179"
log_format = "json"

[global.telemetry.grpc_uds]
path = "/var/lib/rustbgpd/grpc.sock"

[bmp]
sys_name = "rustbgpd-passive-relay"

[[bmp.collectors]]
address = "10.20.0.10:1790"
monitor = ["rib_in_pre"]

[policy]
import_chain = ["observe-all"]
export_chain = ["deny-all"]

[policy.definitions.observe-all]
default_action = "permit"

[policy.definitions.deny-all]
default_action = "deny"

[[neighbors]]
address = "10.0.0.2"
remote_asn = 65001
families = ["ipv4_unicast"]

[[neighbors]]
address = "10.0.1.2"
remote_asn = 65001
families = ["ipv4_unicast"]

Keep the deny-all export chain attached: an empty iBGP export chain permits routes. This configuration enables no forwarding backend; received routes remain available to the daemon's RIB queries and BMP feed.

At the collector, clear that peer's route state on PeerDown, as specified by RFC 7854 §4.9. Count that state teardown separately from explicit RouteMonitoring withdrawals. Connect the collector before feeding routes. After a BMP reconnect, cached PeerUp messages do not rebuild the received table: Adj-RIB-In has no automatic reconnect dump. See the BMP reconnect caveat.

The dated withdrawal parity receipt and its runnable lab prove one bounded shape: eight IPv4 /32s per peer, three announce/withdraw rounds and two flaps per peer, with 24 matching wire/BMP withdrawals per peer and zero exported announcements. This is not full-table memory, sustained-load, backpressure or reconnect-completeness evidence.

Verify

$ export RUSTBGPD_ADDR=unix:///var/lib/rustbgpd/grpc.sock
$ rbgp health
$ rbgp neighbor

BMP: on the collector you should see Initiation, the Peer Ups, the chunked Loc-RIB dump and its End-of-RIB (loc_rib only), then live RouteMonitoring deltas for every selected view. From the daemon side the collector connection state is visible in the logs (log_format = "json") and the BMP metrics below. Periodic peer Stats Reports also carry RFC 9972 post-policy accepted-route gauges, exact type-22 IPv4/IPv6-unicast policy reject counts, and exact per-path RPKI Invalid/Valid/NotFound types 35/36/37. The RPKI rows cover negotiated IPv4/IPv6-unicast families, count every Add-Path identity, and include authoritative zero rows; they are omitted when no VRP table is installed. Type 22 is present only while the default-on rejected-route store is authoritative: disabling retention or reaching its capacity omits the rows after the first eviction instead of publishing a partial count.

During a Loc-RIB bootstrap or dump, watch bmp_loc_rib_dump_live_buffer_depth{collector} for the current queued live rows and bmp_loc_rib_dump_live_buffer_high_watermark{collector} for the connection generation's peak. The collector value is the configured socket address including port. A high-water mark near the fixed 8192-row bound means the collector or dump path needs investigation before the next burst.

Events (watch, then snapshot): the event stream is live only. A controller opens the watch first and buffers it, then reads the state it needs, then applies the buffered events, skipping any the snapshot already reflects. After any reconnect it does the same again:

$ rbgp -j events watch --category route,session > events.ndjson &
$ rbgp -j neighbor

That shell pair is illustrative only: backgrounding the watch does not wait for the subscription to exist, rbgp events watch prints nothing when its stream is established, and the snapshot can finish first. A client that needs a gap-free handoff calls EventService.WatchEvents and waits for its response headers, which the daemon sends only after it has subscribed to every requested source, and only then requests state. No event is sent at stream start, so do not wait for a first message. The separate RPCs give no atomic handoff: reading state first and opening the watch afterwards loses any change in between, with no lag signal. gNMI Subscribe ON_CHANGE on neighbor session-state does the subscribe-before-snapshot step internally: every subscription starts with a fresh snapshot and sync_response, then streams changes. Neither replays the disconnected window. rustbgpd deliberately is not an event bus: the BMP feed above, Prometheus, and the JSON logs are the durable record.

MRT: force a dump and inspect it with your usual tooling:

$ rbgp mrt-dump
$ ls /var/lib/rustbgpd/mrt/
feed.20260703.120001.123456789.mrt.gz

Looking glass (optional): for status, peer, accepted-route, filtered-route, and noexport views in an Alice-LG-style frontend, run the examples/birdwatcher-adapter/ against the local Unix socket, or use its dedicated authenticated observer listener pattern for least privilege. (The in-daemon [global.telemetry.looking_glass] server has been removed.) The filtered view is served from PolicyService.ListRejectedRoutes with structured reject reasons; the noexport view diffs the Loc-RIB best set against the peer's Adj-RIB-Out and names each suppression's export gate via RibService.ExplainAdvertisedRoute — see the adapter README for exactly what each view contains.

Watch

Import the overview dashboard per the Grafana guide; the BMP and event-streaming row is populated once the features above are configured. Key series:

MetricMeaning
bgp_event_stream_lagged_total{service,source}events missed by a slow live subscriber; that consumer reopens its watch, then re-reads state
bmp_collector_drops_totalper-collector queue/dump failures; live fan-out Full/Closed automatically resets only that collector generation, replays cached Peer Up state, and rebuilds configured Loc-RIB state after the one-second reconnect
bmp_source_drops_totalper-peer BMP events dropped at the source tap, including a periodic stats report whose session-state query timed out
bmp_replay_attempts_totalPeerUp-cache replays on collector reconnect
bgp_rib_outbound_registered_peersfeed coverage: peers whose routes the views carry

Failure modes

The controller missed events during a burst. Live streams emit stream_lagged warnings when a bounded source dropped events for a slow consumer, and gNMI ON_CHANGE ends with DATA_LOSS. Either is the signal to reopen the watch and then re-read state (or resubscribe without updates_only) before trusting later deltas.

A BMP collector shows nothing after a network blip. The daemon redials with backoff capped by reconnect_interval and replays cached Peer Up state. It performs a fresh EoR-closed table dump only for collectors with monitor = ["loc_rib"]. Adj-RIB-In and Adj-RIB-Out have no automatic reconnect dump. For a late outbound collector, follow the outbound capture procedure. Its experimental replay-out operation reannounces the selected peer's routes on the live BGP session; successful scheduling alone does not prove a complete capture. See Known issues. Check the collector-side listener first, then the daemon log for connection and bootstrap failures.

pmacct rejects the v4 stream (BMPv4 BGP PDU TLV != 1). Known and expected: pmacct does not decode the draft BMPv4 TLV framing. Per the config comment above, point v4 only at tooling that tracks draft-ietf-grow-bmp-tlv. Move that collector to version = 3 (or drop the version key; 3 is the default).

Source on GitHub

On this page