Repository navigation
Conversation
rodonile
force-pushed
the
rib-lookup
branch
3 times, most recently
from
October 1, 2026 14:01
26fbc87 to
cb8c16d
Compare
Introduce crates/rib (netcalyx-rib): sync only, no tokio, no lookup or ingestion yet. - types: TableId/RibContext (per-VRF table addressing, RD-normalized the same way for every consumer), AfiSafiType (RFC 4760 AFI/SAFI identities), LabeledRouteExtra/Srv6RouteExtra (MPLS/SRv6 forwarding info carried per route). - attrs: RouteAttributes (flattened path attributes) and AttrStore, which interns both sub-components (AS-path, communities, cluster list, ...) and whole attribute sets, so a full table's worth of routes share Arc'd attribute sets instead of duplicating them per route. - model: RibStore -> RouterRib -> AfiSafiTable -> AfiSafiRib, the five RIB views per table (loc-rib plus the four adj-ribs) held per peer in PeerRibs, and Route/MultiRoute for per-prefix path storage (best-path selection, ECMP, path status). Arc-per-trie copy-on-write: a write after a snapshot publish clones only the one trie it touches, not the whole router. - peers: a flow's next-hop is an address, but BMP identifies a peer by a five-field tuple; PeerIndex resolves address -> peer within one RIB context in O(1) instead of scanning every peer in a table. peer_identity() normalizes RD the same way RibContext does, so inconsistent RD reporting can't split one peer's adj-rib in two. Lookup (LPM) and BMP ingestion are intentionally out of scope here, landing as separate follow-up PRs. Add docs/rib_structure.md: hierarchy sketch and copy-on-write lifecycle walkthrough for the new crate.
Add `lookup::lookup()`, resolving one address against `(RibContext, AfiSafiType[, RouteDistinguisher])` targets into the active path of the first RIB view with a hit, trying `loc-rib` then the four adj-ribs in precedence order (overridable via `LookupRequest::view_order`). Adj-rib reads resolve the flow's neighbor address to a peer through `PeerAddrIndex`; ambiguous or absent neighbors fall back to the lowest `(peer_address, bgp_id)` among matching peers, deterministically. Consolidate the `(post_policy, adj_rib_out) -> view` mapping, which previously existed independently in three places, into `RibView::from_peer_flags` plus `PeerRibs::view()`/`view_mut()` as the single source of truth; `adj_rib_view_mut` and `lookup` both delegate to it now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR depends on #57
Adds the read path on top of the
netcalyx-ribdata model landedin #57 : resolving an address to its best-matching route across a
router's RIB views.
Reason
Flow enrichment and other consumers need to resolve an address
(e.g. flow src/dst) into path attributes and forwarding info.
Changelog
lookup::lookup(): LPM lookup against one or moreLookupTargets (context + AFI-SAFI + optional RD), trying RIBviews in precedence order (
loc-ribfirst, then the fouradj-ribs,
DEFAULT_VIEW_ORDERor a caller-supplied order). Returnsa
Matchwith the active path's attributes/forwarding info, theview that answered, and the peer that answered (
Noneforloc-rib).
PeerIndexbefore reading an adj-rib view; fall back to the lowest
(peer_address, bgp_id)among matching peers when the neighbor isambiguous or absent.
lookup.rs; 50 tests pass overall for the crate.