Skip to content

Commit

Permalink
Preserve aggregate logs
Browse files Browse the repository at this point in the history
  • Loading branch information
helius-kurt committed May 23, 2024
1 parent 2087522 commit 9d0d1d8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion validator-firewall/src/ip_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use rangemap::RangeInclusiveSet;
use solana_rpc_client::nonblocking::rpc_client::RpcClient;
use std::collections::HashSet;
use std::net::SocketAddr;
use std::ops::{RangeInclusive};
use std::ops::RangeInclusive;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
Expand Down
2 changes: 1 addition & 1 deletion validator-firewall/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ fn push_ports_to_map(bpf: &mut Bpf, ports: Vec<u16>) -> Result<(), anyhow::Error

#[cfg(test)]
mod tests {

use cidr::Ipv4Cidr;
use std::str::FromStr;

Expand Down
15 changes: 11 additions & 4 deletions validator-firewall/src/stats_service.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use aya::maps::{Map, MapData, MapIter, PerCpuHashMap, PerCpuValues};
use log::{info, debug};
use log::info;
use std::net::Ipv4Addr;
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
Expand Down Expand Up @@ -37,7 +37,6 @@ impl StatsService {
per_cpu.iter().sum(),
)
})
.take(100)
.collect();
pairs.sort_by(|a, b| b.1.cmp(&a.1));
pairs
Expand All @@ -58,9 +57,13 @@ impl StatsService {
while !co_exit.load(Ordering::Relaxed) {
// Get stats from the maps
let mut all_sum = 0u64;
let mut log_limit = 100;
for (addr, total) in Self::prepare_stats(all_traffic.iter()) {
all_sum += total;
info!("total_packets: {:?} = {:?}", addr, total);
if log_limit > 0 {
info!("total_packets: {:?} = {:?}", addr, total);
log_limit -= 1;
}
}
info!(
"All traffic summary: {} pkts last_interval {} pkts {} pkts/s",
Expand All @@ -72,9 +75,13 @@ impl StatsService {
all_las_eval_time = std::time::Instant::now();

let mut blocked_sum = 0u64;
let mut log_limit = 100;
for (addr, total) in Self::prepare_stats(blocked_traffic.iter()) {
blocked_sum += total;
info!("dropped_packets: {:?} = {:?}", addr, total);
if log_limit > 0 {
info!("dropped_packets: {:?} = {:?}", addr, total);
log_limit -= 1;
}
}
info!(
"Blocked traffic summary: {} pkts last_interval {} pkts {} pkts/s",
Expand Down

0 comments on commit 9d0d1d8

Please sign in to comment.