-
Notifications
You must be signed in to change notification settings - Fork 2
bgp rib
Pre-Alpha. This page describes behavior that may change.
The main BGP RIB store and best-path selection engine.
Storage.
Load the plugin and bind it to peers.
plugin {
external rib { use bgp-rib; encoder json; }
}
bgp {
peer upstream {
connection { remote { ip 10.0.0.1; } }
session { asn { remote 65001; } }
process rib { receive [ update state ]; send [ update ]; }
}
}
receive [ update state ] lets the RIB see routes arriving and peer state changes. send [ update ] lets it send routes back out after best-path selection (when acting as a router) or forwarding (when paired with bgp-rs).
bgp-rib stores routes per prefix per family and runs RFC 4271 section 9.1.2 best-path selection when multiple paths exist for a prefix. N-way multipath is supported: when bgp/multipath is configured with maximum-paths and relax-as-path, multiple equal-cost paths are selected and installed. The output is fed to sysrib (unified Loc-RIB) for cross-protocol admin-distance selection and then to fib-kernel and/or fib-vpp for forwarding table installation. The best-path order is LOCAL_PREF, AS_PATH length, ORIGIN, MED (same neighbour AS only), eBGP over iBGP, IGP cost (not implemented), lowest router-id, lowest peer address.
The RIB uses a two-level ribInPool keyed by ProtocolID, enabling multi-source support. BGP peers and BMP-monitored peers store routes under separate ProtocolIDs, so best-path selection only iterates real BGP routes while BMP routes are visible through the looking glass without additional filtering.
Internally, the RIB uses BART (Binary Adaptive Radix Tree) storage with per-family NLRI split registry. Non-CIDR families (EVPN, FlowSpec, etc.) get an opaque-map backend. bestPathRecord is packed into uint64 with a shared cross-family interner for memory efficiency. The Loc-RIB shards by prefix hash and the peer-keyed map lock is split from the main RIB mutex to keep it off the hot path.
The plugin also handles the RIB half of Graceful Restart: holding stale routes during a peer restart, clearing them on EOR, and purging any that did not come back.
The plugin replays stored routes when a peer reconnects. A batch of fixes landed recently (three bugs in the sent-event path: dispatch routing by Direction instead of EventType, missing WireUpdate on sent events, and a format mismatch for text-codec routes). The sync is now event-driven rather than timer-driven, and the graceful-restart, LLGR, and refresh-on-reconnect test scenarios all pass reliably.
Registered via ConfigureMetrics. Includes both route counts and attribute-pool statistics.
| Metric | Type | Meaning |
|---|---|---|
ze_rib_routes_in_total |
gauge | Total Adj-RIB-In route count across all peers. |
ze_rib_routes_out_total |
gauge | Total Adj-RIB-Out route count across all peers. |
ze_rib_routes_in{peer} |
gauge | Adj-RIB-In route count per peer. |
ze_rib_routes_out{peer} |
gauge | Adj-RIB-Out route count per peer. |
ze_rib_route_inserts_total{peer,family} |
counter | Routes inserted into Adj-RIB-In. |
ze_rib_route_withdrawals_total{peer,family} |
counter | Routes withdrawn from Adj-RIB-In. |
ze_attr_pool_intern_total{pool} |
gauge | Total Intern() calls per attribute pool. |
ze_attr_pool_dedup_hits_total{pool} |
gauge |
Intern() dedup hits per pool. |
ze_attr_pool_slots_used{pool} |
gauge | Active slots per pool. |
See plugin metrics.
-
bgp-grdepends onbgp-ribfor the stale route handling. -
bgp-persistsnapshots the RIB to disk. -
bgp-adj-rib-infeeds raw received updates into the RIB. -
sysribconsumes best-path change events from the RIB.
main/internal/component/bgp/plugins/rib/
Unreviewed draft. This wiki was authored in bulk and has not been reviewed. File corrections on the issue tracker.
- Overview
- YANG Model
- Editor Workflow
- Archive and Rollback
- System
- Interfaces
- VRRP
- BFD
- FIB
- OSPF
- IS-IS
- MPLS / LDP / RSVP-TE
- RSVP-TE
- SRv6
- Static Routes
- Policy Routing
- Firewall
- Traffic Control
- Class of Service
- L2TP/PPP
- PPPoE
- VPP Data Plane
- RPKI
- IPsec VPN
- TACACS+ AAA
- RADIUS AAA
- AS112 DNS
- Authorization
- Fleet
- BGP
- Starting and Stopping
- Show Commands
- Monitoring
- Flow Export
- DDoS Mitigation
- Anomaly Detection
- Health Checks
- Audit Trail
- Production Diagnostics
- Logging
- Operational Reports
- Healthcheck
- Self-Update
- Zero-Touch Provisioning
- MRT Analysis
- Upgrade and Restart
- Storage
- Policy
- Core
- Resilience
- Validation
- Capabilities
- Address Families
- Protocol
- Subsystems
- Infrastructure
- Route Server at an IXP
- Transit Edge with RPKI
- Public Looking Glass
- ExaBGP Migration Walkthrough
- FlowSpec Injection
- Chaos-Tested Peering
- AS Path Topology