Skip to content

Commit

Permalink
chore: add event_config alignment check
Browse files Browse the repository at this point in the history
declare a dummy event_config struct in bpf_alignchecker and check it in alignchecker.go

Close #108

Signed-off-by: Peihao Yang <[email protected]>
  • Loading branch information
Forsworns committed Jun 28, 2022
1 parent 7fd8213 commit 2a0b9e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bpf/alignchecker/bpf_alignchecker.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#include "include/vmlinux.h"
#include "include/api.h"
#include "lib/hubble_msg.h"
#include "process/retprobe_map.h"
#include "process/types/basic.h"

/* DECLARE declares a unique usage of the union or struct 'x' on the stack.
*
Expand Down Expand Up @@ -36,6 +38,7 @@ int main(void)
// from maps
DECLARE(struct, event, iter);
DECLARE(struct, execve_map_value, iter);
DECLARE(struct, event_config, iter);

return 0;
}
2 changes: 2 additions & 0 deletions pkg/alignchecker/alignchecker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (

"github.com/cilium/tetragon/pkg/api/processapi"
"github.com/cilium/tetragon/pkg/api/testapi"
"github.com/cilium/tetragon/pkg/api/tracingapi"
"github.com/cilium/tetragon/pkg/sensors/exec/execvemap"

check "github.com/cilium/cilium/pkg/alignchecker"
Expand All @@ -29,6 +30,7 @@ func CheckStructAlignments(path string) error {
"msg_exit": {reflect.TypeOf(processapi.MsgExitEvent{})},
"msg_test": {reflect.TypeOf(testapi.MsgTestEvent{})},
"execve_map_value": {reflect.TypeOf(execvemap.ExecveValue{})},
"event_config": {reflect.TypeOf(tracingapi.EventConfig{})},
}
return check.CheckStructAlignments(path, toCheck, true)
}

0 comments on commit 2a0b9e7

Please sign in to comment.