Skip to content

Commit

Permalink
Remove part of the debug dump
Browse files Browse the repository at this point in the history
This info is now available as part of the admin API

Signed-off-by: Lee Smet <lee.smet@hotmail.com>
  • Loading branch information
LeeSmet committed Feb 27, 2024
1 parent 1254b1a commit d0d8723
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
35 changes: 0 additions & 35 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,44 +174,9 @@ impl Stack {
#[cfg(target_family = "unix")]
/// Dump internal state, temporary method.
pub fn dump(&self) {
println!("----------- Current selected routes -----------\n");
self._router.print_selected_routes();
println!("----------- Current fallback routes -----------\n");
self._router.print_fallback_routes();
println!("----------- Current source table -----------\n");
self._router.print_source_table();
println!("----------- Subnet origins -----------\n");
self._router.print_subnet_origins();

println!("\n----------- Current peers: -----------");
for p in self._router.peer_interfaces() {
println!(
"Peer: {}, with link cost: {} (Read: {} / Written: {})",
p.connection_identifier(),
p.link_cost(),
format_bytes(p.read()),
format_bytes(p.written()),
);
}

fn format_bytes(bytes: u64) -> String {
/// 1 Tebibyte
const TI_B: u64 = 1 << 40;
/// 1 Gibibyte
const GI_B: u64 = 1 << 30;
/// 1 Mebibyte
const MI_B: u64 = 1 << 20;
/// 1 Kibibyte
const KI_B: u64 = 1 << 10;
match bytes {
x if x > TI_B => format!("{}.{} TiB", x / TI_B, (x % TI_B) / (TI_B / 100)),
x if x > GI_B => format!("{}.{} GiB", x / GI_B, (x % GI_B) / (GI_B / 100)),
x if x > MI_B => format!("{}.{} MiB", x / MI_B, (x % MI_B) / (MI_B / 100)),
x if x > KI_B => format!("{}.{} KiB", x / KI_B, (x % KI_B) / (KI_B / 100)),
x => format!("{x} B"),
}
}

println!("\n\n");
}
}
35 changes: 0 additions & 35 deletions src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,23 +258,6 @@ impl Router {
&self.dead_peer_sink
}

pub fn print_selected_routes(&self) {
let inner = self
.inner_r
.enter()
.expect("Write handle is saved on router so it is not dropped before the read handles");

for (route_key, route_entry) in inner.routing_table.iter().filter(|(_, re)| re.selected()) {
println!(
"{} next-hop {} metric: {} (seqno {})",
route_key.subnet(),
route_entry.neighbour().connection_identifier(),
route_entry.metric(),
route_entry.seqno(),
);
}
}

/// Get a list of all selected route entries.
pub fn load_selected_routes(&self) -> Vec<RouteEntry> {
let inner = self
Expand All @@ -290,24 +273,6 @@ impl Router {
.collect()
}

pub fn print_fallback_routes(&self) {
let inner = self
.inner_r
.enter()
.expect("Write handle is saved on router so it is not dropped before the read handles");

for (route_key, route_entry) in inner.routing_table.iter().filter(|(_, re)| !re.selected())
{
println!(
"{} next-hop {} metric: {} (seqno {})",
route_key.subnet(),
route_entry.neighbour().connection_identifier(),
route_entry.metric(),
route_entry.seqno(),
);
}
}

/// Get a list of all fallback route entries.
pub fn load_fallback_routes(&self) -> Vec<RouteEntry> {
let inner = self
Expand Down

0 comments on commit d0d8723

Please sign in to comment.