Skip to content

Commit

Permalink
tetragon: Store link in program.Program
Browse files Browse the repository at this point in the history
Storing link in program so we can access link's stats
and store them as metrics.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Mar 30, 2024
1 parent 8079b30 commit 4ae7e3a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/sensors/program/loader.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ func kprobeAttach(load *Program, prog *ebpf.Program, spec *ebpf.ProgramSpec, sym
if err != nil {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
load.Link = lnk
return &unloader.RelinkUnloader{
UnloadProg: unloader.PinUnloader{Prog: prog}.Unload,
IsLinked: true,
Expand Down Expand Up @@ -370,6 +371,7 @@ func multiKprobeAttach(load *Program, prog *ebpf.Program,
if err != nil {
return nil, fmt.Errorf("attaching '%s' failed: %w", spec.Name, err)
}
load.Link = lnk
return unloader.ChainUnloader{
unloader.PinUnloader{
Prog: prog,
Expand Down
4 changes: 4 additions & 0 deletions pkg/sensors/program/program.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"fmt"

"github.com/cilium/ebpf"
"github.com/cilium/ebpf/link"
"github.com/cilium/tetragon/pkg/sensors/unloader"
)

Expand All @@ -30,6 +31,7 @@ func Builder(
PinMap: make(map[string]string),
MaxEntriesMap: make(map[string]uint32),
MaxEntriesInnerMap: make(map[string]uint32),
Link: nil,
}
}

Expand Down Expand Up @@ -102,6 +104,8 @@ type Program struct {

MaxEntriesMap map[string]uint32
MaxEntriesInnerMap map[string]uint32

Link link.Link
}

func (p *Program) SetRetProbe(ret bool) *Program {
Expand Down

0 comments on commit 4ae7e3a

Please sign in to comment.