fix(xdp): verifier padding, synchronous detach, percpu stats; add netns stress harness
Found by running the netns smoke on a real 5.15 KVM node: - throttle_entry implicit padding rejected by the verifier (clang 14) - XDP program left attached after the edge exited - rampart_xdp_* gauges always zero (percpu_array read with lookup) - RUST_LOG could not raise rampart above info Smoke now keeps the origin inside the netns and polls for ban expiry.
This commit is contained in:
parent
987ccec905
commit
d68b45e2b8
11 changed files with 268 additions and 27 deletions
|
|
@ -71,9 +71,12 @@ impl XdpFilter {
|
|||
let map = self.find_map("stats_map")?;
|
||||
let sum = |idx: u32| -> u64 {
|
||||
let key = idx.to_le_bytes();
|
||||
match map.lookup(&key, MapFlags::ANY) {
|
||||
Ok(Some(v)) => v
|
||||
.chunks_exact(8)
|
||||
// `stats_map` is a percpu_array: plain `lookup` does not support it and
|
||||
// the failure would silently read as zero, so sum the per-CPU slots.
|
||||
match map.lookup_percpu(&key, MapFlags::ANY) {
|
||||
Ok(Some(slots)) => slots
|
||||
.iter()
|
||||
.flat_map(|slot| slot.chunks_exact(8))
|
||||
.map(|c| u64::from_le_bytes(c.try_into().expect("chunk size 8")))
|
||||
.sum(),
|
||||
_ => 0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue