summaryrefslogtreecommitdiff
path: root/internal/ioriotng.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-02-13 11:50:48 +0200
committerPaul Buetow <paul@buetow.org>2024-02-13 11:50:48 +0200
commitcf73e5aa79cc6f6e147a5df55bad52f30706a5c3 (patch)
treef6a808171f18bfb7f022629dc51d6d8f669b1885 /internal/ioriotng.go
parent6c6e3ea33241042e8a1efc04cee3bfb3559dd210 (diff)
can pass UID via map from userland to BPF part
Diffstat (limited to 'internal/ioriotng.go')
-rw-r--r--internal/ioriotng.go21
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)
}