Add fixed-size, process-lifetime counters (received/enqueued/dropped/
drained/dequeued/decoded/decode-errors/reader-errors/canceled) for the
process and DNS eBPF event paths, exposed as individually-atomic
snapshots. Wire DNSEventCounters and ProcessEventCounters through the
perf reader/enqueue/decode loop in daemon/dns and daemon/procmon/ebpf,
with a matching ebpf_prog/event_stats.h and a structural eBPF test.
Counters hold totals only, never event payloads.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Some kernels or systems may not have tracefs mounted or available
by default.
We need the path /sys/kernel/tracing to be mounted, in order to add
syscalls ebpf probes.
So from now on we'll try to mount /sys/kernel/tracing if it's not
already mounted.
-check-requirements parameter updated to check if this option is
available.
Closes#1450.
Up until now we've been using https://github.com/iovisor/gobpf/ for
intercepting events from the kernel, and it has worked very well.
Unfortunately it's deprecated since 2021 (iovisor/gobpf#304), which means
that some of the known issues and limitations won't be fixed.
After evaluating some options, I've migrated the code from gobpf to
github.com/cilium/ebpf.
More info: #1222, #1312
Now it's possible to configure eBPF modules path from the
default-config.json file:
"Ebpf": {
"ModulesPath": "..."
}
If the option is not provided, or if it's empty, we'll keep loading from
the default directories:
- /usr/local/lib/opensnitchd/ebpf
- /usr/lib/opensnitchd/ebpf
- /etc/opensnitchd/ebpf (deprecated, will be removed in the future).
Closes#928
As we've added eBPF interception method, we need go iovisor ebpf package,
which is not packaged for Debian yet, so the way I was compiling it
differs a little bit (instead of using gbp buildpackage,
dpkg-buildpackage is used).
Aside from that, there'll be a new eBPF module (.o ELF), which must be
packaged with the packages. Will be compiled on the fly, but maybe it
could be hosted in the repo, because it won't change that much.
- Delete lists of domains if the rule about to change is of type Lists.
- Monitor the lists of domains, and reload them if they're modified.
- Delete rules from disk when the Duration changes from
Always (saved on disk) to !Always (temporary).
- After the above operation a fsnotify Remove event is fired. Don't
delete the rule from memory if it's temporary.
- Rules are only compiled if they're enabled, avoiding unnecessary
allocations.