diff options
| author | Paul Buetow <paul@buetow.org> | 2024-02-13 11:50:48 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2024-02-13 11:50:48 +0200 |
| commit | cf73e5aa79cc6f6e147a5df55bad52f30706a5c3 (patch) | |
| tree | f6a808171f18bfb7f022629dc51d6d8f669b1885 /internal/ioriotng.go | |
| parent | 6c6e3ea33241042e8a1efc04cee3bfb3559dd210 (diff) | |
can pass UID via map from userland to BPF part
Diffstat (limited to 'internal/ioriotng.go')
| -rw-r--r-- | internal/ioriotng.go | 21 |
1 files changed, 21 insertions, 0 deletions
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) } |
