From dade2a79ee609ae09470a1f93f7035338cbb53da Mon Sep 17 00:00:00 2001 From: Andrew Fitzgerald Date: Wed, 11 Dec 2024 17:38:27 -0600 Subject: [PATCH] remove Sigverifier::process_excess_packet --- core/benches/sigverify_stage.rs | 4 ++-- core/src/sigverify_stage.rs | 17 +++-------------- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/core/benches/sigverify_stage.rs b/core/benches/sigverify_stage.rs index 6e5121dd1c62b6..30220b0aa1d113 100644 --- a/core/benches/sigverify_stage.rs +++ b/core/benches/sigverify_stage.rs @@ -57,7 +57,7 @@ fn run_bench_packet_discard(num_ips: usize, bencher: &mut Bencher) { info!("total packets: {}", total); bencher.iter(move || { - SigVerifyStage::discard_excess_packets(&mut batches, 10_000, |_| ()); + SigVerifyStage::discard_excess_packets(&mut batches, 10_000); let mut num_packets = 0; for batch in batches.iter_mut() { for p in batch.iter_mut() { @@ -104,7 +104,7 @@ fn bench_packet_discard_mixed_senders(bencher: &mut Bencher) { } } bencher.iter(move || { - SigVerifyStage::discard_excess_packets(&mut batches, 10_000, |_| ()); + SigVerifyStage::discard_excess_packets(&mut batches, 10_000); let mut num_packets = 0; for batch in batches.iter_mut() { for packet in batch.iter_mut() { diff --git a/core/src/sigverify_stage.rs b/core/src/sigverify_stage.rs index ab1bd3015f4f3a..a8a73a84648847 100644 --- a/core/src/sigverify_stage.rs +++ b/core/src/sigverify_stage.rs @@ -57,7 +57,6 @@ pub struct SigVerifyStage { pub trait SigVerifier { type SendType: std::fmt::Debug; fn verify_batches(&self, batches: Vec, valid_packets: usize) -> Vec; - fn process_excess_packet(&mut self, _packet: &Packet) {} fn process_passed_sigverify_packet(&mut self, _packet: &Packet) {} fn send_packets(&mut self, packet_batches: Vec) -> Result<(), Self::SendType>; } @@ -244,11 +243,7 @@ impl SigVerifyStage { Self { thread_hdl } } - pub fn discard_excess_packets( - batches: &mut [PacketBatch], - mut max_packets: usize, - mut process_excess_packet: impl FnMut(&Packet), - ) { + pub fn discard_excess_packets(batches: &mut [PacketBatch], mut max_packets: usize) { // Group packets by their incoming IP address. let mut addrs = batches .iter_mut() @@ -269,7 +264,6 @@ impl SigVerifyStage { } // Discard excess packets from each address. for packet in addrs.into_values().flatten() { - process_excess_packet(packet); packet.meta_mut().set_discard(true); } } @@ -323,12 +317,7 @@ impl SigVerifyStage { let mut discard_time = Measure::start("sigverify_discard_time"); let mut num_packets_to_verify = num_unique; if num_unique > MAX_SIGVERIFY_BATCH { - Self::discard_excess_packets( - &mut batches, - MAX_SIGVERIFY_BATCH, - #[inline(always)] - |excess_packet| verifier.process_excess_packet(excess_packet), - ); + Self::discard_excess_packets(&mut batches, MAX_SIGVERIFY_BATCH); num_packets_to_verify = MAX_SIGVERIFY_BATCH; } let excess_fail = num_unique.saturating_sub(MAX_SIGVERIFY_BATCH); @@ -477,7 +466,7 @@ mod tests { batch[4].meta_mut().addr = std::net::IpAddr::from([2u16; 8]); let mut batches = vec![batch]; let max = 3; - SigVerifyStage::discard_excess_packets(&mut batches, max, |_| {}); + SigVerifyStage::discard_excess_packets(&mut batches, max); let total_non_discard = count_non_discard(&batches); assert_eq!(total_non_discard, max); assert!(!batches[0][0].meta().discard());