Repository navigation
Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
RD normalization can merge distinct VRFs, and several documentation and copy-on-write coverage issues remain.
Review effort: Balanced
Findings: 1
Open (4)
What changed in this PR
Adds the in-memory BGP RIB data model, including attribute interning, peer indexing, route structures, copy-on-write snapshots, and documentation.
Changes:
- Introduces RIB types, tables, routes, and peer resolution.
- Adds attribute interning with explicit garbage collection.
- Registers and documents the new workspace crate.
| File | Description |
|---|---|
Cargo.toml |
Registers the RIB crate and prefix-trie dependency. |
Cargo.lock |
Locks new crate dependencies. |
crates/rib/Cargo.toml |
Defines crate metadata and dependencies. |
crates/rib/LICENSE |
Adds the Apache 2.0 license. |
crates/rib/README.md |
Summarizes crate scope. |
crates/rib/src/lib.rs |
Exposes the public API. |
crates/rib/src/attrs.rs |
Implements attribute interning and GC. |
crates/rib/src/model.rs |
Defines RIB storage and route models. |
crates/rib/src/peers.rs |
Implements peer identity and indexing. |
crates/rib/src/types.rs |
Defines table, context, and labeled-route types. |
docs/rib_structure.md |
Documents hierarchy and copy-on-write behavior. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
rodonile
marked this pull request as ready for review
September 29, 2026 07:51
rodonile
enabled auto-merge (rebase)
September 29, 2026 07:52
This was referenced Sep 29, 2026
rodonile
force-pushed
the
rib-model
branch
2 times, most recently
from
October 1, 2026 14:00
e948988 to
8987444
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.
mxyns
reviewed
Oct 5, 2026
| /// 2. Any path marked as PRIMARY (useful for ECMP) | ||
| /// 3. Fallback to lowest Path-ID | ||
| pub fn active_path(&self) -> Option<&Route<E>> { | ||
| use netcalyx_bmp_pkt::v4::PathStatus; |
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.



Adds
crates/rib(netcalyx-rib): the core in-memory BGP RIB data model.The collector needs an in-memory RIB to enrich flow records via
longest-prefix-match against BGP attributes. The design (per-router
snapshots, Arc-per-trie copy-on-write) was benchmarked and validated
separately before porting here; this PR lands only the data model.
Lookups, ingestion, and collector wiring will follow as separate PRs.
Changelog
netcalyx-rib, workspace member, sync onlytypes:TableId,RibContext,AfiSafiType,LabeledRouteExtra,Srv6RouteExtra.attrs:RouteAttributes,AttrStore(sub-component + whole-attributeinterning with explicit gc).
model:RibStore,RouterRib,AfiSafiTable/AfiSafiRib/PeerRibs(
loc-rib+ 4 adj-rib views),Route/MultiRoute,RibViewCounts.Arc sits at up to four levels so a write clones only the touched trie.
peers:PeerIndex(address → candidate peer(s), self-healing onsession flap) and
peer_identity()(normalizes RD the same wayRibContextdoes, so inconsistent RD reporting can't split one peer'sadj-rib in two).
docs/rib_structure.md: hierarchy diagram and copy-on-write walkthrough.Testing
cargo test -p netcalyx-rib: 32 unit tests, including a dedicatedcopy-on-write correctness test (
Arcsharing before a write, privatecopy after) and RD-normalization/AFI-SAFI-mapping coverage.