Skip to content

Commit 028f8b1

Browse files
[review] Update based on review feedback + dump_m2p addition
This aligns us with the current updates on master, addresses reviewer feedback, and adds dump_m2p ioctl (which is needed in Omicron, as I've been working on that code).
1 parent 7d8a232 commit 028f8b1

15 files changed

Lines changed: 332 additions & 247 deletions

File tree

.cargo/config.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
[alias]
22
xtask = "run --package xtask --"
33
ubench = "bench --package opte-bench --bench userland --profile release-lto --"
4-
mbench = "bench --package opte-bench --bench multicast --profile release-lto --"
54
kbench = "bench --package opte-bench --bench xde --"
65

76
[env]

.github/buildomat/jobs/bench.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ pfexec add_drv xde
114114
banner "bench"
115115
cargo kbench local
116116
cargo ubench
117-
cargo mbench
118117

119118
cp -r target/criterion $OUT_DIR
120119
cp -r target/xde-bench $OUT_DIR

bench/Cargo.toml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,3 @@ harness = false
4242
name = "xde"
4343
harness = false
4444

45-
[[bench]]
46-
name = "multicast"
47-
harness = false

bench/benches/multicast.rs

Lines changed: 0 additions & 134 deletions
This file was deleted.

bench/benches/userland.rs

Lines changed: 111 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
99
use criterion::BenchmarkId;
1010
use criterion::Criterion;
11+
use criterion::Throughput;
1112
use criterion::criterion_group;
1213
use criterion::criterion_main;
1314
use opte::engine::packet::Packet;
@@ -24,6 +25,11 @@ use opte_bench::packet::TestCase;
2425
use opte_bench::packet::ULP_FAST_PATH;
2526
use opte_bench::packet::ULP_SLOW_PATH;
2627
use opte_test_utils::*;
28+
use oxide_vpc::api::IpAddr;
29+
use oxide_vpc::api::Ipv4Addr;
30+
use oxide_vpc::api::Ipv6Addr;
31+
use oxide_vpc::api::SourceFilter;
32+
use std::collections::BTreeSet;
2733
use std::hint::black_box;
2834

2935
// Top level runner. Specifies packet classes.
@@ -218,7 +224,111 @@ pub fn test_handle<M: MeasurementInfo + 'static>(
218224
);
219225
}
220226

