Rib

Struct Rib 

Source
pub struct Rib { /* private fields */ }
Expand description

The Routing Information Base.

Sits between routing protocols / static config and the FIB. Each route is stored with an origin value that identifies who installed it, and an optional expiration time. When routes change the caller invokes apply_to_fib to push the computed best nexthops into the FIB.

§RIB-to-FIB computation

For each name prefix the RIB collapses all registered routes to a single FibEntry by selecting, per unique face_id, the route with the lowest cost (ties broken by lowest origin value). The resulting nexthop set is atomically written to the FIB via Fib::set_nexthops.

§Multiple concurrent protocols

Each protocol uses a distinct origin value. All their routes coexist in the RIB; the FIB sees only the best computed result. Stopping a protocol with flush_origin removes its routes and recomputes the FIB for affected prefixes, revealing routes from other protocols that may have been shadowed.

§Note on discovery-managed routes

Discovery protocols (link-local neighbor discovery) write directly to the FIB via EngineDiscoveryContext. Those routes are not tracked in the RIB. For a given prefix, the RIB and discovery subsystem should not both manage the same face — in practice they target disjoint prefix ranges (/ndn/local/… for discovery, global prefixes for routing protocols).

Implementations§

Source§

impl Rib

Source

pub fn new() -> Self

Source

pub fn add(&self, prefix: &Name, route: RibRoute) -> bool

Register or update a route.

Routes are keyed by (face_id, origin). If a route with the same key already exists, it is replaced. Returns true if the FIB should be recomputed for this prefix (i.e. something actually changed).

Source

pub fn remove(&self, prefix: &Name, face_id: FaceId, origin: u64) -> bool

Remove a specific (face_id, origin) route from a prefix.

Returns true if the route was found and removed.

Source

pub fn remove_nexthop(&self, prefix: &Name, face_id: FaceId) -> bool

Remove all routes for (prefix, face_id) regardless of origin.

Returns true if any routes were removed.

Source

pub fn flush_origin(&self, origin: u64) -> Vec<Name>

Remove all routes registered by origin.

Returns the list of affected prefixes. Callers should call apply_to_fib for each returned prefix to update the FIB.

Source

pub fn flush_face(&self, face_id: FaceId) -> Vec<Name>

Remove all routes via face_id.

Returns the list of affected prefixes. Callers should call apply_to_fib for each returned prefix to update the FIB.

Source

pub fn drain_expired(&self) -> Vec<Name>

Drain all expired entries.

Returns the list of affected prefixes. Callers should call apply_to_fib for each returned prefix to update the FIB.

Source

pub fn apply_to_fib(&self, prefix: &Name, fib: &Fib)

Compute the best nexthops for prefix and apply them to the FIB.

For each unique face_id, selects the route with the lowest cost (ties broken by lowest origin value). Atomically replaces the FIB entry with the computed nexthops, or removes the entry if no routes remain.

Source

pub fn handle_face_down(&self, face_id: FaceId, fib: &Fib)

Handle a face going down: flush all RIB routes via that face and recompute affected FIB entries.

Call this alongside Fib::remove_face for a complete face teardown. The two operations are complementary: Fib::remove_face cleans up discovery-managed routes that are not tracked in the RIB; this method cleans up routing-protocol-managed routes.

Source

pub fn dump(&self) -> Vec<(Name, Vec<RibRoute>)>

Dump all RIB entries for management display.

Trait Implementations§

Source§

impl Default for Rib

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Rib

§

impl !RefUnwindSafe for Rib

§

impl Send for Rib

§

impl Sync for Rib

§

impl Unpin for Rib

§

impl UnwindSafe for Rib

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more