From 7b8710cfc72cc6cff510ee8b548db029e24a254a Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Tue, 20 Jun 2023 18:40:04 -0300 Subject: [PATCH] ospf: fix benchmarking code compilation The benchmarking code broke due to the new cryptographic authentication additions. This commit fixes the problem. In the future, the CI should be updated to catch such issues and ensure the benchmark code always compiles (and detect performance regressions as well!). Signed-off-by: Renato Westphal --- holo-ospf/benches/packet_decoding.rs | 5 ++++- holo-ospf/benches/packet_encoding.rs | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/holo-ospf/benches/packet_decoding.rs b/holo-ospf/benches/packet_decoding.rs index 8fad8e24..0ab16366 100644 --- a/holo-ospf/benches/packet_decoding.rs +++ b/holo-ospf/benches/packet_decoding.rs @@ -3,6 +3,7 @@ use std::hint::black_box; use std::sync::LazyLock as Lazy; +use bytes::Bytes; use criterion::{criterion_group, criterion_main, Criterion}; use holo_ospf::packet::*; use holo_ospf::version::Ospfv2; @@ -25,7 +26,9 @@ static BYTES: Lazy> = Lazy::new(|| { fn packet_decode(n: u64) { for _ in 0..n { - let _ = Packet::::decode(AddressFamily::Ipv4, &BYTES).unwrap(); + let mut buf = Bytes::copy_from_slice(&BYTES); + let _ = Packet::::decode(AddressFamily::Ipv4, &mut buf, None) + .unwrap(); } } diff --git a/holo-ospf/benches/packet_encoding.rs b/holo-ospf/benches/packet_encoding.rs index 14feb25e..9e1ee2d9 100644 --- a/holo-ospf/benches/packet_encoding.rs +++ b/holo-ospf/benches/packet_encoding.rs @@ -18,6 +18,7 @@ static PACKET: Lazy> = Lazy::new(|| { pkt_type: PacketType::LsUpdate, router_id: Ipv4Addr::from_str("2.2.2.2").unwrap(), area_id: Ipv4Addr::from_str("0.0.0.1").unwrap(), + auth_seqno: None, }, lsas: vec![ Lsa::new( @@ -64,7 +65,7 @@ static PACKET: Lazy> = Lazy::new(|| { fn packet_encode(n: u64) { for _ in 0..n { - PACKET.encode(); + PACKET.encode(None); } }