221-
criterion_group!(wall, parse_and_process);
227+
/// Generate a source IP address for filter testing (10.0.0.x).
228+
fn make_src_v4(i: u32) -> IpAddr {
229+
IpAddr::Ip4(Ipv4Addr::from(0x0a000000u32 + i))
230+
}
231+
232+
/// Generate a source IP address for filter testing (fd00::x).
233+
fn make_src_v6(i: u32) -> IpAddr {
234+
let mut bytes = [0u8; 16];
235+
bytes[0..4].copy_from_slice(&[0xfd, 0x00, 0x00, 0x00]);
236+
bytes[12..16].copy_from_slice(&i.to_be_bytes());
237+
IpAddr::Ip6(Ipv6Addr::from(bytes))
238+
}
239+
240+
/// Benchmark [`SourceFilter::allows`] for various filter configurations.
241+
fn source_filter_allows(c: &mut Criterion) {
242+
let mut group = c.benchmark_group("source_filter/allows");
243+
group.throughput(Throughput::Elements(1));
244+
245+
let src_v4 = make_src_v4(100); // Not in any source list
246+
let src_v6 = make_src_v6(100);
247+
248+
// Fast path: EXCLUDE() with empty sources (*, G)
249+
let filter_any = SourceFilter::default();
250+
group.bench_function("exclude_empty_v4", |b| {
251+
b.iter(|| black_box(filter_any.allows(black_box(src_v4))))
252+
});
253+
group.bench_function("exclude_empty_v6", |b| {
254+
b.iter(|| black_box(filter_any.allows(black_box(src_v6))))
255+
});
256+
257+
// EXCLUDE with sources: "Miss" case where source is not in exclusion list
258+
for size in [1, 5, 10, 50, 100] {
259+
let sources_v4: BTreeSet<_> = (0..size).map(make_src_v4).collect();
260+
let filter_v4 = SourceFilter::Exclude(sources_v4);
261+
group.bench_with_input(
262+
BenchmarkId::new("exclude_miss_v4", size),
263+
&filter_v4,
264+
|b, f| b.iter(|| black_box(f.allows(black_box(src_v4)))),
265+
);
266+
let src_in_list_v4 = make_src_v4(0);
267+
group.bench_with_input(
268+
BenchmarkId::new("exclude_hit_v4", size),
269+
&filter_v4,
270+
|b, f| b.iter(|| black_box(f.allows(black_box(src_in_list_v4)))),
271+
);
272+
273+
let sources_v6: BTreeSet<_> = (0..size).map(make_src_v6).collect();
274+
let filter_v6 = SourceFilter::Exclude(sources_v6);
275+
group.bench_with_input(
276+
BenchmarkId::new("exclude_miss_v6", size),
277+
&filter_v6,
278+
|b, f| b.iter(|| black_box(f.allows(black_box(src_v6)))),
279+
);
280+
let src_in_list_v6 = make_src_v6(0);
281+
group.bench_with_input(
282+
BenchmarkId::new("exclude_hit_v6", size),
283+
&filter_v6,
284+
|b, f| b.iter(|| black_box(f.allows(black_box(src_in_list_v6)))),
285+
);
286+
}
287+
288+
// INCLUDE with sources: "Hit" case where source is in inclusion list
289+
for size in [1, 5, 10, 50, 100] {
290+
let sources_v4: BTreeSet<_> = (0..size).map(make_src_v4).collect();
291+
let filter_v4 = SourceFilter::Include(sources_v4);
292+
let src_in_list_v4 = make_src_v4(0);
293+
group.bench_with_input(
294+
BenchmarkId::new("include_hit_v4", size),
295+
&filter_v4,
296+
|b, f| b.iter(|| black_box(f.allows(black_box(src_in_list_v4)))),
297+
);
298+
group.bench_with_input(
299+
BenchmarkId::new("include_miss_v4", size),
300+
&filter_v4,
301+
|b, f| b.iter(|| black_box(f.allows(black_box(src_v4)))),
302+
);
303+
304+
let sources_v6: BTreeSet<_> = (0..size).map(make_src_v6).collect();
305+
let filter_v6 = SourceFilter::Include(sources_v6);
306+
let src_in_list_v6 = make_src_v6(0);
307+
group.bench_with_input(
308+
BenchmarkId::new("include_hit_v6", size),
309+
&filter_v6,
310+
|b, f| b.iter(|| black_box(f.allows(black_box(src_in_list_v6)))),
311+
);
312+
group.bench_with_input(
313+
BenchmarkId::new("include_miss_v6", size),
314+
&filter_v6,
315+
|b, f| b.iter(|| black_box(f.allows(black_box(src_v6)))),
316+
);
317+
}
318+
319+
// INCLUDE() empty, rejecting all
320+
let filter_none = SourceFilter::Include(BTreeSet::new());
321+
group.bench_function("include_empty_v4", |b| {
322+
b.iter(|| black_box(filter_none.allows(black_box(src_v4))))
323+
});
324+
group.bench_function("include_empty_v6", |b| {
325+
b.iter(|| black_box(filter_none.allows(black_box(src_v6))))
326+
});
327+
328+
group.finish();
329+
}
330+
331+
criterion_group!(wall, parse_and_process, source_filter_allows);
222332
criterion_group!(
223333
name = alloc;
224334
config = new_crit(Allocs);

bin/opteadm/src/bin/opteadm.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ use oxide_vpc::api::SetVirt2PhysReq;
6868
use oxide_vpc::api::SourceFilter;
6969
use oxide_vpc::api::TunnelEndpoint;
7070
use oxide_vpc::api::VpcCfg;
71+
use oxide_vpc::print::print_m2p;
7172
use oxide_vpc::print::print_mcast_fwd;
7273
use oxide_vpc::print::print_mcast_subs;
7374
use oxide_vpc::print::print_v2b;
@@ -310,6 +311,9 @@ enum Command {
310311
/// Dump multicast subscriptions (group -> ports on this sled)
311312
DumpMcastSubs,
312313

314+
/// Dump M2P (multicast group -> underlay multicast) mappings
315+
DumpM2p,
316+
313317
/// Subscribe a port to a multicast group
314318
///
315319
/// Allows a port to receive multicast traffic for the specified group.
@@ -986,6 +990,10 @@ fn main() -> anyhow::Result<()> {
986990
print_mcast_subs(&hdl.dump_mcast_subs()?)?;
987991
}
988992

993+
Command::DumpM2p => {
994+
print_m2p(&hdl.dump_m2p()?)?;
995+
}
996+
989997
Command::McastSubscribe { port, group } => {
990998
let req = McastSubscribeReq {
991999
port_name: port,

crates/opte-api/src/cmd.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ pub enum OpteCmd {
114114
DumpMcastSubscriptions = 107,
115115
/// Unsubscribe all ports from a multicast group.
116116
McastUnsubscribeAll = 108,
117+
/// Read out all M2P (multicast group -> underlay multicast) mappings.
118+
DumpMcast2Phys = 109,
117119
}
118120

119121
impl TryFrom<c_int> for OpteCmd {
@@ -155,6 +157,7 @@ impl TryFrom<c_int> for OpteCmd {
155157
106 => Ok(Self::ClearMcast2Phys),
156158
107 => Ok(Self::DumpMcastSubscriptions),
157159
108 => Ok(Self::McastUnsubscribeAll),
160+
109 => Ok(Self::DumpMcast2Phys),
158161
_ => Err(()),
159162
}
160163
}

0 commit comments

Comments
 (0)