From 04fa01992ad88ea8e9cd05e7cbb9f81087b23aff Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 16 Feb 2024 01:56:13 +0200 Subject: move some files to internal types --- Makefile | 2 +- internal/types/maps.bpf.h | 13 +++++++++++++ internal/types/types.bpf.h | 37 +++++++++++++++++++++++++++++++++++++ ioriotng.bpf.c | 6 +++--- maps.bpf.h | 13 ------------- types.bpf.h | 37 ------------------------------------- 6 files changed, 54 insertions(+), 54 deletions(-) create mode 100644 internal/types/maps.bpf.h create mode 100644 internal/types/types.bpf.h delete mode 100644 maps.bpf.h delete mode 100644 types.bpf.h diff --git a/Makefile b/Makefile index e243d65..116d967 100644 --- a/Makefile +++ b/Makefile @@ -11,7 +11,7 @@ build: bpfbuild gobuild .PHONY: bpfbuild bpfbuild: - bpftool btf dump file /sys/kernel/btf/vmlinux format c > vmlinux.h + bpftool btf dump file /sys/kernel/btf/vmlinux format c > ./internal/types/vmlinux.h $(CC) -g -O2 -Wall -fpie -target bpf -D__TARGET_ARCH_amd64 -I$(LIBBPFGO)/output -c ioriotng.bpf.c -o ioriotng.bpf.o .PHONY: gobuild diff --git a/internal/types/maps.bpf.h b/internal/types/maps.bpf.h new file mode 100644 index 0000000..dc55993 --- /dev/null +++ b/internal/types/maps.bpf.h @@ -0,0 +1,13 @@ +//+build ignore + +struct { + __uint(type, BPF_MAP_TYPE_RINGBUF); + __uint(max_entries, 1 << 24); +} event_map SEC(".maps"); + +struct { + __uint(type, BPF_MAP_TYPE_HASH); + __type(key, u32); + __type(value, struct flags); + __uint(max_entries, 1 << 24); +} flags_map SEC(".maps"); diff --git a/internal/types/types.bpf.h b/internal/types/types.bpf.h new file mode 100644 index 0000000..57feaaa --- /dev/null +++ b/internal/types/types.bpf.h @@ -0,0 +1,37 @@ +//+build ignore + +// These types mirror the Go types from internal/types/types.go +// +#define MAX_FILENAME_LENGTH 256 +#define MAX_PROGNAME_LENGTH 16 + +#define OPENAT_ENTER_OP_ID 1 +#define OPENAT_EXIT_OP_ID 2 +#define CLOSE_ENTER_OP_ID 3 +#define CLOSE_EXIT_OP_ID 4 + +struct null_event { + __u32 op_id; + __u32 tid; + __u64 time; +}; + +struct fd_event { + __u32 op_id; + __u32 tid; + __u64 time; + __s32 fd; +}; + +struct openat_enter_event { + __u32 op_id; + __u32 tid; + __u64 time; + char filename[MAX_FILENAME_LENGTH]; + char comm[MAX_PROGNAME_LENGTH]; +}; + +struct flags { + __u32 uid_filter; +}; + diff --git a/ioriotng.bpf.c b/ioriotng.bpf.c index a4785da..1b64ee4 100644 --- a/ioriotng.bpf.c +++ b/ioriotng.bpf.c @@ -1,9 +1,9 @@ //+build ignore -#include "vmlinux.h" +#include "internal/types/vmlinux.h" #include -#include "types.bpf.h" -#include "maps.bpf.h" +#include "internal/types/types.bpf.h" +#include "internal/types/maps.bpf.h" static inline int filter() { u32 key = 1; diff --git a/maps.bpf.h b/maps.bpf.h deleted file mode 100644 index dc55993..0000000 --- a/maps.bpf.h +++ /dev/null @@ -1,13 +0,0 @@ -//+build ignore - -struct { - __uint(type, BPF_MAP_TYPE_RINGBUF); - __uint(max_entries, 1 << 24); -} event_map SEC(".maps"); - -struct { - __uint(type, BPF_MAP_TYPE_HASH); - __type(key, u32); - __type(value, struct flags); - __uint(max_entries, 1 << 24); -} flags_map SEC(".maps"); diff --git a/types.bpf.h b/types.bpf.h deleted file mode 100644 index 57feaaa..0000000 --- a/types.bpf.h +++ /dev/null @@ -1,37 +0,0 @@ -//+build ignore - -// These types mirror the Go types from internal/types/types.go -// -#define MAX_FILENAME_LENGTH 256 -#define MAX_PROGNAME_LENGTH 16 - -#define OPENAT_ENTER_OP_ID 1 -#define OPENAT_EXIT_OP_ID 2 -#define CLOSE_ENTER_OP_ID 3 -#define CLOSE_EXIT_OP_ID 4 - -struct null_event { - __u32 op_id; - __u32 tid; - __u64 time; -}; - -struct fd_event { - __u32 op_id; - __u32 tid; - __u64 time; - __s32 fd; -}; - -struct openat_enter_event { - __u32 op_id; - __u32 tid; - __u64 time; - char filename[MAX_FILENAME_LENGTH]; - char comm[MAX_PROGNAME_LENGTH]; -}; - -struct flags { - __u32 uid_filter; -}; - -- cgit v1.2.3