Repository navigation
fix: load eBPF counters again, count with TC only and skip lo - #172
Merged
Merged
Conversation
Since v0.4.0 no eBPF program loaded anywhere: the EbpfLogger returned by aya_log::EbpfLogger::init_with_logger was dropped right away, which closed the AYA_LOGS ring buffer that every program references, so each BPF_PROG_LOAD failed with EBADF. The attach results were discarded with `.is_ok()`, so every interface reported `none` and the operator silently fell back to /proc/net/dev. - drop aya-log from the eBPF program and userspace: the only error path was a lookup of index 0 in a 1-entry array, and each loaded object paid a 128 KiB ring buffer for it - count ingress with a TC classifier instead of XDP: an XDP program on a veth clears TSO on its peer (`tx-tcp-segmentation: off [fixed]`) and on lo it ran as generic XDP on every loopback packet - skip lo by default (`--exclude-interface`, repeatable) - report attach errors; if both directions fail, emit InterfaceBpfInitializationFailed - detach on SIGTERM/SIGINT instead of dying with programs left attached (netlink TC filters outlive the process on kernels without tcx) - count egress with skb->len instead of the linear head only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Since v0.4.0 (2026-07-03) snoopy loads no eBPF program at all.
aya_log::EbpfLogger::init_with_loggerreturns the logger that owns theAYA_LOGSring buffer; snoopy dropped it right away, which closed the map fd that every program references. EveryBPF_PROG_LOADthen fails withEBADF(seen withstraceon kernel 6.8). The attach results were discarded via.is_ok(), so every interface reportedingress_implementation: none/egress_implementation: noneand the operator silently fell back to/proc/net/dev.Checked with the release binaries in an isolated netns: v0.3.12 attaches, v0.4.0, v0.4.37 and v0.4.38 do not.
Simply keeping the logger alive would bring back what v0.3.12 did: XDP on the pod's veth, which clears TSO on its peer (
tx-tcp-segmentation: off [fixed], verified), and generic XDP onlo. That costs the workloads, not snoopy. So this PR fixes the load and the attach strategy together.Changes
lo:--exclude-interface(repeatable), defaults tolo. The operator never reported loopback traffic.InterfaceBpfInitializationFailedis emitted so the operator sees it.ctx.len()(skb->len) instead ofdata_end - data, which only covered the linear head of GSO packets.Verification (homeserver, kernel 6.8, isolated netns)
lo, no XDP, peer keepstx-tcp-segmentation: onshutting down, detaching 1 ebpf module(s), no programs leftcargo fmt --check,cargo clippy --release,cargo testcleanThe operator side (one snoopy per pod, SIGTERM, eBPF-attached tracking) is in mogenius/mogenius-operator branch
perf/node-metrics-snoopy-per-pod; it works with both the old and the new snoopy.🤖 Generated with Claude Code