From cf73e5aa79cc6f6e147a5df55bad52f30706a5c3 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 13 Feb 2024 11:50:48 +0200 Subject: can pass UID via map from userland to BPF part --- internal/ioriotng.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'internal') diff --git a/internal/ioriotng.go b/internal/ioriotng.go index ca2a02e..b34a5cf 100644 --- a/internal/ioriotng.go +++ b/internal/ioriotng.go @@ -10,6 +10,7 @@ import ( "log" "runtime" "sync" + "unsafe" "ioriotng/internal/debugfs" "ioriotng/internal/tracepoints" @@ -69,6 +70,22 @@ 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() { // To consider for implementation! log.Println(debugfs.TracepointsWithFd()) @@ -91,6 +108,10 @@ func Run() { log.Fatal(err) } + if err := config(bpfModule); err != nil { + log.Fatal(err) + } + if err := tracepoints.AttachSyscalls(bpfModule); err != nil { log.Fatal(err) } -- cgit v1.2.3