summaryrefslogtreecommitdiff
path: root/internal/ior_bpfsetup.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-05-13 09:51:41 +0300
committerPaul Buetow <paul@buetow.org>2026-05-13 09:51:41 +0300
commit66956756ba018ed32a455aa57f04517af2c7357f (patch)
tree6dc86c8f3f77c684c711775a62346648a1ab5ada /internal/ior_bpfsetup.go
parent6c7a5d5fb3e88068799fb414e316b6bec31015e9 (diff)
fix: surface rb.Poll errors instead of silently dropping them
The libbpfgo RingBuffer.Poll() previously launched a background goroutine that could fail with a fatal C-level errno (e.g. EBADF, EPERM) and silently exit, causing BPF events to stop flowing with no diagnostic. Changes: - Patch ../libbpfgo (replace directive) so RingBuffer.Poll() returns a buffered <-chan error that the background goroutine sends to on failure. - In setupEventChannel, capture the error channel and spawn a monitoring goroutine that logs any poll error to stderr. - Update go.mod with the replace directive and drop the now-unused remote checksum entries from go.sum. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'internal/ior_bpfsetup.go')
-rw-r--r--internal/ior_bpfsetup.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/internal/ior_bpfsetup.go b/internal/ior_bpfsetup.go
index 885d321..7575700 100644
--- a/internal/ior_bpfsetup.go
+++ b/internal/ior_bpfsetup.go
@@ -88,13 +88,23 @@ func setupBPFModule(parentCtx context.Context, cfg flags.Config) (*bpf.Module, *
}
// setupEventChannel initialises the BPF ring-buffer and returns the event channel.
+// It starts polling the ring buffer and logs any fatal poll error to stderr so
+// that a background ring-buffer failure does not go completely unnoticed.
func setupEventChannel(bpfModule *bpf.Module) (chan []byte, error) {
ch := make(chan []byte, appconfig.DefaultChannelBufferSize)
rb, err := bpfModule.InitRingBuf("event_map", ch)
if err != nil {
return nil, err
}
- rb.Poll(300)
+ // Poll returns a channel that receives any fatal error from the background
+ // polling goroutine. Monitor it in a goroutine so the error is logged and
+ // does not silently drop events.
+ pollErrCh := rb.Poll(300)
+ go func() {
+ if err := <-pollErrCh; err != nil {
+ fmt.Fprintf(os.Stderr, "ior: ring buffer poll failed: %v\n", err)
+ }
+ }()
return ch, nil
}