Skip to content

Commit

Permalink
tetragon: Add sensor PostLoadHook hook
Browse files Browse the repository at this point in the history
Adding sensor PostLoadHook hook, it will be used in following
changes in kprobe sensor to kill the stats timer.

Signed-off-by: Jiri Olsa <[email protected]>
  • Loading branch information
olsajiri committed Mar 30, 2024
1 parent 97c3f03 commit 1959f24
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions pkg/sensors/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ func (s *Sensor) Load(bpfDir string) error {
p.LoadState.RefInc()
l.WithField("prog", p.Name).WithField("label", p.Label).Debugf("BPF prog was loaded")
}
if s.PostLoadHook != nil {
if err := s.PostLoadHook(); err != nil {
logger.GetLogger().WithError(err).WithField("sensor", s.Name).Warn("Post load hook failed")
}
}
l.WithField("sensor", s.Name).Infof("Loaded BPF maps and events for sensor successfully")
s.Loaded = true
return nil
Expand Down
2 changes: 2 additions & 0 deletions pkg/sensors/sensors.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ type Sensor struct {
Loaded bool
// Destroyed indicates whether the sensor had been destroyed.
Destroyed bool
// PostLoadHook hook
PostLoadHook SensorHook
// PreUnloadHook can optionally contain a pointer to a function to be
// called during sensor unloading, prior to the programs and maps being
// unloaded.
Expand Down

0 comments on commit 1959f24

Please sign in to comment.