Skip to content

feat(ids/bypass): kernel packet-depth elephant cap (Route A bytes-OR-packets)#393

Open
pigri wants to merge 2 commits into
mainfrom
feat/ids-elephant-packets-threshold
Open

feat(ids/bypass): kernel packet-depth elephant cap (Route A bytes-OR-packets)#393
pigri wants to merge 2 commits into
mainfrom
feat/ids-elephant-packets-threshold

Conversation

@pigri

@pigri pigri commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Summary

Route A (kernel byte-depth IDS auto-bypass) previously capped a flow only on cumulative bytes (ids.bypass.depth_bytes). This adds a companion packet cap so a flow stops being exported to the IDS once it crosses depth_bytes OR depth_packets, using the shared flow_is_elephant() primitive instead of open-coding the comparison.

Changes

  • bpf/lib/ids_export.h#include "flow/elephant.h"; ids_flow_bypass_check() takes depth_packets and decides via flow_is_elephant(packets, bytes, depth_packets, depth_bytes); unknown flows are tracked when either dimension is set.
  • bpf/xdp_maps.hstruct ids_export_config gains bypass_depth_packets.
  • synapse-core/cli.rsIdsBypassConfig.depth_packets, #[serde(default)], default 0 (disabled) → behaviour unchanged unless configured; byte-depth stays the default cap.
  • synapse-idp/thalamus_ids.rs — push the 16-byte config incl bypass_depth_packets; debug-log it. (Config read path is length-defensive, so the size bump is backward-compatible.)

Dependency

Uses flow/elephant.h from dendrite (gen0sec/dendrite#88). It's on the BPF include path already (same dir as the ja4/ headers xdp.bpf.c includes). This merges after a dendrite version that ships the header.

Verification

  • xdp.bpf.c compiles to object under clang -target bpf with the header on the include path.
  • Additive + default-0; no behaviour change unless ids.bypass.depth_packets is set. Full workspace build / clippy / kernel-verifier load to run in CI.

pigri added 2 commits June 18, 2026 10:05
…packets)

Route A previously bypassed an IDS flow only on cumulative bytes (depth_bytes).
Add a companion packet cap so a flow is bypassed once it crosses depth_bytes OR
depth_packets, sharing the dendrite flow_is_elephant() primitive instead of
open-coding the comparison:

- ids_export.h: include flow/elephant.h; ids_flow_bypass_check takes depth_packets
  and decides via flow_is_elephant(packets, bytes, depth_packets, depth_bytes);
  track unknown flows when either dimension is set.
- xdp_maps.h: ids_export_config gains bypass_depth_packets.
- cli.rs: IdsBypassConfig.depth_packets (default 0 = disabled; behaviour unchanged
  unless configured).
- thalamus_ids.rs: push the 16-byte config incl bypass_depth_packets; log it.

Requires dendrite providing flow/elephant.h (already on the BPF include path via
the ja4/ headers). Default 0 keeps byte-depth as the sole cap unless set.
bpf_stats read index 3 (IDS_EXPORT_STAT_BYPASSED) of ids_export_stats and add
ids_bypassed to BpfAccessStats + the summary line, so the bypass feature's
suppression count is observable (exported/ringbuf_dropped/invalid/bypassed).
Previously the kernel counted bypassed packets but userspace never surfaced it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant