Repository navigation
Conversation
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.
model.rs and lookup.rs had grown long, mostly from test code (23 and 15 tests respectively). Move each `#[cfg(test)] mod tests` block out to a same-named-folder file (model/tests.rs, lookup/tests.rs), matching the pattern already used elsewhere in the repo (e.g. collector/src/flow/enrichment/actor.rs). No behavior change: `use super::*` becomes `use crate::<module>::*` per the established convention for this pattern, everything else is unmodified.
rodonile
force-pushed
the
rib-tests-refactor
branch
from
September 30, 2026 07:06
6a281be to
40205ed
Compare
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 #59.
Pure test-code relocation, no behavior change.
Reason
model.rsandlookup.rshad grown long, splitting tests intoa same-named-folder file keeps the source file focused on
the implementation while keeping tests colocated and easy to find.