Skip to content

Commit b5b7c9f

Browse files
committed
feat(routing): removed unused code
Signed-off-by: Fredi Raspall <[email protected]>
1 parent 3dac134 commit b5b7c9f

File tree

2 files changed

+12
-32
lines changed

2 files changed

+12
-32
lines changed

routing/src/display.rs

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,20 @@
22
// Copyright Open Network Fabric Authors
33

44
//! Module that implements Display for routing objects
5-
5+
//!
6+
//! Note: most of the objects for which Display is implemented here belong to
7+
//! the routing database which is fully and only owned by the routing thread.
8+
//! This includes the Fib contents since fibs belong to vrfs.
9+
//! So:
10+
/// - it is Okay to call any of this from the routing thread (cli)
11+
/// - other threads may not be able to call Display's for routing objects.
12+
/// - Display for Fib objects visible from dataplane workers can be safely called.
13+
/// - Cli thread does not need a read handle cache to inspect Fib contents
14+
/// - Still, FIXME(fredi): make that distinction clearer
615
use crate::atable::adjacency::{Adjacency, AdjacencyTable};
716
use crate::cpi::{CpiStats, CpiStatus, StatsRow};
817
use crate::fib::fibgroupstore::FibRoute;
918
use crate::fib::fibobjects::{EgressObject, FibEntry, FibGroup, PktInstruction};
10-
use crate::fib::fibtable::FibTable;
1119
use crate::fib::fibtype::{Fib, FibKey};
1220
use crate::frr::frrmi::{FrrAppliedConfig, Frrmi, FrrmiStats};
1321

@@ -723,22 +731,6 @@ impl Display for Fib {
723731
Ok(())
724732
}
725733
}
726-
impl Display for FibTable {
727-
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
728-
Heading(format!(
729-
" Fib Table ({} fibs, version: {})",
730-
self.len(),
731-
self.version()
732-
))
733-
.fmt(f)?;
734-
for fibr in self.values().map(|f| f.handle()) {
735-
if let Some(fib) = fibr.enter() {
736-
write!(f, "{}", *fib)?;
737-
}
738-
}
739-
Ok(())
740-
}
741-
}
742734

743735
pub struct FibViewV4<'a, F>
744736
where

routing/src/fib/fibtable.rs

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,12 @@ impl FibTable {
7878
self.get_entry(key).map(|entry| entry.factory.handle())
7979
}
8080

81+
/// Number of entries in this table
8182
#[must_use]
83+
#[cfg(test)]
8284
pub(crate) fn len(&self) -> usize {
8385
self.entries.len()
8486
}
85-
/// Tell if fib table is empty
86-
#[must_use]
87-
#[allow(unused)]
88-
pub(crate) fn is_empty(&self) -> bool {
89-
self.entries.is_empty()
90-
}
91-
/// Provide an iterator of [`FibReaderFactory`]s
92-
pub(crate) fn values(&self) -> impl Iterator<Item = &FibReaderFactory> {
93-
self.entries.values().map(|e| &e.factory)
94-
}
95-
/// Tell version of this [`FibTable`]
96-
pub(crate) fn version(&self) -> u64 {
97-
self.version
98-
}
9987
}
10088

10189
enum FibTableChange {

0 commit comments

Comments
 (0)