diff options
| -rw-r--r-- | go.mod | 2 | ||||
| -rw-r--r-- | go.sum | 2 | ||||
| -rw-r--r-- | internal/ior_bpfsetup.go | 12 |
3 files changed, 13 insertions, 3 deletions
@@ -39,3 +39,5 @@ require ( golang.org/x/sys v0.41.0 // indirect google.golang.org/protobuf v1.34.2 // indirect ) + +replace github.com/aquasecurity/libbpfgo => ../libbpfgo @@ -14,8 +14,6 @@ github.com/alecthomas/repr v0.4.0 h1:GhI2A8MACjfegCPVq9f1FLvIBS+DrQ2KQBFZP1iFzXc github.com/alecthomas/repr v0.4.0/go.mod h1:Fr0507jx4eOXV7AlPV6AVZLYrLIuIeSOWtW57eE/O/4= github.com/andybalholm/brotli v1.1.1 h1:PR2pgnyFznKEugtsUo0xLdDop5SKXd5Qf5ysW+7XdTA= github.com/andybalholm/brotli v1.1.1/go.mod h1:05ib4cKhjx3OQYUY22hTVd34Bc8upXjOLL2rKwwZBoA= -github.com/aquasecurity/libbpfgo v0.9.2-libbpf-1.5.1 h1:TDN+16Nim3gimjuTxd+sFhb4v06mEeYH0JfRWAFowA0= -github.com/aquasecurity/libbpfgo v0.9.2-libbpf-1.5.1/go.mod h1:JQNC5NuGwyYC7IZum6JqPNVHarFAuab+h4lO6t0jIhc= github.com/atotto/clipboard v0.1.4 h1:EH0zSVneZPSuFR11BlR9YppQTVDbh5+16AmcJi4g1z4= github.com/atotto/clipboard v0.1.4/go.mod h1:ZY9tmq7sm5xIbd9bOK4onWV4S6X0u6GY7Vn0Yu86PYI= github.com/aymanbagabas/go-udiff v0.4.0 h1:TKnLPh7IbnizJIBKFWa9mKayRUBQ9Kh1BPCk6w2PnYM= 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 } |
