From 6c1335b3538dabc82b4931d4bf13a36f86c4666e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 13 Feb 2024 19:11:52 +0200 Subject: can pass flags to BPF --- internal/ioriotng.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'internal') diff --git a/internal/ioriotng.go b/internal/ioriotng.go index b34a5cf..94c8030 100644 --- a/internal/ioriotng.go +++ b/internal/ioriotng.go @@ -10,9 +10,9 @@ import ( "log" "runtime" "sync" - "unsafe" "ioriotng/internal/debugfs" + "ioriotng/internal/flags" "ioriotng/internal/tracepoints" bpf "github.com/aquasecurity/libbpfgo" @@ -70,23 +70,7 @@ func resizeMap(module *bpf.Module, name string, size uint32) error { return nil } -func config(bpfModule *bpf.Module) error { - configMap, err := bpfModule.GetMap("config_map") - if err != nil { - return err - } - - config := struct { - UidFilter int32 - }{ - UidFilter: 1001, // TODO: Make configurable via flag, - } - - key := uint32(1) - return configMap.Update(unsafe.Pointer(&key), unsafe.Pointer(&config)) -} - -func Run() { +func Run(flags flags.Flags) { // To consider for implementation! log.Println(debugfs.TracepointsWithFd()) @@ -108,7 +92,7 @@ func Run() { log.Fatal(err) } - if err := config(bpfModule); err != nil { + if err := flags.SetBPF(bpfModule); err != nil { log.Fatal(err) } -- cgit v1.2.3