Skip to content

Commit

Permalink
tetragon: Use program.SetTailCall for lsm probes
Browse files Browse the repository at this point in the history
Using program.SetTailCall for lsm probes and getting rid of
the map name check for tail call setup.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri authored and jrfastab committed Aug 1, 2024
1 parent 9d463fc commit 253cc56
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
16 changes: 2 additions & 14 deletions pkg/sensors/program/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ type AttachFunc func(*ebpf.Collection, *ebpf.CollectionSpec, *ebpf.Program, *ebp

type OpenFunc func(*ebpf.CollectionSpec) error

type tailCall struct {
m *Map
prefix string
}

type LoadOpts struct {
Attach AttachFunc
Open OpenFunc
Expand Down Expand Up @@ -660,18 +655,11 @@ func LoadTracingProgram(bpfDir string, load *Program, verbose int) error {
}

func LoadLSMProgram(bpfDir string, load *Program, verbose int) error {
var tc tailCall
for mName, m := range load.PinMap {
if mName == "lsm_calls" {
tc = tailCall{m, "lsm"}
break
}
}
opts := &LoadOpts{
Attach: LSMAttach(),
Open: LSMOpen(load),
TcMap: tc.m,
TcPrefix: tc.prefix,
TcMap: load.TcMap,
TcPrefix: load.TcPrefix,
}
return loadProgram(bpfDir, load, opts, verbose)
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/sensors/tracing/genericlsm.go
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,8 @@ func createLsmSensorFromEntry(lsmEntry *genericLsm,
tailCalls := program.MapBuilderPin("lsm_calls", sensors.PathJoin(pinPath, "lsm_calls"), load)
maps = append(maps, tailCalls)

load.SetTailCall("lsm", tailCalls)

filterMap := program.MapBuilderPin("filter_map", sensors.PathJoin(pinPath, "filter_map"), load)
maps = append(maps, filterMap)

Expand Down

0 comments on commit 253cc56

Please sign in to comment.